From 5746309cb4be2073d550ad7a6885e918631dbc38 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 15 Aug 2011 21:54:06 +0000 Subject: [PATCH] indentation --- src/arm/arm_api.c | 63 +- src/arm/gnunet-arm.c | 42 +- src/arm/gnunet-service-arm.c | 153 ++- src/arm/gnunet-service-arm_interceptor.c | 155 ++- src/arm/mockup-service.c | 15 +- src/arm/test_arm_api.c | 10 +- src/arm/test_exponential_backoff.c | 49 +- src/arm/test_gnunet_service_manager.c | 18 +- src/ats/ats_api.c | 103 +- src/block/block.c | 23 +- src/block/plugin_block_dht.c | 26 +- src/block/plugin_block_dns.c | 17 +- src/block/plugin_block_fs.c | 40 +- src/block/plugin_block_template.c | 16 +- src/block/plugin_block_test.c | 17 +- src/block/test_block.c | 20 +- src/chat/chat.c | 103 +- src/chat/gnunet-chat.c | 116 +- src/chat/gnunet-service-chat.c | 266 ++--- src/chat/test_chat.c | 107 +- src/chat/test_chat_private.c | 113 +- src/core/core_api.c | 109 +- src/core/core_api_iterate_peers.c | 36 +- src/core/gnunet-core-list-connections.c | 12 +- src/core/gnunet-service-core.c | 808 ++++++------- src/core/test_core_api.c | 82 +- src/core/test_core_api_preferences.c | 123 +- src/core/test_core_api_reliability.c | 92 +- src/core/test_core_api_send_to_self.c | 40 +- src/core/test_core_api_start_only.c | 48 +- src/core/test_core_quota_compliance.c | 183 ++- src/datacache/datacache.c | 37 +- src/datacache/perf_datacache.c | 47 +- src/datacache/plugin_datacache_mysql.c | 247 ++-- src/datacache/plugin_datacache_postgres.c | 170 ++- src/datacache/plugin_datacache_sqlite.c | 161 ++- src/datacache/plugin_datacache_template.c | 14 +- src/datacache/test_datacache.c | 39 +- src/datacache/test_datacache_quota.c | 15 +- src/datastore/datastore_api.c | 191 ++- src/datastore/gnunet-service-datastore.c | 299 ++--- src/datastore/perf_datastore_api.c | 83 +- src/datastore/perf_plugin_datastore.c | 89 +- src/datastore/plugin_datastore_mysql.c | 315 +++-- src/datastore/plugin_datastore_postgres.c | 376 +++--- src/datastore/plugin_datastore_sqlite.c | 429 +++---- src/datastore/plugin_datastore_template.c | 36 +- src/datastore/test_datastore_api.c | 280 ++--- src/datastore/test_datastore_api_management.c | 125 +- src/datastore/test_plugin_datastore.c | 63 +- src/dht/dht_api.c | 118 +- src/dht/dht_api_find_peer.c | 12 +- src/dht/dht_api_get_put.c | 43 +- src/dht/dhtlog.c | 8 +- src/dht/gnunet-dht-driver.c | 1029 ++++++++--------- src/dht/gnunet-dht-get-peer.c | 17 +- src/dht/gnunet-dht-get.c | 28 +- src/dht/gnunet-dht-put.c | 15 +- src/dht/gnunet-service-dht.c | 572 +++++---- src/dht/plugin_dhtlog_dummy.c | 31 +- src/dht/plugin_dhtlog_mysql.c | 678 +++++------ src/dht/plugin_dhtlog_mysql_dump.c | 107 +- src/dht/plugin_dhtlog_mysql_dump_load.c | 109 +- src/dht/test_dht_api.c | 53 +- src/dht/test_dht_multipeer.c | 96 +- src/dht/test_dht_twopeer.c | 90 +- src/dht/test_dht_twopeer_path_tracking.c | 74 +- src/dht/test_dht_twopeer_put_get.c | 103 +- src/dht/test_dhtlog.c | 9 +- src/dv/dv_api.c | 49 +- src/dv/gnunet-service-dv.c | 280 ++--- src/dv/plugin_transport_dv.c | 50 +- src/dv/test_transport_api_dv.c | 183 ++- src/fragmentation/defragmentation.c | 30 +- src/fragmentation/fragmentation.c | 35 +- src/fragmentation/test_fragmentation.c | 12 +- src/fs/fs.c | 521 ++++----- src/fs/fs_directory.c | 53 +- src/fs/fs_download.c | 370 +++--- src/fs/fs_file_information.c | 108 +- src/fs/fs_getopt.c | 15 +- src/fs/fs_list_indexed.c | 21 +- src/fs/fs_misc.c | 49 +- src/fs/fs_namespace.c | 163 ++- src/fs/fs_publish.c | 297 ++--- src/fs/fs_search.c | 154 ++- src/fs/fs_test_lib.c | 139 +-- src/fs/fs_tree.c | 46 +- src/fs/fs_unindex.c | 57 +- src/fs/fs_uri.c | 111 +- src/fs/gnunet-directory.c | 46 +- src/fs/gnunet-download.c | 52 +- src/fs/gnunet-pseudonym.c | 38 +- src/fs/gnunet-publish.c | 121 +- src/fs/gnunet-search.c | 46 +- src/fs/gnunet-service-fs.c | 61 +- src/fs/gnunet-service-fs_cp.c | 220 ++-- src/fs/gnunet-service-fs_indexing.c | 129 +-- src/fs/gnunet-service-fs_lc.c | 54 +- src/fs/gnunet-service-fs_pe.c | 75 +- src/fs/gnunet-service-fs_pr.c | 419 ++++--- src/fs/gnunet-service-fs_push.c | 50 +- src/fs/gnunet-service-fs_put.c | 58 +- src/fs/gnunet-unindex.c | 29 +- src/fs/perf_gnunet_service_fs_p2p.c | 84 +- src/fs/perf_gnunet_service_fs_p2p_trust.c | 102 +- src/fs/test_fs.c | 25 +- src/fs/test_fs_directory.c | 30 +- src/fs/test_fs_download.c | 94 +- src/fs/test_fs_download_indexed.c | 100 +- src/fs/test_fs_download_persistence.c | 86 +- src/fs/test_fs_download_recursive.c | 38 +- src/fs/test_fs_file_information.c | 65 +- src/fs/test_fs_list_indexed.c | 103 +- src/fs/test_fs_namespace.c | 48 +- src/fs/test_fs_namespace_list_updateable.c | 45 +- src/fs/test_fs_publish.c | 90 +- src/fs/test_fs_publish_persistence.c | 96 +- src/fs/test_fs_search.c | 70 +- src/fs/test_fs_search_persistence.c | 74 +- src/fs/test_fs_search_ranking.c | 25 +- src/fs/test_fs_start_stop.c | 28 +- src/fs/test_fs_test_lib.c | 37 +- src/fs/test_fs_unindex.c | 77 +- src/fs/test_fs_unindex_persistence.c | 81 +- src/fs/test_fs_uri.c | 10 +- src/fs/test_gnunet_service_fs_migration.c | 38 +- src/fs/test_gnunet_service_fs_p2p.c | 39 +- src/hello/hello.c | 78 +- src/hello/test_hello.c | 44 +- src/hostlist/gnunet-daemon-hostlist.c | 48 +- src/hostlist/hostlist-client.c | 151 +-- src/hostlist/hostlist-server.c | 125 +- src/hostlist/test_gnunet_daemon_hostlist.c | 34 +- .../test_gnunet_daemon_hostlist_learning.c | 131 +-- .../test_gnunet_daemon_hostlist_reconnect.c | 34 +- src/mesh/gnunet-service-mesh.c | 307 ++--- src/mesh/mesh_api.c | 77 +- src/mesh/mesh_api_new.c | 67 +- src/mesh/test_mesh_api.c | 28 +- src/mesh/test_mesh_small.c | 169 ++- src/nat/gnunet-helper-nat-client-windows.c | 61 +- src/nat/gnunet-helper-nat-client.c | 55 +- src/nat/gnunet-helper-nat-server-windows.c | 53 +- src/nat/gnunet-helper-nat-server.c | 55 +- src/nat/gnunet-nat-server.c | 45 +- src/nat/nat.c | 282 ++--- src/nat/nat_mini.c | 90 +- src/nat/nat_test.c | 95 +- src/nat/test_nat.c | 26 +- src/nat/test_nat_mini.c | 17 +- src/nat/test_nat_test.c | 24 +- src/nse/gnunet-nse-profiler.c | 208 ++-- src/nse/gnunet-service-nse.c | 181 ++- src/nse/nse_api.c | 27 +- src/nse/test_nse_api.c | 25 +- src/nse/test_nse_multipeer.c | 52 +- src/peerinfo-tool/gnunet-peerinfo.c | 50 +- src/peerinfo/gnunet-service-peerinfo.c | 101 +- src/peerinfo/peerinfo_api.c | 46 +- src/peerinfo/peerinfo_api_notify.c | 21 +- src/peerinfo/perf_peerinfo_api.c | 50 +- src/peerinfo/test_peerinfo_api.c | 44 +- src/statistics/gnunet-service-statistics.c | 92 +- src/statistics/gnunet-statistics.c | 30 +- src/statistics/statistics_api.c | 109 +- src/statistics/test_statistics_api.c | 60 +- src/statistics/test_statistics_api_loop.c | 23 +- src/statistics/test_statistics_api_watch.c | 39 +- src/template/gnunet-service-template.c | 11 +- src/template/gnunet-template.c | 13 +- src/testing/test_testing.c | 12 +- src/testing/test_testing_connect.c | 32 +- src/testing/test_testing_group.c | 17 +- src/testing/test_testing_group_remote.c | 22 +- src/testing/test_testing_large_topology.c | 190 ++- src/testing/test_testing_peergroup.c | 15 +- src/testing/test_testing_reconnect.c | 32 +- src/testing/test_testing_topology.c | 208 ++-- src/testing/test_testing_topology_blacklist.c | 90 +- src/testing/test_testing_topology_churn.c | 42 +- src/testing/testing.c | 484 ++++---- src/testing/testing_group.c | 973 ++++++++-------- src/testing/testing_peergroup.c | 221 ++-- src/topology/gnunet-daemon-topology.c | 210 ++-- src/topology/test_gnunet_daemon_topology.c | 27 +- src/transport/gnunet-service-transport-new.c | 102 +- src/transport/gnunet-service-transport.c | 900 +++++++------- src/transport/gnunet-service-transport_ats.c | 176 ++- .../gnunet-service-transport_blacklist.c | 64 +- .../gnunet-service-transport_clients.c | 117 +- .../gnunet-service-transport_hello.c | 31 +- .../gnunet-service-transport_neighbours.c | 88 +- .../gnunet-service-transport_plugins.c | 15 +- .../gnunet-service-transport_validation.c | 147 +-- .../gnunet-transport-certificate-creation.c | 17 +- .../gnunet-transport-list-connections.c | 12 +- src/transport/gnunet-transport-wlan-helper.c | 66 +- src/transport/perf_transport_ats.c | 7 +- src/transport/plugin_transport_http.c | 476 ++++---- src/transport/plugin_transport_smtp.c | 151 +-- src/transport/plugin_transport_tcp.c | 398 +++---- src/transport/plugin_transport_template.c | 20 +- src/transport/plugin_transport_udp.c | 216 ++-- src/transport/plugin_transport_unix.c | 103 +- src/transport/plugin_transport_wlan.c | 289 ++--- src/transport/test_plugin_transport.c | 42 +- src/transport/test_plugin_transport_http.c | 160 +-- src/transport/test_plugin_transport_https.c | 67 +- src/transport/test_plugin_transport_udp.c | 39 +- .../test_plugin_transport_wlan_dummy.c | 22 +- src/transport/test_quota_compliance.c | 88 +- src/transport/test_transport_api.c | 51 +- src/transport/test_transport_api_disconnect.c | 65 +- .../test_transport_api_multiaddress.c | 47 +- .../test_transport_api_reliability.c | 79 +- .../test_transport_api_unreliability.c | 88 +- src/transport/test_transport_ats.c | 29 +- .../test_transport_ats_multiple_peers.c | 158 ++- src/transport/test_transport_testing.c | 26 +- src/transport/transport-testing.c | 51 +- src/transport/transport_api.c | 85 +- src/transport/transport_api_address_iterate.c | 9 +- src/transport/transport_api_address_lookup.c | 15 +- src/transport/transport_api_blacklist.c | 40 +- .../transport_api_peer_address_lookup.c | 9 +- src/transport/wlan/radiotap-parser.c | 17 +- src/util/bandwidth.c | 45 +- src/util/bio.c | 50 +- src/util/client.c | 172 ++- src/util/common_allocation.c | 4 +- src/util/common_logging.c | 22 +- src/util/configuration.c | 109 +- src/util/connection.c | 184 ++- src/util/container_bloomfilter.c | 46 +- src/util/container_heap.c | 42 +- src/util/container_meta_data.c | 93 +- src/util/container_multihashmap.c | 19 +- src/util/container_slist.c | 9 +- src/util/crypto_aes.c | 34 +- src/util/crypto_hash.c | 35 +- src/util/crypto_hkdf.c | 28 +- src/util/crypto_kdf.c | 11 +- src/util/crypto_ksk.c | 46 +- src/util/crypto_random.c | 21 +- src/util/crypto_rsa.c | 153 ++- src/util/disk.c | 102 +- src/util/getopt.c | 75 +- src/util/getopt_helpers.c | 15 +- src/util/gnunet-config-diff.c | 3 +- src/util/gnunet-resolver.c | 12 +- src/util/gnunet-service-resolver.c | 71 +- src/util/network.c | 27 +- src/util/os_installation.c | 10 +- src/util/os_network.c | 33 +- src/util/os_priority.c | 110 +- src/util/peer.c | 11 +- src/util/perf_crypto_hash.c | 8 +- src/util/plugin.c | 3 +- src/util/program.c | 15 +- src/util/pseudonym.c | 50 +- src/util/resolver_api.c | 80 +- src/util/scheduler.c | 149 ++- src/util/server.c | 77 +- src/util/server_mst.c | 5 +- src/util/server_nc.c | 37 +- src/util/server_tc.c | 14 +- src/util/service.c | 257 ++-- src/util/strings.c | 7 +- src/util/test_client.c | 22 +- src/util/test_common_endian.c | 4 +- src/util/test_common_logging.c | 4 +- src/util/test_configuration.c | 70 +- src/util/test_connection.c | 25 +- src/util/test_connection_addressing.c | 34 +- src/util/test_connection_receive_cancel.c | 19 +- src/util/test_connection_timeout.c | 10 +- src/util/test_connection_timeout_no_connect.c | 7 +- src/util/test_connection_transmit_cancel.c | 7 +- src/util/test_container_bloomfilter.c | 4 +- src/util/test_container_heap.c | 3 +- src/util/test_container_meta_data.c | 93 +- src/util/test_container_multihashmap.c | 35 +- src/util/test_container_slist.c | 9 +- src/util/test_crypto_aes.c | 33 +- src/util/test_crypto_aes_weak.c | 15 +- src/util/test_crypto_hkdf.c | 8 +- src/util/test_crypto_ksk.c | 43 +- src/util/test_crypto_rsa.c | 77 +- src/util/test_disk.c | 30 +- src/util/test_os_network.c | 11 +- src/util/test_os_start_process.c | 5 +- src/util/test_program.c | 29 +- src/util/test_pseudonym.c | 45 +- src/util/test_resolver_api.c | 37 +- src/util/test_scheduler.c | 20 +- src/util/test_scheduler_delay.c | 8 +- src/util/test_server.c | 10 +- src/util/test_server_disconnect.c | 3 +- src/util/test_server_with_client.c | 17 +- src/util/test_server_with_client_unix.c | 17 +- src/util/test_service.c | 52 +- src/util/test_time.c | 7 +- src/util/time.c | 29 +- src/util/winproc.c | 105 +- src/vpn/gnunet-daemon-exit.c | 121 +- src/vpn/gnunet-daemon-vpn-dns.c | 8 +- src/vpn/gnunet-daemon-vpn-helper.c | 109 +- src/vpn/gnunet-daemon-vpn.c | 59 +- src/vpn/gnunet-dns-parser.c | 4 +- src/vpn/gnunet-helper-vpn-api.c | 19 +- src/vpn/gnunet-helper-vpn.c | 49 +- src/vpn/gnunet-service-dns.c | 174 ++- 313 files changed, 12717 insertions(+), 16341 deletions(-) diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 0db9e5c3e..cc75e46da 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -141,8 +141,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) "Received confirmation for service shutdown.\n"); #endif shutdown_ctx->confirmed = GNUNET_YES; - GNUNET_CLIENT_receive (shutdown_ctx->sock, - &service_shutdown_handler, + GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); break; default: /* Fall through */ @@ -206,9 +205,8 @@ write_shutdown (void *cls, size_t size, void *buf) return 0; /* client disconnected */ } - GNUNET_CLIENT_receive (shutdown_ctx->sock, - &service_shutdown_handler, shutdown_ctx, - GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, + shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (shutdown_ctx->timeout), @@ -246,11 +244,9 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, shutdown_ctx->sock = sock; shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); GNUNET_CLIENT_notify_transmit_ready (sock, - sizeof (struct - GNUNET_MessageHeader), - timeout, - GNUNET_YES, - &write_shutdown, shutdown_ctx); + sizeof (struct GNUNET_MessageHeader), + timeout, GNUNET_YES, &write_shutdown, + shutdown_ctx); } @@ -378,16 +374,16 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "gnunet-service-arm"); #endif if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, - "arm", "PREFIX", &loprefix)) + GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "PREFIX", + &loprefix)) loprefix = GNUNET_strdup (""); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, - "arm", "OPTIONS", &lopostfix)) + GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "OPTIONS", + &lopostfix)) lopostfix = GNUNET_strdup (""); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, - "arm", "BINARY", &binary)) + GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY", + &binary)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -401,8 +397,8 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, - "arm", "CONFIG", &config)) + GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG", + &config)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -519,10 +515,9 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) * @param type type of the request */ static void -change_service (struct GNUNET_ARM_Handle *h, - const char *service_name, - struct GNUNET_TIME_Relative timeout, - GNUNET_ARM_Callback cb, void *cb_cls, uint16_t type) +change_service (struct GNUNET_ARM_Handle *h, const char *service_name, + struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, + void *cb_cls, uint16_t type) { struct RequestContext *sctx; size_t slen; @@ -539,9 +534,10 @@ change_service (struct GNUNET_ARM_Handle *h, } #if DEBUG_ARM GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - (type == GNUNET_MESSAGE_TYPE_ARM_START) - ? _("Requesting start of service `%s'.\n") - : _("Requesting termination of service `%s'.\n"), service_name); + (type == + GNUNET_MESSAGE_TYPE_ARM_START) ? + _("Requesting start of service `%s'.\n") : + _("Requesting termination of service `%s'.\n"), service_name); #endif sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); sctx->h = h; @@ -555,15 +551,14 @@ change_service (struct GNUNET_ARM_Handle *h, msg->type = htons (sctx->type); memcpy (&msg[1], service_name, slen); if (GNUNET_OK != - GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, - msg, + GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, msg, GNUNET_TIME_absolute_get_remaining (sctx->timeout), GNUNET_YES, &handle_response, sctx)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - (type == GNUNET_MESSAGE_TYPE_ARM_START) - ? + (type == + GNUNET_MESSAGE_TYPE_ARM_START) ? _ ("Error while trying to transmit request to start `%s' to ARM\n") : @@ -590,8 +585,7 @@ change_service (struct GNUNET_ARM_Handle *h, * @param cb_cls closure for callback */ void -GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, - const char *service_name, +GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_name, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls) { @@ -616,8 +610,8 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, sctx->cls = cb_cls; sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); memcpy (&sctx[1], service_name, slen); - GNUNET_CLIENT_service_test ("arm", - h->cfg, timeout, &arm_service_report, sctx); + GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, + sctx); return; } if (h->client == NULL) @@ -670,8 +664,7 @@ arm_shutdown_callback (void *cls, int reason) * @param cb_cls closure for callback */ void -GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, - const char *service_name, +GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, const char *service_name, struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, void *cb_cls) { diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index f7ff536be..cf5e1592a 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c @@ -177,14 +177,14 @@ confirm_cb (void *cls, int success) break; case GNUNET_SYSERR: if (quiet != GNUNET_YES) - fprintf (stdout, - _("Some error communicating with service `%s'.\n"), service); + fprintf (stdout, _("Some error communicating with service `%s'.\n"), + service); ret = 1; break; } - GNUNET_SCHEDULER_add_continuation (&cps_loop, - NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -210,8 +210,8 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (quiet != GNUNET_YES) fprintf (stdout, _("Service `%s' is not running.\n"), service); } - GNUNET_SCHEDULER_add_continuation (&cps_loop, - NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -224,9 +224,8 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; config_file = cfgfile; @@ -247,8 +246,8 @@ run (void *cls, ret = 1; return; } - GNUNET_SCHEDULER_add_continuation (&cps_loop, - NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } /** @@ -306,8 +305,9 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_ARM_stop_service (h, "arm", (0 == - timeout.rel_value) ? STOP_TIMEOUT_ARM : - timeout, &confirm_cb, "arm"); + timeout. + rel_value) ? STOP_TIMEOUT_ARM : timeout, + &confirm_cb, "arm"); return; } break; @@ -336,8 +336,9 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_CLIENT_service_test (test, cfg, (0 == - timeout.rel_value) ? TEST_TIMEOUT : - timeout, &confirm_task, test); + timeout. + rel_value) ? TEST_TIMEOUT : timeout, + &confirm_task, test); return; } break; @@ -412,12 +413,11 @@ main (int argc, char *const *argv) if (temp_timeout_ms > 0) timeout.rel_value = temp_timeout_ms; - if (GNUNET_OK == GNUNET_PROGRAM_run (argc, - argv, - "gnunet-arm", - gettext_noop - ("Control services and the Automated Restart Manager (ARM)"), - options, &run, NULL)) + if (GNUNET_OK == + GNUNET_PROGRAM_run (argc, argv, "gnunet-arm", + gettext_noop + ("Control services and the Automated Restart Manager (ARM)"), + options, &run, NULL)) { return ret; } diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index e4a8e7c6c..ddccb7fa0 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -198,8 +198,8 @@ config_change_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) while (pos != NULL) { /* FIXME: this test for config change may be a bit too coarse grained */ - if ((0 == STAT (pos->config, &sbuf)) && - (pos->mtime < sbuf.st_mtime) && (pos->proc != NULL)) + if ((0 == STAT (pos->config, &sbuf)) && (pos->mtime < sbuf.st_mtime) && + (pos->proc != NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ @@ -235,8 +235,8 @@ write_result (void *cls, size_t size, void *buf) return 0; /* error, not much we can do */ } #if DEBUG_ARM - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending status response %u to client\n", (unsigned int) *res); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending status response %u to client\n", + (unsigned int) *res); #endif GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); msg = buf; @@ -257,8 +257,8 @@ write_result (void *cls, size_t size, void *buf) * @return NULL if it was not found */ static void -signal_result (struct GNUNET_SERVER_Client *client, - const char *name, uint16_t result) +signal_result (struct GNUNET_SERVER_Client *client, const char *name, + uint16_t result) { uint16_t *res; @@ -270,8 +270,8 @@ signal_result (struct GNUNET_SERVER_Client *client, } #if DEBUG_ARM GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Telling client that service `%s' is now %s\n", - name, result == GNUNET_MESSAGE_TYPE_ARM_IS_DOWN ? "down" : "up"); + "Telling client that service `%s' is now %s\n", name, + result == GNUNET_MESSAGE_TYPE_ARM_IS_DOWN ? "down" : "up"); #endif res = GNUNET_malloc (sizeof (uint16_t)); *res = result; @@ -344,12 +344,12 @@ start_process (struct ServiceList *sl, const int *lsocks) /* start service */ if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - sl->name, "PREFIX", &loprefix)) + GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "PREFIX", + &loprefix)) loprefix = GNUNET_strdup (prefix_command); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - sl->name, "OPTIONS", &options)) + GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "OPTIONS", + &options)) { options = GNUNET_strdup (final_option); if (NULL == strstr (options, "%")) @@ -376,8 +376,8 @@ start_process (struct ServiceList *sl, const int *lsocks) next = optend + 1; *optend = '\0'; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", - optpos + 1, &val)) + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", optpos + 1, + &val)) val = GNUNET_strdup (""); *optpos = '\0'; GNUNET_asprintf (&optpos, "%s%s%c%s", options, val, b, next); @@ -395,18 +395,16 @@ start_process (struct ServiceList *sl, const int *lsocks) sl->name, sl->binary, sl->config); #endif if (GNUNET_YES == use_debug) - sl->proc = do_start_process (lsocks, - loprefix, - sl->binary, - "-c", sl->config, - "-L", "DEBUG", options, NULL); + sl->proc = + do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config, "-L", + "DEBUG", options, NULL); else - sl->proc = do_start_process (lsocks, - loprefix, - sl->binary, "-c", sl->config, options, NULL); + sl->proc = + do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config, + options, NULL); if (sl->proc == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to start service `%s'\n"), sl->name); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start service `%s'\n"), + sl->name); else GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting service `%s'\n"), sl->name); GNUNET_free (loprefix); @@ -423,8 +421,8 @@ start_process (struct ServiceList *sl, const int *lsocks) * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -start_service (struct GNUNET_SERVER_Client *client, - const char *servicename, const int *lsocks) +start_service (struct GNUNET_SERVER_Client *client, const char *servicename, + const int *lsocks) { struct ServiceList *sl; char *binary; @@ -442,14 +440,14 @@ start_service (struct GNUNET_SERVER_Client *client, sl = find_service (servicename); if (sl != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Service `%s' already running.\n"), servicename); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Service `%s' already running.\n"), + servicename); signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); return GNUNET_SYSERR; } if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - servicename, "BINARY", &binary)) + GNUNET_CONFIGURATION_get_value_string (cfg, servicename, "BINARY", + &binary)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Binary implementing service `%s' not known!\n"), @@ -458,9 +456,7 @@ start_service (struct GNUNET_SERVER_Client *client, return GNUNET_SYSERR; } if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - servicename, - "CONFIG", + GNUNET_CONFIGURATION_get_value_filename (cfg, servicename, "CONFIG", &config)) || (0 != STAT (config, &sbuf))) { @@ -499,8 +495,8 @@ stop_service (struct GNUNET_SERVER_Client *client, const char *servicename) { struct ServiceList *pos; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Preparing to stop `%s'\n"), servicename); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Preparing to stop `%s'\n"), + servicename); pos = find_service (servicename); if (pos == NULL) { @@ -515,8 +511,8 @@ stop_service (struct GNUNET_SERVER_Client *client, const char *servicename) { /* killing already in progress */ #if DEBUG_ARM - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Service `%s' is already down\n", servicename); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' is already down\n", + servicename); #endif signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); GNUNET_SERVER_receive_done (client, GNUNET_OK); @@ -564,8 +560,7 @@ stop_service (struct GNUNET_SERVER_Client *client, const char *servicename) * GNUNET_SYSERR to close it (signal serious error) */ static void -handle_start (void *cls, - struct GNUNET_SERVER_Client *client, +handle_start (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const char *servicename; @@ -595,8 +590,7 @@ handle_start (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static void -handle_stop (void *cls, - struct GNUNET_SERVER_Client *client, +handle_stop (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const char *servicename; @@ -720,16 +714,16 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Restarting service `%s'.\n"), pos->name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Restarting service `%s'.\n"), + pos->name); start_process (pos, NULL); } else { - lowestRestartDelay - = GNUNET_TIME_relative_min (lowestRestartDelay, - GNUNET_TIME_absolute_get_remaining - (pos->restartAt)); + lowestRestartDelay = + GNUNET_TIME_relative_min (lowestRestartDelay, + GNUNET_TIME_absolute_get_remaining (pos-> + restartAt)); } } pos = pos->next; @@ -737,13 +731,12 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (lowestRestartDelay.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) { #if DEBUG_ARM - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Will restart process in %llums\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will restart process in %llums\n", (unsigned long long) lowestRestartDelay.rel_value); #endif - child_restart_task - = GNUNET_SCHEDULER_add_delayed (lowestRestartDelay, - &delayed_restart_task, NULL); + child_restart_task = + GNUNET_SCHEDULER_add_delayed (lowestRestartDelay, &delayed_restart_task, + NULL); } } @@ -786,12 +779,10 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) next = pos->next; if (pos->proc == NULL) continue; - if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc, - &statusType, - &statusCode))) || - ((ret == GNUNET_NO) || - (statusType == GNUNET_OS_PROCESS_STOPPED) || - (statusType == GNUNET_OS_PROCESS_RUNNING))) + if ((GNUNET_SYSERR == + (ret = GNUNET_OS_process_status (pos->proc, &statusType, &statusCode))) + || ((ret == GNUNET_NO) || (statusType == GNUNET_OS_PROCESS_STOPPED) || + (statusType == GNUNET_OS_PROCESS_RUNNING))) continue; if (statusType == GNUNET_OS_PROCESS_EXITED) @@ -813,10 +804,10 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) pos->proc = NULL; if (NULL != pos->killing_client) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Service `%s' stopped\n"), pos->name); - signal_result (pos->killing_client, - pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' stopped\n"), + pos->name); + signal_result (pos->killing_client, pos->name, + GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); GNUNET_SERVER_receive_done (pos->killing_client, GNUNET_OK); GNUNET_SERVER_client_drop (pos->killing_client); free_service (pos); @@ -835,15 +826,15 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) pos->backoff = GNUNET_TIME_relative_multiply (pos->backoff, 2); if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) GNUNET_SCHEDULER_cancel (child_restart_task); - child_restart_task - = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, - &delayed_restart_task, NULL); + child_restart_task = + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, + &delayed_restart_task, NULL); } #if DEBUG_ARM else GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Service `%s' terminated with status %s/%d\n", - pos->name, statstr, statcode); + "Service `%s' terminated with status %s/%d\n", pos->name, + statstr, statcode); #endif } child_death_task = @@ -893,8 +884,7 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf) * @param message the actual message */ static void -handle_shutdown (void *cls, - struct GNUNET_SERVER_Client *client, +handle_shutdown (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GNUNET_SERVER_client_keep (client); @@ -935,8 +925,7 @@ sighandler_child_death () * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *serv, +run (void *cls, struct GNUNET_SERVER_Handle *serv, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -955,32 +944,28 @@ run (void *cls, pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); GNUNET_assert (pr != NULL); GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); child_death_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, &maint_child_death, NULL); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "ARM", - "GLOBAL_PREFIX", &prefix_command)) + GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "GLOBAL_PREFIX", + &prefix_command)) prefix_command = GNUNET_strdup (""); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "ARM", - "GLOBAL_POSTFIX", &final_option)) + GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "GLOBAL_POSTFIX", + &final_option)) final_option = GNUNET_strdup (""); /* start default services... */ if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, - "ARM", - "DEFAULTSERVICES", + GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "DEFAULTSERVICES", &defaultservices)) { #if DEBUG_ARM - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting default services `%s'\n", defaultservices); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting default services `%s'\n", + defaultservices); #endif if (0 < strlen (defaultservices)) { diff --git a/src/arm/gnunet-service-arm_interceptor.c b/src/arm/gnunet-service-arm_interceptor.c index b99b076da..6d417ba37 100644 --- a/src/arm/gnunet-service-arm_interceptor.c +++ b/src/arm/gnunet-service-arm_interceptor.c @@ -356,8 +356,8 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, int reason) * @param cls callback data, struct ForwardedConnection for the communication between client and service * @param tc context */ -static void -receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void receiveFromClient (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -366,15 +366,15 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); * @param cls callback data, struct ForwardedConnection for the communication between client and service * @param tc scheduler context */ -static void -receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void receiveFromService (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** * */ -static void -start_forwarding (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void start_forwarding (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); @@ -391,13 +391,13 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ssize_t numberOfBytesSent; fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; - if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->write_ready, - fc->armClientSocket)) + if (GNUNET_YES != + GNUNET_NETWORK_fdset_isset (tc->write_ready, fc->armClientSocket)) { fc->service_to_client_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &forwardToClient, fc); + fc->armClientSocket, &forwardToClient, + fc); return; } /* Forwarding service response to client */ @@ -415,8 +415,8 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } #if DEBUG_SERVICE_MANAGER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Forwarded %d bytes to client\n", numberOfBytesSent); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Forwarded %d bytes to client\n", + numberOfBytesSent); #endif if (numberOfBytesSent < fc->service_to_client_bufferDataLength) { @@ -424,14 +424,14 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fc->service_to_client_bufferDataLength -= numberOfBytesSent; fc->service_to_client_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &forwardToClient, fc); + fc->armClientSocket, &forwardToClient, + fc); return; } fc->service_to_client_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armServiceSocket, - &receiveFromService, fc); + fc->armServiceSocket, &receiveFromService, + fc); } @@ -454,8 +454,8 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) closeClientAndServiceSockets (fc, REASON_ERROR); return; } - if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->read_ready, - fc->armServiceSocket)) + if (GNUNET_YES != + GNUNET_NETWORK_fdset_isset (tc->read_ready, fc->armServiceSocket)) { fc->service_to_client_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, @@ -497,12 +497,12 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_a2s (fc->listen_info->service_addr, fc->listen_info->service_addr_len), (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, - rem).rel_value); + rem). + rel_value); #endif rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); - fc->start_task - = + fc->start_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off, rem), &start_forwarding, fc); @@ -520,14 +520,13 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } fc->first_write_done = GNUNET_YES; #if DEBUG_SERVICE_MANAGER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received %d bytes for client\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d bytes for client\n", fc->service_to_client_bufferDataLength); #endif fc->service_to_client_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &forwardToClient, fc); + fc->armClientSocket, &forwardToClient, + fc); } @@ -551,13 +550,13 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) closeClientAndServiceSockets (fc, REASON_ERROR); return; } - if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->write_ready, - fc->armServiceSocket)) + if (GNUNET_YES != + GNUNET_NETWORK_fdset_isset (tc->write_ready, fc->armServiceSocket)) { fc->client_to_service_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armServiceSocket, - &forwardToService, fc); + fc->armServiceSocket, &forwardToService, + fc); return; } numberOfBytesSent = @@ -585,12 +584,12 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_a2s (fc->listen_info->service_addr, fc->listen_info->service_addr_len), (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, - rem).rel_value); + rem). + rel_value); #endif rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); - fc->start_task - = + fc->start_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off, rem), &start_forwarding, fc); @@ -606,8 +605,8 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } #if DEBUG_SERVICE_MANAGER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Forwarded %d bytes to service\n", numberOfBytesSent); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Forwarded %d bytes to service\n", + numberOfBytesSent); #endif fc->first_write_done = GNUNET_YES; if (numberOfBytesSent < fc->client_to_service_bufferDataLength) @@ -616,14 +615,14 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fc->client_to_service_bufferDataLength -= numberOfBytesSent; fc->client_to_service_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armServiceSocket, - &forwardToService, fc); + fc->armServiceSocket, &forwardToService, + fc); return; } fc->client_to_service_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &receiveFromClient, fc); + fc->armClientSocket, &receiveFromClient, + fc); } @@ -639,13 +638,13 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct ForwardedConnection *fc = cls; fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; - if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->read_ready, - fc->armClientSocket)) + if (GNUNET_YES != + GNUNET_NETWORK_fdset_isset (tc->read_ready, fc->armClientSocket)) { fc->client_to_service_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &receiveFromClient, fc); + fc->armClientSocket, &receiveFromClient, + fc); return; } fc->client_to_service_bufferPos = fc->client_to_service_buffer; @@ -665,23 +664,22 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { #if DEBUG_SERVICE_MANAGER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Error receiving from client: %s\n", STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error receiving from client: %s\n", + STRERROR (errno)); #endif } closeClientAndServiceSockets (fc, REASON_CLIENT_TO_SERVICE); return; } #if DEBUG_SERVICE_MANAGER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received %d bytes for service\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d bytes for service\n", fc->client_to_service_bufferDataLength); #endif if (fc->armServiceSocket != NULL) fc->client_to_service_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armServiceSocket, - &forwardToService, fc); + fc->armServiceSocket, &forwardToService, + fc); else /* We have not added any task with fc as a closure, so we're * dropping our reference to fc @@ -742,8 +740,8 @@ fc_acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else fc->service_to_client_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &forwardToClient, fc); + fc->armClientSocket, &forwardToClient, + fc); fc->reference_count += 1; } GNUNET_free (sli); @@ -751,9 +749,8 @@ fc_acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static struct ServiceListeningInfo * -service_try_to_connect (const struct sockaddr *addr, - int pf, - socklen_t addrlen, struct ForwardedConnection *fc) +service_try_to_connect (const struct sockaddr *addr, int pf, socklen_t addrlen, + struct ForwardedConnection *fc) { struct GNUNET_NETWORK_Handle *sock; struct ServiceListeningInfo *serviceListeningInfo; @@ -839,8 +836,8 @@ start_forwarding (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) target_ipv4.sin_port = v4->sin_port; v4 = &target_ipv4; } - sc = service_try_to_connect ((const struct sockaddr *) v4, - PF_INET, sizeof (struct sockaddr_in), fc); + sc = service_try_to_connect ((const struct sockaddr *) v4, PF_INET, + sizeof (struct sockaddr_in), fc); break; case AF_INET6: v6 = (struct sockaddr_in6 *) fc->listen_info->service_addr; @@ -855,12 +852,11 @@ start_forwarding (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) target_ipv6.sin6_port = v6->sin6_port; v6 = &target_ipv6; } - sc = service_try_to_connect ((const struct sockaddr *) v6, - PF_INET6, sizeof (struct sockaddr_in6), fc); + sc = service_try_to_connect ((const struct sockaddr *) v6, PF_INET6, + sizeof (struct sockaddr_in6), fc); break; case AF_UNIX: - sc = service_try_to_connect (fc->listen_info->service_addr, - PF_UNIX, + sc = service_try_to_connect (fc->listen_info->service_addr, PF_UNIX, fc->listen_info->service_addr_len, fc); break; default: @@ -917,8 +913,8 @@ stop_listening (const char *serviceName) * @param cls callback data, struct ServiceListeningInfo describing a listen socket * @param tc context */ -static void -acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void acceptConnection (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); static void @@ -952,18 +948,18 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo) return; } GNUNET_break (GNUNET_OK == - GNUNET_NETWORK_socket_close - (serviceListeningInfo->listeningSocket)); + GNUNET_NETWORK_socket_close (serviceListeningInfo-> + listeningSocket)); start_service (NULL, serviceListeningInfo->serviceName, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Service `%s' started\n"), fc->listen_info->serviceName); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' started\n"), + fc->listen_info->serviceName); fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; fc->client_to_service_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - fc->armClientSocket, - &receiveFromClient, fc); + fc->armClientSocket, &receiveFromClient, + fc); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); /* We're creating another chain of tasks for this fc that * will have its own reference to it. @@ -997,12 +993,12 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) serviceListeningInfoList_tail, sli); #ifndef MINGW use_lsocks = GNUNET_NO; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, - sli->serviceName, - "DISABLE_SOCKET_FORWARDING")) - use_lsocks = GNUNET_CONFIGURATION_get_value_yesno (cfg, - sli->serviceName, - "DISABLE_SOCKET_FORWARDING"); + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (cfg, sli->serviceName, + "DISABLE_SOCKET_FORWARDING")) + use_lsocks = + GNUNET_CONFIGURATION_get_value_yesno (cfg, sli->serviceName, + "DISABLE_SOCKET_FORWARDING"); #else use_lsocks = GNUNET_YES; #endif @@ -1100,8 +1096,8 @@ createListeningSocket (struct sockaddr *sa, socklen_t addr_len, "setsockopt"); #endif - if (GNUNET_NETWORK_socket_bind - (sock, (const struct sockaddr *) sa, addr_len) != GNUNET_OK) + if (GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) sa, addr_len) + != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -1145,8 +1141,8 @@ createListeningSocket (struct sockaddr *sa, socklen_t addr_len, * @param value the option's value */ static void -checkPortNumberCB (void *cls, - const char *section, const char *option, const char *value) +checkPortNumberCB (void *cls, const char *section, const char *option, + const char *value) { struct sockaddr **addrs; socklen_t *addr_lens; @@ -1158,8 +1154,9 @@ checkPortNumberCB (void *cls, (strcasecmp (value, "YES") != 0) || (isInDefaultList (section) == GNUNET_YES)) return; - if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, - &addr_lens))) + if (0 >= + (ret = + GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, &addr_lens))) return; /* this will free (or capture) addrs[i] */ for (i = 0; i < ret; i++) diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c index 0a0e1de5a..53a502fa8 100644 --- a/src/arm/mockup-service.c +++ b/src/arm/mockup-service.c @@ -61,8 +61,7 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf) * @param message the actual message */ static void -handle_shutdown (void *cls, - struct GNUNET_SERVER_Client *client, +handle_shutdown (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GNUNET_SERVER_client_keep (client); @@ -79,8 +78,7 @@ handle_shutdown (void *cls, static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -99,10 +97,9 @@ main (int argc, char *const *argv) { int ret; - ret = (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "do-nothing", GNUNET_SERVICE_OPTION_NONE, - &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "do-nothing", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; return ret; } diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 1e9d84202..11c245ea1 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c @@ -114,9 +114,8 @@ arm_notify (void *cls, int success) static void -task (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +task (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; arm = GNUNET_ARM_connect (cfg, NULL); @@ -145,9 +144,8 @@ check () }; GNUNET_assert (GNUNET_OK == GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, - "test-arm-api", - "nohelp", options, &task, NULL)); + argv, "test-arm-api", "nohelp", options, + &task, NULL)); return ok; } diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index eb6421d5f..04c52d0eb 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -136,8 +136,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) "Received confirmation for service shutdown.\n"); #endif shutdown_ctx->confirmed = GNUNET_YES; - GNUNET_CLIENT_receive (shutdown_ctx->sock, - &service_shutdown_handler, + GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); break; default: /* Fall through */ @@ -197,9 +196,8 @@ write_shutdown (void *cls, size_t size, void *buf) return 0; /* client disconnected */ } - GNUNET_CLIENT_receive (shutdown_ctx->sock, - &service_shutdown_handler, shutdown_ctx, - GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, + shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (shutdown_ctx->timeout), @@ -237,11 +235,9 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, shutdown_ctx->sock = sock; shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); GNUNET_CLIENT_notify_transmit_ready (sock, - sizeof (struct - GNUNET_MessageHeader), - timeout, - GNUNET_NO, - &write_shutdown, shutdown_ctx); + sizeof (struct GNUNET_MessageHeader), + timeout, GNUNET_NO, &write_shutdown, + shutdown_ctx); } @@ -255,8 +251,8 @@ arm_notify_stop (void *cls, int success) } -static void -kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void kill_task (void *cbData, + const struct GNUNET_SCHEDULER_TaskContext *tc); static void @@ -272,13 +268,13 @@ static void arm_notify (void *cls, int success) { GNUNET_assert (success == GNUNET_YES); - GNUNET_ARM_start_service (arm, - "do-nothing", TIMEOUT, &do_nothing_notify, NULL); + GNUNET_ARM_start_service (arm, "do-nothing", TIMEOUT, &do_nothing_notify, + NULL); } -static void -kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void kill_task (void *cbData, + const struct GNUNET_SCHEDULER_TaskContext *tc); static void @@ -310,8 +306,7 @@ do_nothing_restarted_notify_task (void *cls, static void do_test (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_CLIENT_service_test ("do-nothing", - cfg, TIMEOUT, + GNUNET_CLIENT_service_test ("do-nothing", cfg, TIMEOUT, &do_nothing_restarted_notify_task, NULL); } @@ -335,8 +330,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); #if LOG_BACKOFF - fprintf (killLogFilePtr, - "Waited for: %llu ms\n", (unsigned long long) waitedFor.rel_value); + fprintf (killLogFilePtr, "Waited for: %llu ms\n", + (unsigned long long) waitedFor.rel_value); #endif } else @@ -349,8 +344,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) if (trialCount == 12) { GNUNET_CLIENT_disconnect (doNothingConnection, GNUNET_NO); - GNUNET_ARM_stop_service (arm, - "do-nothing", TIMEOUT, &arm_notify_stop, NULL); + GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, + NULL); ok = 0; return; } @@ -360,9 +355,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -task (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +task (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; @@ -393,9 +387,8 @@ check () /* Running ARM and running the do_nothing task */ GNUNET_assert (GNUNET_OK == GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, - "test-exponential-backoff", - "nohelp", options, &task, NULL)); + argv, "test-exponential-backoff", "nohelp", + options, &task, NULL)); return ok; diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c index 4c4de9242..4f863ed19 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_manager.c @@ -101,9 +101,9 @@ arm_notify (void *cls, int success) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to resolve our own hostname!\n"); /* connect to the resolver service */ - if (NULL == GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, - TIMEOUT, - &hostNameResolveCB, NULL)) + if (NULL == + GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT, &hostNameResolveCB, + NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable initiate connection to resolver service\n"); @@ -116,9 +116,8 @@ arm_notify (void *cls, int success) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; #if START_ARM @@ -146,8 +145,7 @@ check () }; GNUNET_assert (GNUNET_OK == GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, - "test-gnunet-service-manager", + argv, "test-gnunet-service-manager", "nohelp", options, &run, NULL)); } @@ -159,8 +157,8 @@ main (int argc, char *argv[]) if (0 != gethostname (hostname, sizeof (hostname) - 1)) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "gethostname"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "gethostname"); fprintf (stderr, "Failed to determine my own hostname, testcase not run.\n"); return 0; diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c index 6cd8a82ba..ca0954173 100644 --- a/src/ats/ats_api.c +++ b/src/ats/ats_api.c @@ -216,18 +216,16 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value) ar->bandwidth = sbc->bw; sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, (const struct GNUNET_PeerIdentity *) key, - ar->plugin_name, - ar->session, - ar->plugin_addr, ar->plugin_addr_len, ar->bandwidth); + ar->plugin_name, ar->session, ar->plugin_addr, + ar->plugin_addr_len, ar->bandwidth); } else if (ntohl (ar->bandwidth.value__) > 0) { ar->bandwidth = GNUNET_BANDWIDTH_value_init (0); sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, (const struct GNUNET_PeerIdentity *) key, - ar->plugin_name, - ar->session, - ar->plugin_addr, ar->plugin_addr_len, ar->bandwidth); + ar->plugin_name, ar->session, ar->plugin_addr, + ar->plugin_addr_len, ar->bandwidth); } return GNUNET_YES; } @@ -286,13 +284,10 @@ suggest_address (void *cls, const GNUNET_HashCode * key, void *value) struct AllocationRecord *ar = value; /* trivial strategy: pick first available address... */ - asc->cb (asc->cb_cls, - &asc->target, - ar->plugin_name, - ar->plugin_addr, + asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, ar->plugin_addr_len, - GNUNET_BANDWIDTH_value_init (asc->atc->total_bps / 32), - ar->ats, ar->ats_count); + GNUNET_BANDWIDTH_value_init (asc->atc->total_bps / 32), ar->ats, + ar->ats_count); asc->cb = NULL; return GNUNET_NO; } @@ -320,17 +315,14 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc, asc->cb_cls = cb_cls; asc->atc = atc; asc->target = *peer; - GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, - &peer->hashPubKey, + GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, &peer->hashPubKey, &suggest_address, asc); if (NULL == asc->cb) { GNUNET_free (asc); return NULL; } - GNUNET_CONTAINER_multihashmap_put (atc->notify_map, - &peer->hashPubKey, - asc, + GNUNET_CONTAINER_multihashmap_put (atc->notify_map, &peer->hashPubKey, asc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); return asc; } @@ -372,9 +364,8 @@ GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, atc->alloc_cb = alloc_cb; atc->alloc_cb_cls = alloc_cb_cls; atc->peers = GNUNET_CONTAINER_multihashmap_create (256); - GNUNET_CONFIGURATION_get_value_number (cfg, - "core", - "TOTAL_QUOTA_OUT", &atc->total_bps); + GNUNET_CONFIGURATION_get_value_number (cfg, "core", "TOTAL_QUOTA_OUT", + &atc->total_bps); return atc; } @@ -412,8 +403,8 @@ GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc) GNUNET_SCHEDULER_cancel (atc->ba_task); atc->ba_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_CONTAINER_multihashmap_iterate (atc->peers, - &destroy_allocation_record, NULL); + GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &destroy_allocation_record, + NULL); GNUNET_CONTAINER_multihashmap_destroy (atc->peers); GNUNET_assert (GNUNET_CONTAINER_multihashmap_size (atc->notify_map) == 0); GNUNET_CONTAINER_multihashmap_destroy (atc->notify_map); @@ -461,8 +452,9 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value) if ((arnew->session == arold->session) || ((arold->session == NULL) && (arold->plugin_addr_len == arnew->plugin_addr_len) && - (0 == memcmp (arold->plugin_addr, - arnew->plugin_addr, arnew->plugin_addr_len)))) + (0 == + memcmp (arold->plugin_addr, arnew->plugin_addr, + arnew->plugin_addr_len)))) { change = GNUNET_NO; /* records match */ @@ -497,10 +489,8 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value) * @param ats_count number of performance records in 'ats' */ static struct AllocationRecord * -create_allocation_record (const char *plugin_name, - struct Session *session, - const void *plugin_addr, - size_t plugin_addr_len, +create_allocation_record (const char *plugin_name, struct Session *session, + const void *plugin_addr, size_t plugin_addr_len, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -513,8 +503,8 @@ create_allocation_record (const char *plugin_name, ar->session = session; ar->plugin_addr_len = plugin_addr_len; GNUNET_array_grow (ar->ats, ar->ats_count, ats_count); - memcpy (ar->ats, - ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); + memcpy (ar->ats, ats, + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); return ar; } @@ -559,21 +549,18 @@ disconnect_peer (void *cls, const GNUNET_HashCode * key, void *value) void GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc, const struct GNUNET_PeerIdentity *peer, - const char *plugin_name, - struct Session *session, - const void *plugin_addr, - size_t plugin_addr_len, + const char *plugin_name, struct Session *session, + const void *plugin_addr, size_t plugin_addr_len, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { struct AllocationRecord *ar; struct UpdateSessionContext usc; - (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, - &disconnect_peer, atc); - ar = create_allocation_record (plugin_name, - session, - plugin_addr, plugin_addr_len, ats, ats_count); + (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &disconnect_peer, + atc); + ar = create_allocation_record (plugin_name, session, plugin_addr, + plugin_addr_len, ats, ats_count); ar->connected = GNUNET_YES; usc.atc = atc; usc.arnew = ar; @@ -585,8 +572,7 @@ GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc, } GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (atc->peers, - &peer->hashPubKey, - ar, + &peer->hashPubKey, ar, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); } @@ -646,8 +632,8 @@ destroy_session (void *cls, const GNUNET_HashCode * key, void *value) if (ar->plugin_addr != NULL) return GNUNET_OK; GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_remove (sdc->atc->peers, - key, ar)); + GNUNET_CONTAINER_multihashmap_remove (sdc->atc->peers, key, + ar)); if (GNUNET_YES == ar->connected) ; { /* FIXME: is this supposed to be allowed? What to do then? */ @@ -674,8 +660,8 @@ GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, sdc.atc = atc; sdc.session = session; - (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, - &destroy_session, &sdc); + (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &destroy_session, + &sdc); } @@ -693,13 +679,10 @@ notify_valid (void *cls, const GNUNET_HashCode * key, void *value) struct AllocationRecord *ar = cls; struct GNUNET_ATS_SuggestionContext *asc = value; - asc->cb (asc->cb_cls, - &asc->target, - ar->plugin_name, - ar->plugin_addr, + asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr, ar->plugin_addr_len, - GNUNET_BANDWIDTH_value_init (asc->atc->total_bps / 32), - ar->ats, ar->ats_count); + GNUNET_BANDWIDTH_value_init (asc->atc->total_bps / 32), ar->ats, + ar->ats_count); GNUNET_ATS_suggest_address_cancel (asc); return GNUNET_OK; } @@ -727,19 +710,16 @@ void GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, const struct GNUNET_PeerIdentity *peer, struct GNUNET_TIME_Absolute valid_until, - const char *plugin_name, - struct Session *session, - const void *plugin_addr, - size_t plugin_addr_len, + const char *plugin_name, struct Session *session, + const void *plugin_addr, size_t plugin_addr_len, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { struct AllocationRecord *ar; struct UpdateSessionContext usc; - ar = create_allocation_record (plugin_name, - session, - plugin_addr, plugin_addr_len, ats, ats_count); + ar = create_allocation_record (plugin_name, session, plugin_addr, + plugin_addr_len, ats, ats_count); usc.atc = atc; usc.arnew = ar; if (GNUNET_SYSERR == @@ -750,12 +730,11 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, } GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (atc->peers, - &peer->hashPubKey, - ar, + &peer->hashPubKey, ar, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); GNUNET_CONTAINER_multihashmap_get_multiple (atc->notify_map, - &peer->hashPubKey, - ¬ify_valid, ar); + &peer->hashPubKey, ¬ify_valid, + ar); } /* end of file gnunet-service-transport_ats.c */ diff --git a/src/block/block.c b/src/block/block.c index bdef55aa3..ac466337c 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -72,8 +72,8 @@ struct GNUNET_BLOCK_Context * @param hc where to store the result. */ void -GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, - uint32_t mingle_number, GNUNET_HashCode * hc) +GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, uint32_t mingle_number, + GNUNET_HashCode * hc) { GNUNET_HashCode m; @@ -105,8 +105,8 @@ GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg) if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "block", "PLUGINS", &plugs)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading block plugins `%s'\n"), plugs); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading block plugins `%s'\n"), + plugs); pos = strtok (plugs, " "); while (pos != NULL) { @@ -212,18 +212,16 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * query, struct GNUNET_CONTAINER_BloomFilter **bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - const void *reply_block, size_t reply_block_size) + int32_t bf_mutator, const void *xquery, + size_t xquery_size, const void *reply_block, + size_t reply_block_size) { struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); if (plugin == NULL) return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; - return plugin->evaluate (plugin->cls, - type, query, bf, bf_mutator, - xquery, xquery_size, reply_block, reply_block_size); + return plugin->evaluate (plugin->cls, type, query, bf, bf_mutator, xquery, + xquery_size, reply_block, reply_block_size); } @@ -240,8 +238,7 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx, */ int GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, - enum GNUNET_BLOCK_Type type, - const void *block, + enum GNUNET_BLOCK_Type type, const void *block, size_t block_size, GNUNET_HashCode * key) { struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); diff --git a/src/block/plugin_block_dht.c b/src/block/plugin_block_dht.c index 1fe51e1a3..614628a40 100644 --- a/src/block/plugin_block_dht.c +++ b/src/block/plugin_block_dht.c @@ -49,14 +49,12 @@ * @return characterization of result */ static enum GNUNET_BLOCK_EvaluationResult -block_plugin_dht_evaluate (void *cls, - enum GNUNET_BLOCK_Type type, +block_plugin_dht_evaluate (void *cls, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * query, struct GNUNET_CONTAINER_BloomFilter **bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - const void *reply_block, size_t reply_block_size) + int32_t bf_mutator, const void *xquery, + size_t xquery_size, const void *reply_block, + size_t reply_block_size) { switch (type) { @@ -85,10 +83,9 @@ block_plugin_dht_evaluate (void *cls, * (or if extracting a key from a block of this type does not work) */ static int -block_plugin_dht_get_key (void *cls, - enum GNUNET_BLOCK_Type type, - const void *block, - size_t block_size, GNUNET_HashCode * key) +block_plugin_dht_get_key (void *cls, enum GNUNET_BLOCK_Type type, + const void *block, size_t block_size, + GNUNET_HashCode * key) { const struct GNUNET_MessageHeader *msg; const struct GNUNET_HELLO_Message *hello; @@ -98,16 +95,14 @@ block_plugin_dht_get_key (void *cls, return GNUNET_SYSERR; if (block_size < sizeof (struct GNUNET_MessageHeader)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "block-dht", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", _("Block not of type %u\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); return GNUNET_NO; } msg = block; if (block_size != ntohs (msg->size)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "block-dht", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", _("Size mismatch for block\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); return GNUNET_NO; @@ -116,8 +111,7 @@ block_plugin_dht_get_key (void *cls, pid = (struct GNUNET_PeerIdentity *) key; if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "block-dht", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", _("Block of type %u is malformed\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); return GNUNET_NO; diff --git a/src/block/plugin_block_dns.c b/src/block/plugin_block_dns.c index 0cf8c50e9..e20370685 100644 --- a/src/block/plugin_block_dns.c +++ b/src/block/plugin_block_dns.c @@ -47,14 +47,12 @@ * @return characterization of result */ static enum GNUNET_BLOCK_EvaluationResult -block_plugin_dns_evaluate (void *cls, - enum GNUNET_BLOCK_Type type, +block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * query, struct GNUNET_CONTAINER_BloomFilter **bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - const void *reply_block, size_t reply_block_size) + int32_t bf_mutator, const void *xquery, + size_t xquery_size, const void *reply_block, + size_t reply_block_size) { switch (type) { @@ -123,10 +121,9 @@ block_plugin_dns_evaluate (void *cls, * (or if extracting a key from a block of this type does not work) */ static int -block_plugin_dns_get_key (void *cls, - enum GNUNET_BLOCK_Type type, - const void *block, - size_t block_size, GNUNET_HashCode * key) +block_plugin_dns_get_key (void *cls, enum GNUNET_BLOCK_Type type, + const void *block, size_t block_size, + GNUNET_HashCode * key) { if (type != GNUNET_BLOCK_TYPE_DNS) return GNUNET_SYSERR; diff --git a/src/block/plugin_block_fs.c b/src/block/plugin_block_fs.c index db8e59991..627f21a10 100644 --- a/src/block/plugin_block_fs.c +++ b/src/block/plugin_block_fs.c @@ -56,14 +56,12 @@ * @return characterization of result */ static enum GNUNET_BLOCK_EvaluationResult -block_plugin_fs_evaluate (void *cls, - enum GNUNET_BLOCK_Type type, +block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * query, struct GNUNET_CONTAINER_BloomFilter **bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - const void *reply_block, size_t reply_block_size) + int32_t bf_mutator, const void *xquery, + size_t xquery_size, const void *reply_block, + size_t reply_block_size) { const struct SBlock *sb; GNUNET_HashCode chash; @@ -125,8 +123,7 @@ block_plugin_fs_evaluate (void *cls, &sh); if (0 != memcmp (nsid, &sh, sizeof (GNUNET_HashCode))) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "block-fs", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "block-fs", _ ("Reply mismatched in terms of namespace. Discarded.\n")); return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; @@ -162,10 +159,9 @@ block_plugin_fs_evaluate (void *cls, * (or if extracting a key from a block of this type does not work) */ static int -block_plugin_fs_get_key (void *cls, - enum GNUNET_BLOCK_Type type, - const void *block, - size_t block_size, GNUNET_HashCode * key) +block_plugin_fs_get_key (void *cls, enum GNUNET_BLOCK_Type type, + const void *block, size_t block_size, + GNUNET_HashCode * key) { const struct KBlock *kb; const struct SBlock *sb; @@ -185,9 +181,9 @@ block_plugin_fs_get_key (void *cls, } kb = block; if (block_size - sizeof (struct KBlock) != - ntohl (kb->purpose.size) - - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) - - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)) + ntohl (kb->purpose.size) - + sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) - + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)) { GNUNET_break_op (0); return GNUNET_NO; @@ -236,9 +232,9 @@ block_plugin_fs_get_key (void *cls, } nb = block; if (block_size - sizeof (struct NBlock) != - ntohl (nb->ns_purpose.size) - - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) - - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)) + ntohl (nb->ns_purpose.size) - + sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) - + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)) { GNUNET_break_op (0); return GNUNET_NO; @@ -252,16 +248,16 @@ block_plugin_fs_get_key (void *cls, } if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG, - &nb->ksk_purpose, - &nb->ksk_signature, &nb->keyspace)) + &nb->ksk_purpose, &nb->ksk_signature, + &nb->keyspace)) { GNUNET_break_op (0); return GNUNET_NO; } if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK, - &nb->ns_purpose, - &nb->ns_signature, &nb->subspace)) + &nb->ns_purpose, &nb->ns_signature, + &nb->subspace)) { GNUNET_break_op (0); return GNUNET_NO; diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 9eb84ac4b..7ce3004eb 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c @@ -46,14 +46,11 @@ * @return characterization of result */ static enum GNUNET_BLOCK_EvaluationResult -block_plugin_template_evaluate (void *cls, - enum GNUNET_BLOCK_Type type, +block_plugin_template_evaluate (void *cls, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * query, struct GNUNET_CONTAINER_BloomFilter **bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - const void *reply_block, + int32_t bf_mutator, const void *xquery, + size_t xquery_size, const void *reply_block, size_t reply_block_size) { return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; @@ -72,10 +69,9 @@ block_plugin_template_evaluate (void *cls, * (or if extracting a key from a block of this type does not work) */ static int -block_plugin_template_get_key (void *cls, - enum GNUNET_BLOCK_Type type, - const void *block, - size_t block_size, GNUNET_HashCode * key) +block_plugin_template_get_key (void *cls, enum GNUNET_BLOCK_Type type, + const void *block, size_t block_size, + GNUNET_HashCode * key) { return GNUNET_SYSERR; } diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c index b5c03eea9..6fa535afe 100644 --- a/src/block/plugin_block_test.c +++ b/src/block/plugin_block_test.c @@ -53,14 +53,12 @@ * @return characterization of result */ static enum GNUNET_BLOCK_EvaluationResult -block_plugin_test_evaluate (void *cls, - enum GNUNET_BLOCK_Type type, +block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * query, struct GNUNET_CONTAINER_BloomFilter **bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - const void *reply_block, size_t reply_block_size) + int32_t bf_mutator, const void *xquery, + size_t xquery_size, const void *reply_block, + size_t reply_block_size) { GNUNET_HashCode chash; GNUNET_HashCode mhash; @@ -100,10 +98,9 @@ block_plugin_test_evaluate (void *cls, * (or if extracting a key from a block of this type does not work) */ static int -block_plugin_test_get_key (void *cls, - enum GNUNET_BLOCK_Type type, - const void *block, - size_t block_size, GNUNET_HashCode * key) +block_plugin_test_get_key (void *cls, enum GNUNET_BLOCK_Type type, + const void *block, size_t block_size, + GNUNET_HashCode * key) { /* always fails since there is no fixed relationship between * keys and values for test values */ diff --git a/src/block/test_block.c b/src/block/test_block.c index 4bfd63ceb..f7a3422e0 100644 --- a/src/block/test_block.c +++ b/src/block/test_block.c @@ -37,25 +37,21 @@ test_fs (struct GNUNET_BLOCK_Context *ctx) memset (block, 1, sizeof (block)); if (GNUNET_OK != - GNUNET_BLOCK_get_key (ctx, - GNUNET_BLOCK_TYPE_FS_DBLOCK, - block, sizeof (block), &key)) + GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block, + sizeof (block), &key)) return 1; if (GNUNET_BLOCK_EVALUATION_OK_LAST != - GNUNET_BLOCK_evaluate (ctx, - GNUNET_BLOCK_TYPE_FS_DBLOCK, - &key, NULL, 0, NULL, 0, block, sizeof (block))) + GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0, + NULL, 0, block, sizeof (block))) return 2; if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != - GNUNET_BLOCK_evaluate (ctx, - GNUNET_BLOCK_TYPE_FS_DBLOCK, - &key, NULL, 0, NULL, 0, NULL, 0)) + GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0, + NULL, 0, NULL, 0)) return 4; GNUNET_log_skip (1, GNUNET_NO); if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != - GNUNET_BLOCK_evaluate (ctx, - GNUNET_BLOCK_TYPE_FS_DBLOCK, - &key, NULL, 0, "bogus", 5, NULL, 0)) + GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0, + "bogus", 5, NULL, 0)) return 8; GNUNET_log_skip (0, GNUNET_YES); return 0; diff --git a/src/chat/chat.c b/src/chat/chat.c index 1e90a6369..74dde678c 100644 --- a/src/chat/chat.c +++ b/src/chat/chat.c @@ -194,10 +194,10 @@ transmit_acknowledge_request (void *cls, size_t size, void *buf) receipt->author = src->received_msg->sender; receipt->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT); receipt->purpose.size = - htonl (msg_size - - sizeof (struct GNUNET_MessageHeader) - + htonl (msg_size - sizeof (struct GNUNET_MessageHeader) - sizeof (uint32_t) - sizeof (struct GNUNET_CRYPTO_RsaSignature)); - msg_len = ntohs (src->received_msg->header.size) - + msg_len = + ntohs (src->received_msg->header.size) - sizeof (struct ReceiveNotificationMessage); GNUNET_CRYPTO_hash (&src->received_msg[1], msg_len, &receipt->content); GNUNET_assert (GNUNET_OK == @@ -269,9 +269,9 @@ process_result (struct GNUNET_CHAT_Room *room, if (GNUNET_NO == room->is_joined) { GNUNET_CRYPTO_rsa_key_get_public (room->my_private_key, &pkey); - if (0 == memcmp (&join_msg->public_key, - &pkey, - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) + if (0 == + memcmp (&join_msg->public_key, &pkey, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) { room->join_callback (room->join_callback_cls); room->is_joined = GNUNET_YES; @@ -285,8 +285,8 @@ process_result (struct GNUNET_CHAT_Room *room, } } else - room->member_list_callback (room->member_list_callback_cls, - meta, &join_msg->public_key, + room->member_list_callback (room->member_list_callback_cls, meta, + &join_msg->public_key, ntohl (join_msg->msg_options)); break; case GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION: @@ -299,9 +299,8 @@ process_result (struct GNUNET_CHAT_Room *room, return; } leave_msg = (struct LeaveNotificationMessage *) reply; - room->member_list_callback (room->member_list_callback_cls, - NULL, &leave_msg->user, - GNUNET_CHAT_MSG_OPTION_NONE); + room->member_list_callback (room->member_list_callback_cls, NULL, + &leave_msg->user, GNUNET_CHAT_MSG_OPTION_NONE); GNUNET_CRYPTO_hash (&leave_msg->user, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &id); @@ -346,21 +345,20 @@ process_result (struct GNUNET_CHAT_Room *room, msg_len = size - sizeof (struct ReceiveNotificationMessage); if (0 != (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_PRIVATE)) { - if (-1 == GNUNET_CRYPTO_rsa_decrypt (room->my_private_key, - &received_msg->encrypted_key, - &key, - sizeof (struct - GNUNET_CRYPTO_AesSessionKey))) + if (-1 == + GNUNET_CRYPTO_rsa_decrypt (room->my_private_key, + &received_msg->encrypted_key, &key, + sizeof (struct + GNUNET_CRYPTO_AesSessionKey))) { GNUNET_break (0); return; } - msg_len = GNUNET_CRYPTO_aes_decrypt (&received_msg[1], - msg_len, - &key, - (const struct - GNUNET_CRYPTO_AesInitializationVector - *) INITVALUE, decrypted_msg); + msg_len = + GNUNET_CRYPTO_aes_decrypt (&received_msg[1], msg_len, &key, + (const struct + GNUNET_CRYPTO_AesInitializationVector *) + INITVALUE, decrypted_msg); message_content = decrypted_msg; } else @@ -378,17 +376,15 @@ process_result (struct GNUNET_CHAT_Room *room, { pos = room->members; while ((NULL != pos) && - (0 != memcmp (&pos->id, - &received_msg->sender, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&pos->id, &received_msg->sender, + sizeof (GNUNET_HashCode)))) pos = pos->next; GNUNET_assert (NULL != pos); sender = &received_msg->sender; meta = pos->meta; } - room->message_callback (room->message_callback_cls, - room, - sender, - meta, + room->message_callback (room->message_callback_cls, room, sender, meta, message_content, GNUNET_TIME_absolute_ntoh (received_msg->timestamp), ntohl (received_msg->msg_options)); @@ -406,15 +402,15 @@ process_result (struct GNUNET_CHAT_Room *room, } receipt = (struct ConfirmationReceiptMessage *) reply; if (NULL != room->confirmation_callback) - room->confirmation_callback (room->confirmation_cls, - room, + room->confirmation_callback (room->confirmation_cls, room, ntohl (receipt->sequence_number), - GNUNET_TIME_absolute_ntoh - (receipt->timestamp), &receipt->target); + GNUNET_TIME_absolute_ntoh (receipt-> + timestamp), + &receipt->target); break; default: - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Unknown message type: '%u'\n"), ntohs (reply->type)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unknown message type: '%u'\n"), + ntohs (reply->type)); GNUNET_break_op (0); break; } @@ -448,9 +444,8 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) if (NULL == chat_room->client) return; /* fatal error */ /* continue receiving */ - GNUNET_CLIENT_receive (chat_room->client, - &receive_results, - chat_room, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (chat_room->client, &receive_results, chat_room, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -557,17 +552,15 @@ transmit_join_request (void *cls, size_t size, void *buf) memcpy (room, chat_room->room_name, room_len); meta = &room[room_len]; if (GNUNET_SYSERR == - GNUNET_CONTAINER_meta_data_serialize (chat_room->member_info, - &meta, + GNUNET_CONTAINER_meta_data_serialize (chat_room->member_info, &meta, meta_len, GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not serialize metadata\n")); return 0; } - GNUNET_CLIENT_receive (chat_room->client, - &receive_results, - chat_room, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (chat_room->client, &receive_results, chat_room, + GNUNET_TIME_UNIT_FOREVER_REL); return size_of_join; } @@ -580,15 +573,15 @@ rejoin_room (struct GNUNET_CHAT_Room *chat_room) { size_t size_of_join; - size_of_join = sizeof (struct JoinRequestMessage) + + size_of_join = + sizeof (struct JoinRequestMessage) + GNUNET_CONTAINER_meta_data_get_serialized_size (chat_room->member_info) + strlen (chat_room->room_name); if (NULL == - GNUNET_CLIENT_notify_transmit_ready (chat_room->client, - size_of_join, + GNUNET_CLIENT_notify_transmit_ready (chat_room->client, size_of_join, GNUNET_CONSTANTS_SERVICE_TIMEOUT, - GNUNET_YES, - &transmit_join_request, chat_room)) + GNUNET_YES, &transmit_join_request, + chat_room)) return GNUNET_SYSERR; return GNUNET_OK; } @@ -603,8 +596,8 @@ GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room) struct MemberList *pos; #if DEBUG_CHAT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Leaving the room '%s'\n", chat_room->room_name); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Leaving the room '%s'\n", + chat_room->room_name); #endif GNUNET_CLIENT_disconnect (chat_room->client, GNUNET_NO); GNUNET_free (chat_room->room_name); @@ -650,8 +643,7 @@ GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_CONTAINER_MetaData *member_info, const char *room_name, enum GNUNET_CHAT_MsgOptions msg_options, - GNUNET_CHAT_JoinCallback joinCallback, - void *join_cls, + GNUNET_CHAT_JoinCallback joinCallback, void *join_cls, GNUNET_CHAT_MessageCallback messageCallback, void *message_cls, GNUNET_CHAT_MemberListCallback memberCallback, @@ -778,8 +770,7 @@ transmit_send_request (void *cls, size_t size, void *buf) msg_to_send->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); msg_to_send->purpose.size = - htonl (msg_size - - sizeof (struct GNUNET_MessageHeader) - + htonl (msg_size - sizeof (struct GNUNET_MessageHeader) - sizeof (struct GNUNET_CRYPTO_RsaSignature)); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_rsa_sign (smc->chat_room->my_private_key, @@ -802,8 +793,7 @@ transmit_send_request (void *cls, size_t size, void *buf) * @param sequence_number where to write the sequence id of the message */ void -GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, - const char *message, +GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, const char *message, enum GNUNET_CHAT_MsgOptions options, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver, uint32_t * sequence_number) @@ -824,8 +814,7 @@ GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, smc->receiver = receiver; smc->sequence_number = room->sequence_number; msg_size = strlen (message) + sizeof (struct TransmitRequestMessage); - GNUNET_CLIENT_notify_transmit_ready (room->client, - msg_size, + GNUNET_CLIENT_notify_transmit_ready (room->client, msg_size, GNUNET_CONSTANTS_SERVICE_TIMEOUT, GNUNET_YES, &transmit_send_request, smc); } diff --git a/src/chat/gnunet-chat.c b/src/chat/gnunet-chat.c index 6dba4dda5..c656d1cad 100644 --- a/src/chat/gnunet-chat.c +++ b/src/chat/gnunet-chat.c @@ -107,12 +107,10 @@ join_cb (void *cls) * accept (but user is away), GNUNET_SYSERR to signal denied delivery */ static int -receive_cb (void *cls, - struct GNUNET_CHAT_Room *room, +receive_cb (void *cls, struct GNUNET_CHAT_Room *room, const GNUNET_HashCode * sender, const struct GNUNET_CONTAINER_MetaData *member_info, - const char *message, - struct GNUNET_TIME_Absolute timestamp, + const char *message, struct GNUNET_TIME_Absolute timestamp, enum GNUNET_CHAT_MsgOptions options) { char *nick; @@ -183,8 +181,7 @@ receive_cb (void *cls, * confirmations from anyone for this message */ static int -confirmation_cb (void *cls, - struct GNUNET_CHAT_Room *room, +confirmation_cb (void *cls, struct GNUNET_CHAT_Room *room, uint32_t orig_seq_number, struct GNUNET_TIME_Absolute timestamp, const GNUNET_HashCode * receiver) @@ -208,8 +205,7 @@ confirmation_cb (void *cls, * @return GNUNET_OK */ static int -member_list_cb (void *cls, - const struct GNUNET_CONTAINER_MetaData *member_info, +member_list_cb (void *cls, const struct GNUNET_CONTAINER_MetaData *member_info, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, enum GNUNET_CHAT_MsgOptions options) { @@ -222,8 +218,10 @@ member_list_cb (void *cls, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &id); nick = GNUNET_PSEUDONYM_id_to_name (cfg, &id); - fprintf (stdout, member_info != NULL - ? _("`%s' entered the room\n") : _("`%s' left the room\n"), nick); + fprintf (stdout, + member_info != + NULL ? _("`%s' entered the room\n") : _("`%s' left the room\n"), + nick); GNUNET_free (nick); if (NULL != member_info) { @@ -240,10 +238,9 @@ member_list_cb (void *cls, prev = NULL; pos = users; while ((NULL != pos) && - (0 != memcmp (&pos->pkey, - member_id, - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))) + (0 != + memcmp (&pos->pkey, member_id, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))) { prev = pos; pos = pos->next; @@ -277,15 +274,10 @@ do_join (const char *arg, const void *xtra) free_user_list (); GNUNET_free (room_name); room_name = GNUNET_strdup (arg); - room = GNUNET_CHAT_join_room (cfg, - nickname, - meta, - room_name, - -1, - &join_cb, NULL, - &receive_cb, NULL, - &member_list_cb, NULL, - &confirmation_cb, NULL, &me); + room = + GNUNET_CHAT_join_room (cfg, nickname, meta, room_name, -1, &join_cb, NULL, + &receive_cb, NULL, &member_list_cb, NULL, + &confirmation_cb, NULL, &me); if (NULL == room) { fprintf (stdout, _("Could not change username\n")); @@ -311,21 +303,13 @@ do_nick (const char *msg, const void *xtra) GNUNET_CONTAINER_meta_data_destroy (meta); nickname = GNUNET_strdup (msg); meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (meta, - "", - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METAFORMAT_UTF8, "text/plain", nickname, strlen (nickname) + 1); - room = GNUNET_CHAT_join_room (cfg, - nickname, - meta, - room_name, - -1, - &join_cb, NULL, - &receive_cb, NULL, - &member_list_cb, NULL, - &confirmation_cb, NULL, &me); + room = + GNUNET_CHAT_join_room (cfg, nickname, meta, room_name, -1, &join_cb, NULL, + &receive_cb, NULL, &member_list_cb, NULL, + &confirmation_cb, NULL, &me); if (NULL == room) { fprintf (stdout, _("Could not change username\n")); @@ -411,8 +395,8 @@ do_send_pm (const char *msg, const void *xtra) GNUNET_free (user); return GNUNET_OK; } - GNUNET_CHAT_send_message (room, - msg, GNUNET_CHAT_MSG_PRIVATE, &pos->pkey, &seq); + GNUNET_CHAT_send_message (room, msg, GNUNET_CHAT_MSG_PRIVATE, &pos->pkey, + &seq); GNUNET_free (user); return GNUNET_OK; } @@ -423,8 +407,8 @@ do_send_sig (const char *msg, const void *xtra) { uint32_t seq; - GNUNET_CHAT_send_message (room, - msg, GNUNET_CHAT_MSG_AUTHENTICATED, NULL, &seq); + GNUNET_CHAT_send_message (room, msg, GNUNET_CHAT_MSG_AUTHENTICATED, NULL, + &seq); return GNUNET_OK; } @@ -434,8 +418,8 @@ do_send_ack (const char *msg, const void *xtra) { uint32_t seq; - GNUNET_CHAT_send_message (room, - msg, GNUNET_CHAT_MSG_ACKNOWLEDGED, NULL, &seq); + GNUNET_CHAT_send_message (room, msg, GNUNET_CHAT_MSG_ACKNOWLEDGED, NULL, + &seq); return GNUNET_OK; } @@ -520,8 +504,8 @@ do_help (const char *args, const void *xtra) int i; i = 0; - while ((NULL != args) && - (0 != strlen (args)) && (commands[i].Action != &do_help)) + while ((NULL != args) && (0 != strlen (args)) && + (commands[i].Action != &do_help)) { if (0 == strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1)) { @@ -577,8 +561,9 @@ handle_command (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) goto next; i = 0; while ((NULL != commands[i].command) && - (0 != strncasecmp (commands[i].command, - message, strlen (commands[i].command)))) + (0 != + strncasecmp (commands[i].command, message, + strlen (commands[i].command)))) i++; if (GNUNET_OK != commands[i].Action (&message[strlen (commands[i].command)], NULL)) @@ -606,9 +591,8 @@ out: * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { GNUNET_HashCode me; char *my_name; @@ -624,21 +608,13 @@ run (void *cls, if (NULL == room_name) room_name = GNUNET_strdup ("gnunet"); meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (meta, - "", - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METAFORMAT_UTF8, "text/plain", nickname, strlen (nickname) + 1); - room = GNUNET_CHAT_join_room (cfg, - nickname, - meta, - room_name, - -1, - &join_cb, NULL, - &receive_cb, NULL, - &member_list_cb, NULL, - &confirmation_cb, NULL, &me); + room = + GNUNET_CHAT_join_room (cfg, nickname, meta, room_name, -1, &join_cb, NULL, + &receive_cb, NULL, &member_list_cb, NULL, + &confirmation_cb, NULL, &me); if (NULL == room) { fprintf (stderr, _("Failed to join room `%s'\n"), room_name); @@ -655,8 +631,8 @@ run (void *cls, handle_cmd_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &handle_command, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &do_stop_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task, + NULL); } @@ -688,11 +664,9 @@ main (int argc, char *const *argv) fcntl (0, F_SETFL, flags); #endif return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-chat", - gettext_noop ("Join a chat on GNUnet."), - options, &run, NULL)) ? ret : 1; + GNUNET_PROGRAM_run (argc, argv, "gnunet-chat", + gettext_noop ("Join a chat on GNUnet."), options, + &run, NULL)) ? ret : 1; } /* end of gnunet-chat.c */ diff --git a/src/chat/gnunet-service-chat.c b/src/chat/gnunet-service-chat.c index 7afa18d68..e04d8d099 100644 --- a/src/chat/gnunet-service-chat.c +++ b/src/chat/gnunet-service-chat.c @@ -254,18 +254,15 @@ send_message_noficiation (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_PEER_resolve (cp->pid, &pid); #if DEBUG_CHAT_SERVICE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message notification to `%s'\n", GNUNET_i2s (&pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message notification to `%s'\n", + GNUNET_i2s (&pid)); #endif my_msg = GNUNET_memdup (msg, ntohs (msg->header.size)); - if (NULL == GNUNET_CORE_notify_transmit_ready (core, - GNUNET_NO, - 1, - MAX_TRANSMIT_DELAY, - &pid, - ntohs (msg->header.size), - &transmit_message_notification_to_peer, - my_msg)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (core, GNUNET_NO, 1, MAX_TRANSMIT_DELAY, + &pid, ntohs (msg->header.size), + &transmit_message_notification_to_peer, + my_msg)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to queue a message notification\n")); return GNUNET_YES; @@ -281,8 +278,7 @@ send_message_noficiation (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ static void -handle_transmit_request (void *cls, - struct GNUNET_SERVER_Client *client, +handle_transmit_request (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { static GNUNET_HashCode all_zeros; @@ -316,12 +312,11 @@ handle_transmit_request (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting the message text\n"); #endif GNUNET_CRYPTO_aes_create_session_key (&key); - msg_len = GNUNET_CRYPTO_aes_encrypt (&trmsg[1], - msg_len, - &key, - (const struct - GNUNET_CRYPTO_AesInitializationVector - *) INITVALUE, encrypted_msg); + msg_len = + GNUNET_CRYPTO_aes_encrypt (&trmsg[1], msg_len, &key, + (const struct + GNUNET_CRYPTO_AesInitializationVector *) + INITVALUE, encrypted_msg); if (-1 == msg_len) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -332,8 +327,8 @@ handle_transmit_request (void *cls, } } rnmsg = GNUNET_malloc (sizeof (struct ReceiveNotificationMessage) + msg_len); - rnmsg->header.size = htons (sizeof (struct ReceiveNotificationMessage) + - msg_len); + rnmsg->header.size = + htons (sizeof (struct ReceiveNotificationMessage) + msg_len); rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION); rnmsg->msg_options = trmsg->msg_options; rnmsg->timestamp = trmsg->timestamp; @@ -382,8 +377,8 @@ handle_transmit_request (void *cls, memcpy (&rnmsg[1], encrypted_msg, msg_len); target = client_list_head; while ((NULL != target) && - (0 != memcmp (&target->id, - &trmsg->target, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&target->id, &trmsg->target, sizeof (GNUNET_HashCode)))) target = target->next; if (NULL == target) { @@ -394,11 +389,10 @@ handle_transmit_request (void *cls, GNUNET_free (rnmsg); return; } - if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (&key, - sizeof (struct - GNUNET_CRYPTO_AesSessionKey), - &target->public_key, - &rnmsg->encrypted_key)) + if (GNUNET_SYSERR == + GNUNET_CRYPTO_rsa_encrypt (&key, + sizeof (struct GNUNET_CRYPTO_AesSessionKey), + &target->public_key, &rnmsg->encrypted_key)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not encrypt the session key\n"); @@ -419,17 +413,14 @@ handle_transmit_request (void *cls, #endif while (NULL != pos) { - if ((0 == strcmp (room, pos->room)) && - (NULL != pos->client) && (pos->client != client)) + if ((0 == strcmp (room, pos->room)) && (NULL != pos->client) && + (pos->client != client)) { if (((!is_priv) || - (0 == memcmp (&trmsg->target, - &pos->id, - sizeof (GNUNET_HashCode)))) && - (0 == (ntohl (trmsg->msg_options) & (~pos->msg_options)))) + (0 == memcmp (&trmsg->target, &pos->id, sizeof (GNUNET_HashCode)))) + && (0 == (ntohl (trmsg->msg_options) & (~pos->msg_options)))) { - GNUNET_SERVER_notification_context_unicast (nc, - pos->client, + GNUNET_SERVER_notification_context_unicast (nc, pos->client, &rnmsg->header, GNUNET_NO); } } @@ -442,8 +433,9 @@ handle_transmit_request (void *cls, if (is_anon) { room_len = strlen (room); - p2p_rnmsg = GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + - msg_len + room_len); + p2p_rnmsg = + GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + msg_len + + room_len); p2p_rnmsg->header.size = htons (sizeof (struct P2PReceiveNotificationMessage) + msg_len + room_len); @@ -453,15 +445,14 @@ handle_transmit_request (void *cls, } else { - p2p_rnmsg = GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + - msg_len); + p2p_rnmsg = + GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + msg_len); p2p_rnmsg->header.size = htons (sizeof (struct P2PReceiveNotificationMessage) + msg_len); if (is_priv) { memcpy (&p2p_rnmsg[1], encrypted_msg, msg_len); - memcpy (&p2p_rnmsg->encrypted_key, - &rnmsg->encrypted_key, + memcpy (&p2p_rnmsg->encrypted_key, &rnmsg->encrypted_key, sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); } else @@ -540,19 +531,17 @@ send_join_noficiation (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_PEER_resolve (cp->pid, &pid); #if DEBUG_CHAT_SERVICE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending join notification to `%s'\n", GNUNET_i2s (&pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending join notification to `%s'\n", + GNUNET_i2s (&pid)); #endif - msg_size = sizeof (struct P2PJoinNotificationMessage) + - strlen (entry->room) + entry->meta_len; - if (NULL == GNUNET_CORE_notify_transmit_ready (core, - GNUNET_NO, - 1, - MAX_TRANSMIT_DELAY, - &pid, - msg_size, - &transmit_join_notification_to_peer, - entry)) + msg_size = + sizeof (struct P2PJoinNotificationMessage) + strlen (entry->room) + + entry->meta_len; + if (NULL == + GNUNET_CORE_notify_transmit_ready (core, GNUNET_NO, 1, MAX_TRANSMIT_DELAY, + &pid, msg_size, + &transmit_join_notification_to_peer, + entry)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to queue a join notification\n")); return GNUNET_YES; @@ -568,8 +557,7 @@ send_join_noficiation (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ static void -handle_join_request (void *cls, - struct GNUNET_SERVER_Client *client, +handle_join_request (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct JoinRequestMessage *jrmsg; @@ -644,8 +632,7 @@ handle_join_request (void *cls, if (0 == strcmp (room_name, entry->room)) { if (NULL != entry->client) - GNUNET_SERVER_notification_context_unicast (nc, - entry->client, + GNUNET_SERVER_notification_context_unicast (nc, entry->client, &jnmsg->header, GNUNET_NO); if (entry->client != client) { @@ -659,8 +646,7 @@ handle_join_request (void *cls, entry_jnmsg->msg_options = entry->msg_options; entry_jnmsg->public_key = entry->public_key; memcpy (&entry_jnmsg[1], entry->member_info, entry->meta_len); - GNUNET_SERVER_notification_context_unicast (nc, - client, + GNUNET_SERVER_notification_context_unicast (nc, client, &entry_jnmsg->header, GNUNET_NO); GNUNET_free (entry_jnmsg); @@ -728,20 +714,17 @@ send_confirmation_receipt (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_PEER_resolve (cp->pid, &pid); #if DEBUG_CHAT_SERVICE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending confirmation receipt to `%s'\n", GNUNET_i2s (&pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending confirmation receipt to `%s'\n", + GNUNET_i2s (&pid)); #endif msg_size = sizeof (struct P2PConfirmationReceiptMessage); - my_receipt = GNUNET_memdup (receipt, - sizeof (struct P2PConfirmationReceiptMessage)); - if (NULL == GNUNET_CORE_notify_transmit_ready (core, - GNUNET_YES, - 1, - MAX_TRANSMIT_DELAY, - &pid, - msg_size, - &transmit_confirmation_receipt_to_peer, - my_receipt)) + my_receipt = + GNUNET_memdup (receipt, sizeof (struct P2PConfirmationReceiptMessage)); + if (NULL == + GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 1, + MAX_TRANSMIT_DELAY, &pid, msg_size, + &transmit_confirmation_receipt_to_peer, + my_receipt)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to queue a confirmation receipt\n")); return GNUNET_YES; @@ -758,8 +741,7 @@ send_confirmation_receipt (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ static void -handle_acknowledge_request (void *cls, - struct GNUNET_SERVER_Client *client, +handle_acknowledge_request (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct ConfirmationReceiptMessage *receipt; @@ -772,8 +754,8 @@ handle_acknowledge_request (void *cls, receipt = (const struct ConfirmationReceiptMessage *) message; author = client_list_head; while ((NULL != author) && - (0 != memcmp (&receipt->author, - &author->id, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&receipt->author, &author->id, sizeof (GNUNET_HashCode)))) author = author->next; if (NULL == author) { @@ -785,8 +767,8 @@ handle_acknowledge_request (void *cls, } target = client_list_head; while ((NULL != target) && - (0 != memcmp (&receipt->target, - &target->id, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&receipt->target, &target->id, sizeof (GNUNET_HashCode)))) target = target->next; if (NULL == target) { @@ -831,8 +813,8 @@ handle_acknowledge_request (void *cls, #endif if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT, - &receipt->purpose, - &receipt->signature, &target->public_key)) + &receipt->purpose, &receipt->signature, + &target->public_key)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid signature of the receipt\n"); @@ -909,13 +891,13 @@ send_leave_noficiation (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_PEER_resolve (cp->pid, &pid); #if DEBUG_CHAT_SERVICE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending leave notification to `%s'\n", GNUNET_i2s (&pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending leave notification to `%s'\n", + GNUNET_i2s (&pid)); #endif msg_size = sizeof (struct P2PLeaveNotificationMessage); - public_key = GNUNET_memdup (&entry->public_key, - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); + public_key = + GNUNET_memdup (&entry->public_key, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); if (NULL == GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 1, MAX_TRANSMIT_DELAY, &pid, msg_size, @@ -975,8 +957,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) { if ((0 == strcmp (pos->room, entry->room)) && (NULL != entry->client)) { - GNUNET_SERVER_notification_context_unicast (nc, - entry->client, + GNUNET_SERVER_notification_context_unicast (nc, entry->client, &lnmsg.header, GNUNET_NO); } entry = entry->next; @@ -1093,8 +1074,7 @@ handle_p2p_join_notification (void *cls, { if ((0 == strcmp (room_name, entry->room)) && (NULL != entry->client)) { - GNUNET_SERVER_notification_context_unicast (nc, - entry->client, + GNUNET_SERVER_notification_context_unicast (nc, entry->client, &jnmsg->header, GNUNET_NO); } entry = entry->next; @@ -1173,8 +1153,7 @@ handle_p2p_leave_notification (void *cls, { if (0 == strcmp (pos->room, entry->room) && (NULL != entry->client)) { - GNUNET_SERVER_notification_context_unicast (nc, - entry->client, + GNUNET_SERVER_notification_context_unicast (nc, entry->client, &lnmsg.header, GNUNET_NO); } entry = entry->next; @@ -1230,7 +1209,8 @@ handle_p2p_message_notification (void *cls, return GNUNET_SYSERR; } p2p_rnmsg = (const struct P2PReceiveNotificationMessage *) message; - msg_len = ntohs (p2p_rnmsg->header.size) - + msg_len = + ntohs (p2p_rnmsg->header.size) - sizeof (struct P2PReceiveNotificationMessage); is_anon = (0 != (ntohl (p2p_rnmsg->msg_options) & GNUNET_CHAT_MSG_ANONYMOUS)); @@ -1263,8 +1243,8 @@ handle_p2p_message_notification (void *cls, { sender = client_list_head; while ((NULL != sender) && - (0 != memcmp (&sender->id, - &p2p_rnmsg->sender, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&sender->id, &p2p_rnmsg->sender, sizeof (GNUNET_HashCode)))) sender = sender->next; if (NULL == sender) { @@ -1297,18 +1277,17 @@ handle_p2p_message_notification (void *cls, "Sending message to local room members\n"); #endif rnmsg = GNUNET_malloc (sizeof (struct ReceiveNotificationMessage) + msg_len); - rnmsg->header.size = htons (sizeof (struct ReceiveNotificationMessage) + - msg_len); + rnmsg->header.size = + htons (sizeof (struct ReceiveNotificationMessage) + msg_len); rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION); rnmsg->msg_options = p2p_rnmsg->msg_options; rnmsg->sequence_number = p2p_rnmsg->sequence_number; rnmsg->reserved = htonl (0); rnmsg->timestamp = p2p_rnmsg->timestamp; - is_priv = (0 != memcmp (&all_zeros, - &p2p_rnmsg->target, sizeof (GNUNET_HashCode))); + is_priv = + (0 != memcmp (&all_zeros, &p2p_rnmsg->target, sizeof (GNUNET_HashCode))); if (is_priv) - memcpy (&rnmsg->encrypted_key, - &p2p_rnmsg->encrypted_key, + memcpy (&rnmsg->encrypted_key, &p2p_rnmsg->encrypted_key, sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); rnmsg->sender = p2p_rnmsg->sender; memcpy (&rnmsg[1], text, msg_len); @@ -1318,13 +1297,11 @@ handle_p2p_message_notification (void *cls, if ((0 == strcmp (room_name, pos->room)) && (NULL != pos->client)) { if (((!is_priv) || - (0 == memcmp (&p2p_rnmsg->target, - &pos->id, - sizeof (GNUNET_HashCode)))) && + (0 == + memcmp (&p2p_rnmsg->target, &pos->id, sizeof (GNUNET_HashCode)))) && (0 == (ntohl (p2p_rnmsg->msg_options) & (~pos->msg_options)))) { - GNUNET_SERVER_notification_context_unicast (nc, - pos->client, + GNUNET_SERVER_notification_context_unicast (nc, pos->client, &rnmsg->header, GNUNET_NO); } } @@ -1356,8 +1333,7 @@ handle_p2p_message_notification (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_p2p_sync_request (void *cls, - const struct GNUNET_PeerIdentity *other, +handle_p2p_sync_request (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1373,14 +1349,11 @@ handle_p2p_sync_request (void *cls, entry = client_list_head; while (NULL != entry) { - msg_size = sizeof (struct P2PJoinNotificationMessage) + - strlen (entry->room) + entry->meta_len; - th = GNUNET_CORE_notify_transmit_ready (core, - GNUNET_NO, - 1, - MAX_TRANSMIT_DELAY, - other, - msg_size, + msg_size = + sizeof (struct P2PJoinNotificationMessage) + strlen (entry->room) + + entry->meta_len; + th = GNUNET_CORE_notify_transmit_ready (core, GNUNET_NO, 1, + MAX_TRANSMIT_DELAY, other, msg_size, &transmit_join_notification_to_peer, entry); GNUNET_assert (NULL != th); @@ -1417,8 +1390,8 @@ handle_p2p_confirmation_receipt (void *cls, p2p_crmsg = (const struct P2PConfirmationReceiptMessage *) message; target = client_list_head; while ((NULL != target) && - (0 != memcmp (&target->id, - &p2p_crmsg->target, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&target->id, &p2p_crmsg->target, sizeof (GNUNET_HashCode)))) target = target->next; if (NULL == target) { @@ -1441,8 +1414,8 @@ handle_p2p_confirmation_receipt (void *cls, target->rcpt_sequence_number = ntohl (p2p_crmsg->sequence_number); author = client_list_head; while ((NULL != author) && - (0 != memcmp (&author->id, - &p2p_crmsg->author, sizeof (GNUNET_HashCode)))) + (0 != + memcmp (&author->id, &p2p_crmsg->author, sizeof (GNUNET_HashCode)))) author = author->next; if (NULL == author) { @@ -1488,8 +1461,8 @@ handle_p2p_confirmation_receipt (void *cls, crmsg->content = p2p_crmsg->content; if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT, - &crmsg->purpose, - &crmsg->signature, &target->public_key)) + &crmsg->purpose, &crmsg->signature, + &target->public_key)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid signature of the receipt\n"); @@ -1501,8 +1474,7 @@ handle_p2p_confirmation_receipt (void *cls, "The author of the original message is a local client." " Sending receipt to the client\n"); #endif - GNUNET_SERVER_notification_context_unicast (nc, - author->client, + GNUNET_SERVER_notification_context_unicast (nc, author->client, &crmsg->header, GNUNET_NO); GNUNET_free (crmsg); } @@ -1545,8 +1517,7 @@ transmit_sync_request_to_peer (void *cls, size_t size, void *buf) * @param atsi performance data */ static void -peer_connect_handler (void *cls, - const struct GNUNET_PeerIdentity *peer, +peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct ConnectedPeer *cp; @@ -1554,13 +1525,10 @@ peer_connect_handler (void *cls, if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity))) return; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Peer connected: %s\n", GNUNET_i2s (peer)); - th = GNUNET_CORE_notify_transmit_ready (core, - GNUNET_YES, - 1, - MAX_TRANSMIT_DELAY, - peer, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer connected: %s\n", + GNUNET_i2s (peer)); + th = GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 1, + MAX_TRANSMIT_DELAY, peer, sizeof (struct GNUNET_MessageHeader), &transmit_sync_request_to_peer, NULL); GNUNET_assert (NULL != th); @@ -1574,8 +1542,7 @@ peer_connect_handler (void *cls, cp->pid = GNUNET_PEER_intern (peer); GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (connected_peers, - &peer->hashPubKey, - cp, + &peer->hashPubKey, cp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); } @@ -1619,8 +1586,8 @@ peer_disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity))) return; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Peer disconnected: %s\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer disconnected: %s\n", + GNUNET_i2s (peer)); clean_peer (NULL, (const GNUNET_HashCode *) peer, NULL); } @@ -1677,8 +1644,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param publicKey the public key of this peer */ static void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -1695,8 +1661,7 @@ core_init (void *cls, * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -1738,17 +1703,14 @@ run (void *cls, connected_peers = GNUNET_CONTAINER_multihashmap_create (EXPECTED_NEIGHBOUR_COUNT); GNUNET_SERVER_add_handlers (server, handlers); - core = GNUNET_CORE_connect (cfg, - QUEUE_SIZE, - NULL, - &core_init, - &peer_connect_handler, - &peer_disconnect_handler, - NULL, - NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers); + core = + GNUNET_CORE_connect (cfg, QUEUE_SIZE, NULL, &core_init, + &peer_connect_handler, &peer_disconnect_handler, + NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, + p2p_handlers); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleanup_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, + NULL); } @@ -1763,10 +1725,8 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "chat", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, argv, "chat", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } /* end of gnunet-service-chat.c */ diff --git a/src/chat/test_chat.c b/src/chat/test_chat.c index 0953a895b..7cf8b19cf 100644 --- a/src/chat/test_chat.c +++ b/src/chat/test_chat.c @@ -118,12 +118,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -137,8 +138,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -196,8 +196,7 @@ join_cb (void *cls) static int -member_list_cb (void *cls, - const struct GNUNET_CONTAINER_MetaData *member_info, +member_list_cb (void *cls, const struct GNUNET_CONTAINER_MetaData *member_info, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, enum GNUNET_CHAT_MsgOptions options) { @@ -205,24 +204,19 @@ member_list_cb (void *cls, GNUNET_HashCode sender; #if VERBOSE - printf ("%s - told that %s has %s\n", - want->me, - member_info == NULL ? NULL - : GNUNET_CONTAINER_meta_data_get_by_type (member_info, - EXTRACTOR_METATYPE_TITLE), + printf ("%s - told that %s has %s\n", want->me, + member_info == + NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (member_info, + EXTRACTOR_METATYPE_TITLE), member_info == NULL ? "left" : "joined"); #endif GNUNET_CRYPTO_hash (member_id, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &sender); - if ((0 == memcmp (&sender, want->sender, - sizeof (GNUNET_HashCode))) && - (((member_info == NULL) && - (want->meta == NULL)) || - ((member_info != NULL) && - (want->meta != NULL) && - (GNUNET_CONTAINER_meta_data_test_equal (member_info, - want->meta)))) && + if ((0 == memcmp (&sender, want->sender, sizeof (GNUNET_HashCode))) && + (((member_info == NULL) && (want->meta == NULL)) || + ((member_info != NULL) && (want->meta != NULL) && + (GNUNET_CONTAINER_meta_data_test_equal (member_info, want->meta)))) && (options == want->opt)) { if (NULL != want->next_task) @@ -239,29 +233,24 @@ member_list_cb (void *cls, static int -receive_cb (void *cls, - struct GNUNET_CHAT_Room *room, +receive_cb (void *cls, struct GNUNET_CHAT_Room *room, const GNUNET_HashCode * sender, - const struct GNUNET_CONTAINER_MetaData *meta, - const char *message, + const struct GNUNET_CONTAINER_MetaData *meta, const char *message, struct GNUNET_TIME_Absolute timestamp, enum GNUNET_CHAT_MsgOptions options) { struct Wanted *want = cls; #if VERBOSE - printf ("%s - told that %s said %s\n", - want->me, - meta == NULL ? NULL - : GNUNET_CONTAINER_meta_data_get_by_type (meta, - EXTRACTOR_METATYPE_TITLE), + printf ("%s - told that %s said %s\n", want->me, + meta == NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (meta, + EXTRACTOR_METATYPE_TITLE), message); #endif if ((0 == strcmp (message, want->msg)) && (((sender == NULL) && (want->sender == NULL)) || ((sender != NULL) && (want->sender != NULL) && - (0 == memcmp (sender, want->sender, - sizeof (GNUNET_HashCode))))) && + (0 == memcmp (sender, want->sender, sizeof (GNUNET_HashCode))))) && (GNUNET_CONTAINER_meta_data_test_equal (meta, want->meta)) && (options == want->opt) && /* Not == since the library sets the actual timestamp, so it may be @@ -283,8 +272,7 @@ receive_cb (void *cls, static int -confirmation_cb (void *cls, - struct GNUNET_CHAT_Room *room, +confirmation_cb (void *cls, struct GNUNET_CHAT_Room *room, uint32_t orig_seq_number, struct GNUNET_TIME_Absolute timestamp, const GNUNET_HashCode * receiver) @@ -292,14 +280,12 @@ confirmation_cb (void *cls, struct Wanted *want = cls; #if VERBOSE - printf ("%s - told that %s acknowledged message #%d\n", - want->me, + printf ("%s - told that %s acknowledged message #%d\n", want->me, GNUNET_CONTAINER_meta_data_get_by_type (want->meta, EXTRACTOR_METATYPE_TITLE), orig_seq_number); #endif - if ((0 == memcmp (receiver, want->sender, - sizeof (GNUNET_HashCode))) && + if ((0 == memcmp (receiver, want->sender, sizeof (GNUNET_HashCode))) && (orig_seq_number == want->sequence_number) && (timestamp.abs_value >= want->timestamp.abs_value)) { @@ -390,9 +376,8 @@ send_to_alice (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) alice_wanted.timestamp = GNUNET_TIME_absolute_get (); alice_wanted.next_task = &disconnect_bob; alice_wanted.next_task_cls = NULL; - GNUNET_CHAT_send_message (bob_room, - "Hi Alice!", - GNUNET_CHAT_MSG_OPTION_NONE, NULL, NULL); + GNUNET_CHAT_send_message (bob_room, "Hi Alice!", GNUNET_CHAT_MSG_OPTION_NONE, + NULL, NULL); } @@ -476,11 +461,9 @@ join_bob_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) bob_wanted.next_task_cls = NULL; is_ready = GNUNET_NO; bob_room = - GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, - "test", -1, - &join_cb, &bob_wanted, - &receive_cb, &bob_wanted, - &member_list_cb, &bob_wanted, + GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, "test", + -1, &join_cb, &bob_wanted, &receive_cb, + &bob_wanted, &member_list_cb, &bob_wanted, &confirmation_cb, &bob_wanted, &bob); if (NULL == bob_room) { @@ -502,12 +485,10 @@ join_alice_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) alice_wanted.next_task = &join_bob_task; alice_wanted.next_task_cls = NULL; alice_room = - GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, - "test", -1, - &join_cb, &alice_wanted, - &receive_cb, &alice_wanted, - &member_list_cb, &alice_wanted, - &confirmation_cb, &alice_wanted, &alice); + GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, "test", -1, &join_cb, + &alice_wanted, &receive_cb, &alice_wanted, + &member_list_cb, &alice_wanted, &confirmation_cb, + &alice_wanted, &alice); if (NULL == alice_room) { GNUNET_SCHEDULER_cancel (kill_task); @@ -518,9 +499,8 @@ join_alice_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { if (is_p2p) { @@ -535,18 +515,15 @@ run (void *cls, alice_wanted.me = "Alice"; bob_wanted.me = "Bob"; alice_meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (alice_meta, - "", + GNUNET_CONTAINER_meta_data_insert (alice_meta, "", EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "Alice", strlen ("Alice") + 1); bob_meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (bob_meta, - "", + GNUNET_CONTAINER_meta_data_insert (bob_meta, "", EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", "Bob", strlen ("Bob") + 1); + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + "Bob", strlen ("Bob") + 1); kill_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill, NULL); GNUNET_SCHEDULER_add_now (&join_alice_task, NULL); } @@ -591,8 +568,8 @@ main (int argc, char *argv[]) { is_auth = GNUNET_YES; } - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-chat", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-chat", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_CONTAINER_meta_data_destroy (alice_meta); GNUNET_CONTAINER_meta_data_destroy (bob_meta); diff --git a/src/chat/test_chat_private.c b/src/chat/test_chat_private.c index 507e333c9..acec5bcf0 100644 --- a/src/chat/test_chat_private.c +++ b/src/chat/test_chat_private.c @@ -132,12 +132,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -151,8 +152,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -215,8 +215,7 @@ join_cb (void *cls) static int -member_list_cb (void *cls, - const struct GNUNET_CONTAINER_MetaData *member_info, +member_list_cb (void *cls, const struct GNUNET_CONTAINER_MetaData *member_info, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, enum GNUNET_CHAT_MsgOptions options) { @@ -224,11 +223,10 @@ member_list_cb (void *cls, GNUNET_HashCode sender; #if VERBOSE - printf ("%s - told that %s has %s\n", - want->me, - member_info == NULL ? NULL - : GNUNET_CONTAINER_meta_data_get_by_type (member_info, - EXTRACTOR_METATYPE_TITLE), + printf ("%s - told that %s has %s\n", want->me, + member_info == + NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (member_info, + EXTRACTOR_METATYPE_TITLE), member_info == NULL ? "left" : "joined"); #endif GNUNET_CRYPTO_hash (member_id, @@ -241,12 +239,10 @@ member_list_cb (void *cls, (((member_info == NULL) && (want->meta == NULL)) || ((member_info != NULL) && (((want->meta != NULL) && - GNUNET_CONTAINER_meta_data_test_equal (member_info, - want->meta)) || + GNUNET_CONTAINER_meta_data_test_equal (member_info, want->meta)) || ((want->meta2 != NULL) && - GNUNET_CONTAINER_meta_data_test_equal (member_info, - want->meta2))))) && - (options == want->opt)) + GNUNET_CONTAINER_meta_data_test_equal (member_info, want->meta2))))) + && (options == want->opt)) { /* remember Bob's public key, we need it to send private message */ if (NULL == bob_public_key && @@ -280,30 +276,25 @@ member_list_cb (void *cls, static int -receive_cb (void *cls, - struct GNUNET_CHAT_Room *room, +receive_cb (void *cls, struct GNUNET_CHAT_Room *room, const GNUNET_HashCode * sender, - const struct GNUNET_CONTAINER_MetaData *meta, - const char *message, + const struct GNUNET_CONTAINER_MetaData *meta, const char *message, struct GNUNET_TIME_Absolute timestamp, enum GNUNET_CHAT_MsgOptions options) { struct Wanted *want = cls; #if VERBOSE - printf ("%s - told that %s said '%s'\n", - want->me, - meta == NULL ? NULL - : GNUNET_CONTAINER_meta_data_get_by_type (meta, - EXTRACTOR_METATYPE_TITLE), + printf ("%s - told that %s said '%s'\n", want->me, + meta == NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (meta, + EXTRACTOR_METATYPE_TITLE), message); #endif if ((want->msg != NULL) && (0 == strcmp (message, want->msg)) && (((sender == NULL) && (want->sender == NULL)) || ((sender != NULL) && (want->sender != NULL) && - (0 == memcmp (sender, want->sender, - sizeof (GNUNET_HashCode))))) && + (0 == memcmp (sender, want->sender, sizeof (GNUNET_HashCode))))) && (GNUNET_CONTAINER_meta_data_test_equal (meta, want->meta)) && (options == want->opt) && /* Not == since the library sets the actual timestamp, so it may be @@ -444,12 +435,11 @@ send_from_alice_to_bob (void *cls, carol_wanted.opt = 0; carol_wanted.next_task = NULL; carol_wanted.next_task_cls = NULL; - GNUNET_CHAT_send_message (alice_room, - "Hi Bob!", - GNUNET_CHAT_MSG_PRIVATE, bob_public_key, &seq); - finish_task = GNUNET_SCHEDULER_add_delayed (PM_TIMEOUT, - &wait_until_all_ready, - &disconnect_carol); + GNUNET_CHAT_send_message (alice_room, "Hi Bob!", GNUNET_CHAT_MSG_PRIVATE, + bob_public_key, &seq); + finish_task = + GNUNET_SCHEDULER_add_delayed (PM_TIMEOUT, &wait_until_all_ready, + &disconnect_carol); } @@ -508,10 +498,8 @@ join_carol_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) carol_wanted.next_task_cls = NULL; carol_room = GNUNET_CHAT_join_room (is_p2p ? p3.cfg : p1.cfg, "carol", carol_meta, - "test", -1, - &join_cb, &carol_wanted, - &receive_cb, &carol_wanted, - &member_list_cb, &carol_wanted, + "test", -1, &join_cb, &carol_wanted, &receive_cb, + &carol_wanted, &member_list_cb, &carol_wanted, NULL, NULL, &carol); if (NULL == carol_room) { @@ -543,11 +531,10 @@ join_bob_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) bob_wanted.next_task_cls = NULL; bob_ready = GNUNET_NO; bob_room = - GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, - "test", -1, - &join_cb, &bob_wanted, - &receive_cb, &bob_wanted, - &member_list_cb, &bob_wanted, NULL, NULL, &bob); + GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, "test", + -1, &join_cb, &bob_wanted, &receive_cb, + &bob_wanted, &member_list_cb, &bob_wanted, NULL, + NULL, &bob); if (NULL == bob_room) { GNUNET_SCHEDULER_cancel (kill_task); @@ -568,12 +555,10 @@ join_alice_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) alice_wanted.next_task = &join_bob_task; alice_wanted.next_task_cls = NULL; alice_room = - GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, - "test", -1, - &join_cb, &alice_wanted, - &receive_cb, &alice_wanted, - &member_list_cb, &alice_wanted, - NULL, NULL, &alice); + GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, "test", -1, &join_cb, + &alice_wanted, &receive_cb, &alice_wanted, + &member_list_cb, &alice_wanted, NULL, NULL, + &alice); if (NULL == alice_room) { GNUNET_SCHEDULER_cancel (kill_task); @@ -584,9 +569,8 @@ join_alice_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { if (is_p2p) { @@ -604,24 +588,19 @@ run (void *cls, bob_wanted.me = "Bob"; carol_wanted.me = "Carol"; alice_meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (alice_meta, - "", + GNUNET_CONTAINER_meta_data_insert (alice_meta, "", EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "Alice", strlen ("Alice") + 1); bob_meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (bob_meta, - "", + GNUNET_CONTAINER_meta_data_insert (bob_meta, "", EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", "Bob", strlen ("Bob") + 1); + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + "Bob", strlen ("Bob") + 1); carol_meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (carol_meta, - "", + GNUNET_CONTAINER_meta_data_insert (carol_meta, "", EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "Carol", strlen ("Carol") + 1); kill_task = GNUNET_SCHEDULER_add_delayed (KILL_TIMEOUT, &timeout_kill, NULL); GNUNET_SCHEDULER_add_now (&join_alice_task, NULL); @@ -655,8 +634,8 @@ main (int argc, char *argv[]) { is_p2p = GNUNET_YES; } - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-chat", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-chat", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_CONTAINER_meta_data_destroy (alice_meta); GNUNET_CONTAINER_meta_data_destroy (bob_meta); diff --git a/src/core/core_api.c b/src/core/core_api.c index c6fcc0b47..5ec48d68c 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -404,8 +404,8 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return GNUNET_YES (continue) */ static int -disconnect_and_free_peer_entry (void *cls, - const GNUNET_HashCode * key, void *value) +disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key, + void *value) { static struct GNUNET_BANDWIDTH_Value32NBO zero; struct GNUNET_CORE_Handle *h = cls; @@ -485,8 +485,8 @@ reconnect_later (struct GNUNET_CORE_Handle *h) } h->currently_down = GNUNET_YES; GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); - h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->retry_backoff, - &reconnect_task, h); + h->reconnect_task = + GNUNET_SCHEDULER_add_delayed (h->retry_backoff, &reconnect_task, h); while (NULL != (cm = h->control_pending_head)) { GNUNET_CONTAINER_DLL_remove (h->control_pending_head, @@ -502,8 +502,8 @@ reconnect_later (struct GNUNET_CORE_Handle *h) while (NULL != (pr = h->ready_peer_head)) GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); GNUNET_assert (h->control_pending_head == NULL); - h->retry_backoff = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, - h->retry_backoff); + h->retry_backoff = + GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->retry_backoff); h->retry_backoff = GNUNET_TIME_relative_multiply (h->retry_backoff, 2); } @@ -515,8 +515,8 @@ reconnect_later (struct GNUNET_CORE_Handle *h) * @param h core handle * @param ignore_currently_down transmit message even if not initialized? */ -static void -trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down); +static void trigger_next_request (struct GNUNET_CORE_Handle *h, + int ignore_currently_down); /** @@ -526,8 +526,9 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down); * @param cls the transmit handle of the request that timed out * @param tc context, can be NULL (!) */ -static void -transmission_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void transmission_timeout (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** @@ -702,8 +703,9 @@ transmit_message (void *cls, size_t size, void *buf) sm->peer = pr->peer; sm->cork = htonl ((uint32_t) th->cork); sm->reserved = htonl (0); - ret = th->get_message (th->get_message_cls, - size - sizeof (struct SendMessage), &sm[1]); + ret = + th->get_message (th->get_message_cls, + size - sizeof (struct SendMessage), &sm[1]); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -774,8 +776,8 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down) } if (h->control_pending_head != NULL) msize = - ntohs (((struct GNUNET_MessageHeader *) &h-> - control_pending_head[1])->size); + ntohs (((struct GNUNET_MessageHeader *) &h->control_pending_head[1])-> + size); else if (h->ready_peer_head != NULL) msize = h->ready_peer_head->pending_head->msize + sizeof (struct SendMessage); @@ -787,11 +789,10 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down) #endif return; /* no pending message */ } - h->cth = GNUNET_CLIENT_notify_transmit_ready (h->client, - msize, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_NO, - &transmit_message, h); + h->cth = + GNUNET_CLIENT_notify_transmit_ready (h->client, msize, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_NO, &transmit_message, h); } @@ -857,8 +858,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) } h->retry_backoff = GNUNET_TIME_UNIT_MILLISECONDS; GNUNET_CRYPTO_hash (&m->publicKey, - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &h->me.hashPubKey); if (NULL != (init = h->init)) { @@ -886,8 +886,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) pr->ch = h; GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (h->peers, - &h->me.hashPubKey, - pr, + &h->me.hashPubKey, pr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); if (NULL != h->connects) h->connects (h->cls, &h->me, NULL); @@ -934,8 +933,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) pr->ch = h; GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (h->peers, - &cnm->peer.hashPubKey, - pr, + &cnm->peer.hashPubKey, pr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); if (NULL != h->connects) h->connects (h->cls, &cnm->peer, &cnm->ats); @@ -967,8 +965,8 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) reconnect_later (h); return; } - trigger = ((pr->prev != NULL) || - (pr->next != NULL) || (h->ready_peer_head == pr)); + trigger = ((pr->prev != NULL) || (pr->next != NULL) || + (h->ready_peer_head == pr)); disconnect_and_free_peer_entry (h, &dnm->peer.hashPubKey, pr); if (trigger) trigger_next_request (h, GNUNET_NO); @@ -1015,9 +1013,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) reconnect_later (h); return; } - h->status_events (h->cls, - &psnm->peer, - psnm->bandwidth_in, + h->status_events (h->cls, &psnm->peer, psnm->bandwidth_in, psnm->bandwidth_out, GNUNET_TIME_absolute_ntoh (psnm->timeout), &psnm->ats); break; @@ -1056,7 +1052,8 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) return; } if ((GNUNET_NO == h->inbound_hdr_only) && - (msize != ntohs (em->size) + sizeof (struct NotifyTrafficMessage) + + (msize != + ntohs (em->size) + sizeof (struct NotifyTrafficMessage) + +ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information))) { GNUNET_break (0); @@ -1124,8 +1121,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_i2s (&ntm->peer)); #endif if ((GNUNET_NO == h->outbound_hdr_only) && - (msize != ntohs (em->size) + sizeof (struct NotifyTrafficMessage) - + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information))) + (msize != + ntohs (em->size) + sizeof (struct NotifyTrafficMessage) + + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information))) { GNUNET_break (0); reconnect_later (h); @@ -1221,10 +1219,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_free_non_null (pr->pcic_ptr); pr->pcic_ptr = NULL; if (pcic != NULL) - pcic (pr->pcic_cls, - &pr->peer, - cim->bw_out, - ntohl (cim->reserved_amount), + pcic (pr->pcic_cls, &pr->peer, cim->bw_out, ntohl (cim->reserved_amount), GNUNET_TIME_relative_ntoh (cim->reserve_delay), GNUNET_ntohll (cim->preference)); break; @@ -1232,8 +1227,8 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) reconnect_later (h); return; } - GNUNET_CLIENT_receive (h->client, - &main_notify_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &main_notify_handler, h, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -1261,8 +1256,8 @@ init_done_task (void *cls, int success) reconnect_later (h); return; } - GNUNET_CLIENT_receive (h->client, - &main_notify_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &main_notify_handler, h, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -1321,8 +1316,8 @@ reconnect (struct GNUNET_CORE_Handle *h) ts = (uint16_t *) & init[1]; for (hpos = 0; hpos < h->hcnt; hpos++) ts[hpos] = htons (h->handlers[hpos].type); - GNUNET_CONTAINER_DLL_insert (h->control_pending_head, - h->control_pending_tail, cm); + GNUNET_CONTAINER_DLL_insert (h->control_pending_head, h->control_pending_tail, + cm); trigger_next_request (h, GNUNET_YES); } @@ -1354,8 +1349,7 @@ reconnect (struct GNUNET_CORE_Handle *h) */ struct GNUNET_CORE_Handle * GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - unsigned int queue_size, - void *cls, + unsigned int queue_size, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, @@ -1485,8 +1479,7 @@ run_request_next_transmission (void *cls, * memory); if NULL is returned, "notify" will NOT be called. */ struct GNUNET_CORE_TransmitHandle * -GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, - int cork, +GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, uint32_t priority, struct GNUNET_TIME_Relative maxdelay, const struct GNUNET_PeerIdentity *target, @@ -1562,8 +1555,8 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, /* Order entries by deadline, but SKIP 'HEAD' if * we're in the 'ready_peer_*' DLL */ pos = pr->pending_head; - if ((pr->prev != NULL) || - (pr->next != NULL) || (pr == handle->ready_peer_head)) + if ((pr->prev != NULL) || (pr->next != NULL) || + (pr == handle->ready_peer_head)) { GNUNET_assert (pos != NULL); pos = pos->next; /* skip head */ @@ -1576,17 +1569,16 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, prev = pos; pos = pos->next; } - GNUNET_CONTAINER_DLL_insert_after (pr->pending_head, - pr->pending_tail, prev, th); + GNUNET_CONTAINER_DLL_insert_after (pr->pending_head, pr->pending_tail, prev, + th); pr->queue_size++; /* was the request queue previously empty? */ #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission request added to queue\n"); #endif - if ((pr->pending_head == th) && - (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK) && - (pr->next == NULL) && - (pr->prev == NULL) && (handle->ready_peer_head != pr)) + if ((pr->pending_head == th) && (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK) && + (pr->next == NULL) && (pr->prev == NULL) && + (handle->ready_peer_head != pr)) pr->ntr_task = GNUNET_SCHEDULER_add_now (&run_request_next_transmission, pr); return th; @@ -1760,8 +1752,8 @@ GNUNET_CORE_peer_request_connect_cancel (struct GNUNET_CORE_PeerRequestHandle GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "A CHANGE PREFERENCE request was cancelled!\n"); #endif - GNUNET_CONTAINER_DLL_remove (h->control_pending_head, - h->control_pending_tail, cm); + GNUNET_CONTAINER_DLL_remove (h->control_pending_head, h->control_pending_tail, + cm); GNUNET_free (cm); GNUNET_free (req); } @@ -1834,8 +1826,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, const struct GNUNET_PeerIdentity *peer, struct GNUNET_TIME_Relative timeout, struct GNUNET_BANDWIDTH_Value32NBO bw_out, - int32_t amount, - uint64_t preference, + int32_t amount, uint64_t preference, GNUNET_CORE_PeerConfigurationInfoCallback info, void *info_cls) { diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c index 1bad9a768..0cc28e538 100644 --- a/src/core/core_api_iterate_peers.c +++ b/src/core/core_api_iterate_peers.c @@ -114,10 +114,9 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg) } /* Normal case */ if (request_context->peer_cb != NULL) - request_context->peer_cb (request_context->cb_cls, - &connect_message->peer, &connect_message->ats); - GNUNET_CLIENT_receive (request_context->client, - &receive_info, + request_context->peer_cb (request_context->cb_cls, &connect_message->peer, + &connect_message->ats); + GNUNET_CLIENT_receive (request_context->client, &receive_info, request_context, GNUNET_TIME_UNIT_FOREVER_REL); } @@ -194,16 +193,13 @@ GNUNET_CORE_is_peer_connected (const struct GNUNET_CONFIGURATION_Handle *cfg, request_context->cb_cls = cb_cls; request_context->peer = peer; - request_context->th = GNUNET_CLIENT_notify_transmit_ready (client, - sizeof (struct - GNUNET_MessageHeader) - + - sizeof (struct - GNUNET_PeerIdentity), - GNUNET_TIME_relative_get_forever - (), GNUNET_YES, - &transmit_request, - peer); + request_context->th = + GNUNET_CLIENT_notify_transmit_ready (client, + sizeof (struct GNUNET_MessageHeader) + + + sizeof (struct GNUNET_PeerIdentity), + GNUNET_TIME_relative_get_forever (), + GNUNET_YES, &transmit_request, peer); GNUNET_assert (request_context->th != NULL); GNUNET_CLIENT_receive (client, &receive_info, request_context, GNUNET_TIME_relative_get_forever ()); @@ -238,13 +234,11 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, request_context->peer_cb = peer_cb; request_context->cb_cls = cb_cls; - request_context->th = GNUNET_CLIENT_notify_transmit_ready (client, - sizeof (struct - GNUNET_MessageHeader), - GNUNET_TIME_relative_get_forever - (), GNUNET_YES, - &transmit_request, - NULL); + request_context->th = + GNUNET_CLIENT_notify_transmit_ready (client, + sizeof (struct GNUNET_MessageHeader), + GNUNET_TIME_relative_get_forever (), + GNUNET_YES, &transmit_request, NULL); GNUNET_CLIENT_receive (client, &receive_info, request_context, GNUNET_TIME_relative_get_forever ()); diff --git a/src/core/gnunet-core-list-connections.c b/src/core/gnunet-core-list-connections.c index 284a79f69..fe037f73b 100644 --- a/src/core/gnunet-core-list-connections.c +++ b/src/core/gnunet-core-list-connections.c @@ -135,8 +135,7 @@ connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer, #endif pc = GNUNET_malloc (sizeof (struct PrintContext)); pc->peer = *peer; - GNUNET_TRANSPORT_peer_address_lookup (cfg, peer, - GNUNET_TIME_UNIT_MINUTES, + GNUNET_TRANSPORT_peer_address_lookup (cfg, peer, GNUNET_TIME_UNIT_MINUTES, &process_resolved_address, pc); } #if VERBOSE @@ -157,9 +156,8 @@ connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer, * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; @@ -191,9 +189,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-list-connections", + GNUNET_PROGRAM_run (argc, argv, "gnunet-list-connections", gettext_noop ("Print information about connected peers."), options, &run, NULL)) ? 0 : 1; diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 95e182448..e97e9fe46 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -821,21 +821,17 @@ static unsigned long long bandwidth_target_out_bps; */ static void derive_auth_key (struct GNUNET_CRYPTO_AuthKey *akey, - const struct GNUNET_CRYPTO_AesSessionKey *skey, - uint32_t seed, struct GNUNET_TIME_Absolute creation_time) + const struct GNUNET_CRYPTO_AesSessionKey *skey, uint32_t seed, + struct GNUNET_TIME_Absolute creation_time) { static const char ctx[] = "authentication key"; struct GNUNET_TIME_AbsoluteNBO ctbe; ctbe = GNUNET_TIME_absolute_hton (creation_time); - GNUNET_CRYPTO_hmac_derive_key (akey, - skey, - &seed, - sizeof (seed), - &skey->key, - sizeof (skey->key), - &ctbe, sizeof (ctbe), ctx, sizeof (ctx), NULL); + GNUNET_CRYPTO_hmac_derive_key (akey, skey, &seed, sizeof (seed), &skey->key, + sizeof (skey->key), &ctbe, sizeof (ctbe), ctx, + sizeof (ctx), NULL); } @@ -849,13 +845,10 @@ derive_iv (struct GNUNET_CRYPTO_AesInitializationVector *iv, { static const char ctx[] = "initialization vector"; - GNUNET_CRYPTO_aes_derive_iv (iv, - skey, - &seed, - sizeof (seed), + GNUNET_CRYPTO_aes_derive_iv (iv, skey, &seed, sizeof (seed), &identity->hashPubKey.bits, - sizeof (identity->hashPubKey.bits), - ctx, sizeof (ctx), NULL); + sizeof (identity->hashPubKey.bits), ctx, + sizeof (ctx), NULL); } /** @@ -868,13 +861,9 @@ derive_pong_iv (struct GNUNET_CRYPTO_AesInitializationVector *iv, { static const char ctx[] = "pong initialization vector"; - GNUNET_CRYPTO_aes_derive_iv (iv, - skey, - &seed, - sizeof (seed), + GNUNET_CRYPTO_aes_derive_iv (iv, skey, &seed, sizeof (seed), &identity->hashPubKey.bits, - sizeof (identity->hashPubKey.bits), - &challenge, + sizeof (identity->hashPubKey.bits), &challenge, sizeof (challenge), ctx, sizeof (ctx), NULL); } @@ -926,8 +915,8 @@ update_preference_sum (unsigned long long inc) return; /* done! */ /* overflow! compensate by cutting all values in half! */ preference_sum = 0; - GNUNET_CONTAINER_multihashmap_iterate (neighbours, - &update_preference, &preference_sum); + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &update_preference, + &preference_sum); GNUNET_STATISTICS_set (stats, gettext_noop ("# total peer preference"), preference_sum, GNUNET_NO); } @@ -956,8 +945,8 @@ find_neighbour (const struct GNUNET_PeerIdentity *peer) * client's queue is getting too large? */ static void -send_to_client (struct Client *client, - const struct GNUNET_MessageHeader *msg, int can_drop) +send_to_client (struct Client *client, const struct GNUNET_MessageHeader *msg, + int can_drop) { #if DEBUG_CORE_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -965,8 +954,7 @@ send_to_client (struct Client *client, (unsigned int) ntohs (msg->size), (unsigned int) ntohs (msg->type)); #endif - GNUNET_SERVER_notification_context_unicast (notifier, - client->client_handle, + GNUNET_SERVER_notification_context_unicast (notifier, client->client_handle, msg, can_drop); } @@ -980,8 +968,8 @@ send_to_client (struct Client *client, * @param options mask to use */ static void -send_to_all_clients (const struct GNUNET_MessageHeader *msg, - int can_drop, int options) +send_to_all_clients (const struct GNUNET_MessageHeader *msg, int can_drop, + int options) { struct Client *c; @@ -1019,17 +1007,19 @@ handle_peer_status_change (struct Neighbour *n) if ((!n->is_connected) || (n->status != PEER_STATE_KEY_CONFIRMED)) return; #if DEBUG_CORE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' changed status\n", GNUNET_i2s (&n->peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' changed status\n", + GNUNET_i2s (&n->peer)); #endif - size = sizeof (struct PeerStatusNotifyMessage) + + size = + sizeof (struct PeerStatusNotifyMessage) + n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information); if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); /* recovery strategy: throw away performance data */ GNUNET_array_grow (n->ats, n->ats_count, 0); - size = sizeof (struct PeerStatusNotifyMessage) + + size = + sizeof (struct PeerStatusNotifyMessage) + n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information); } psnm = (struct PeerStatusNotifyMessage *) buf; @@ -1041,16 +1031,14 @@ handle_peer_status_change (struct Neighbour *n) psnm->peer = n->peer; psnm->ats_count = htonl (n->ats_count); ats = &psnm->ats; - memcpy (ats, - n->ats, + memcpy (ats, n->ats, n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); ats[n->ats_count].type = htonl (0); ats[n->ats_count].value = htonl (0); - send_to_all_clients (&psnm->header, - GNUNET_YES, GNUNET_CORE_OPTION_SEND_STATUS_CHANGE); - GNUNET_STATISTICS_update (stats, - gettext_noop ("# peer status changes"), - 1, GNUNET_NO); + send_to_all_clients (&psnm->header, GNUNET_YES, + GNUNET_CORE_OPTION_SEND_STATUS_CHANGE); + GNUNET_STATISTICS_update (stats, gettext_noop ("# peer status changes"), 1, + GNUNET_NO); } @@ -1149,10 +1137,9 @@ compute_type_map_message () hdr = GNUNET_malloc (dlen + sizeof (struct GNUNET_MessageHeader)); hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader)); tmp = (char *) &hdr[1]; - if ((Z_OK != compress2 ((Bytef *) tmp, - &dlen, (const Bytef *) my_type_map, - sizeof (my_type_map), 9)) || - (dlen >= sizeof (my_type_map))) + if ((Z_OK != + compress2 ((Bytef *) tmp, &dlen, (const Bytef *) my_type_map, + sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map))) { dlen = sizeof (my_type_map); memcpy (tmp, my_type_map, sizeof (my_type_map)); @@ -1220,8 +1207,7 @@ broadcast_my_type_map () * Handle CORE_SEND_REQUEST message. */ static void -handle_client_send_request (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct SendMessageRequest *req; @@ -1230,13 +1216,12 @@ handle_client_send_request (void *cls, struct ClientActiveRequest *car; req = (const struct SendMessageRequest *) message; - if (0 == memcmp (&req->peer, - &my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 == + memcmp (&req->peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) n = &self; else n = find_neighbour (&req->peer); - if ((n == NULL) || - (GNUNET_YES != n->is_connected) || + if ((n == NULL) || (GNUNET_YES != n->is_connected) || (n->status != PEER_STATE_KEY_CONFIRMED)) { /* neighbour must have disconnected since request was issued, @@ -1297,8 +1282,8 @@ handle_client_send_request (void *cls, * Notify client about an existing connection to one of our neighbours. */ static int -notify_client_about_neighbour (void *cls, - const GNUNET_HashCode * key, void *value) +notify_client_about_neighbour (void *cls, const GNUNET_HashCode * key, + void *value) { struct Client *c = cls; struct Neighbour *n = value; @@ -1307,14 +1292,16 @@ notify_client_about_neighbour (void *cls, struct GNUNET_TRANSPORT_ATS_Information *ats; struct ConnectNotifyMessage *cnm; - size = sizeof (struct ConnectNotifyMessage) + + size = + sizeof (struct ConnectNotifyMessage) + (n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); /* recovery strategy: throw away performance data */ GNUNET_array_grow (n->ats, n->ats_count, 0); - size = sizeof (struct ConnectNotifyMessage) + + size = + sizeof (struct ConnectNotifyMessage) + (n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); } cnm = (struct ConnectNotifyMessage *) buf; @@ -1322,16 +1309,15 @@ notify_client_about_neighbour (void *cls, cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); cnm->ats_count = htonl (n->ats_count); ats = &cnm->ats; - memcpy (ats, - n->ats, + memcpy (ats, n->ats, sizeof (struct GNUNET_TRANSPORT_ATS_Information) * n->ats_count); ats[n->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); ats[n->ats_count].value = htonl (0); if (n->status == PEER_STATE_KEY_CONFIRMED) { #if DEBUG_CORE_CLIENT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending `%s' message to client.\n", "NOTIFY_CONNECT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n", + "NOTIFY_CONNECT"); #endif cnm->peer = n->peer; send_to_client (c, &cnm->header, GNUNET_NO); @@ -1345,8 +1331,7 @@ notify_client_about_neighbour (void *cls, * Handle CORE_INIT request. */ static void -handle_client_init (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_init (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct InitMessage *im; @@ -1401,19 +1386,18 @@ handle_client_init (void *cls, c->options = ntohl (im->options); #if DEBUG_CORE_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Client %p is interested in %u message types\n", - c, (unsigned int) c->tcnt); + "Client %p is interested in %u message types\n", c, + (unsigned int) c->tcnt); #endif /* send init reply message */ irm.header.size = htons (sizeof (struct InitReplyMessage)); irm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY); irm.reserved = htonl (0); - memcpy (&irm.publicKey, - &my_public_key, + memcpy (&irm.publicKey, &my_public_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); #if DEBUG_CORE_CLIENT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending `%s' message to client.\n", "INIT_REPLY"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n", + "INIT_REPLY"); #endif send_to_client (c, &irm.header, GNUNET_NO); if (0 != (c->options & GNUNET_CORE_OPTION_SEND_CONNECT)) @@ -1435,8 +1419,8 @@ handle_client_init (void *cls, * @return GNUNET_YES (continue iteration) */ static int -destroy_active_client_request (void *cls, - const GNUNET_HashCode * key, void *value) +destroy_active_client_request (void *cls, const GNUNET_HashCode * key, + void *value) { struct ClientActiveRequest *car = value; struct Neighbour *n; @@ -1532,14 +1516,16 @@ queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value) cnm = (struct ConnectNotifyMessage *) buf; if (n->status != PEER_STATE_KEY_CONFIRMED) return GNUNET_OK; - size = sizeof (struct ConnectNotifyMessage) + + size = + sizeof (struct ConnectNotifyMessage) + (n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); /* recovery strategy: throw away performance data */ GNUNET_array_grow (n->ats, n->ats_count, 0); - size = sizeof (struct PeerStatusNotifyMessage) + + size = + sizeof (struct PeerStatusNotifyMessage) + n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information); } cnm = (struct ConnectNotifyMessage *) buf; @@ -1547,14 +1533,13 @@ queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value) cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); cnm->ats_count = htonl (n->ats_count); ats = &cnm->ats; - memcpy (ats, - n->ats, + memcpy (ats, n->ats, n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); ats[n->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); ats[n->ats_count].value = htonl (0); #if DEBUG_CORE_CLIENT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending `%s' message to client.\n", "NOTIFY_CONNECT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n", + "NOTIFY_CONNECT"); #endif cnm->peer = n->peer; GNUNET_SERVER_transmit_context_append_message (tc, &cnm->header); @@ -1570,8 +1555,7 @@ queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value) * @param message iteration request message */ static void -handle_client_iterate_peers (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MessageHeader done_msg; @@ -1603,8 +1587,7 @@ handle_client_iterate_peers (void *cls, * @param message iteration request message */ static void -handle_client_have_peer (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MessageHeader done_msg; @@ -1613,8 +1596,7 @@ handle_client_have_peer (void *cls, tc = GNUNET_SERVER_transmit_context_create (client); peer = (struct GNUNET_PeerIdentity *) &message[1]; - GNUNET_CONTAINER_multihashmap_get_multiple (neighbours, - &peer->hashPubKey, + GNUNET_CONTAINER_multihashmap_get_multiple (neighbours, &peer->hashPubKey, &queue_connect_message, tc); done_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END); @@ -1631,8 +1613,7 @@ handle_client_have_peer (void *cls, * @param message iteration request message */ static void -handle_client_request_info (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct RequestInfoMessage *rcm; @@ -1646,8 +1627,8 @@ handle_client_request_info (void *cls, rdelay = GNUNET_TIME_relative_get_zero (); #if DEBUG_CORE_CLIENT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core service receives `%s' request.\n", "REQUEST_INFO"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service receives `%s' request.\n", + "REQUEST_INFO"); #endif pos = clients; while (pos != NULL) @@ -1676,8 +1657,9 @@ handle_client_request_info (void *cls, GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit, n->bw_out_external_limit).value__) { - n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit, - n->bw_out_external_limit); + n->bw_out = + GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit, + n->bw_out_external_limit); GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window, n->bw_out); GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out); @@ -1690,8 +1672,9 @@ handle_client_request_info (void *cls, } else if (want_reserv > 0) { - rdelay = GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window, - want_reserv); + rdelay = + GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window, + want_reserv); if (rdelay.rel_value == 0) got_reserv = want_reserv; else @@ -1711,9 +1694,8 @@ handle_client_request_info (void *cls, #if DEBUG_CORE_QUOTA GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n", - (int) want_reserv, - GNUNET_i2s (&rcm->peer), - (int) got_reserv, (unsigned long long) rdelay.rel_value); + (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv, + (unsigned long long) rdelay.rel_value); #endif cim.reserved_amount = htonl (got_reserv); cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay); @@ -1737,8 +1719,8 @@ handle_client_request_info (void *cls, cim.peer = rcm->peer; cim.rim_id = rcm->rim_id; #if DEBUG_CORE_CLIENT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending `%s' message to client.\n", "CONFIGURATION_INFO"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n", + "CONFIGURATION_INFO"); #endif send_to_client (pos, &cim.header, GNUNET_NO); GNUNET_SERVER_receive_done (client, GNUNET_OK); @@ -1808,8 +1790,7 @@ free_neighbour (struct Neighbour *n) if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->keep_alive_task); if (n->status == PEER_STATE_KEY_CONFIRMED) - GNUNET_STATISTICS_update (stats, - gettext_noop ("# established sessions"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO); GNUNET_array_grow (n->ats, n->ats_count, 0); GNUNET_free_non_null (n->public_key); @@ -1851,18 +1832,17 @@ do_encrypt (struct Neighbour *n, return GNUNET_NO; } GNUNET_assert (size == - GNUNET_CRYPTO_aes_encrypt (in, - (uint16_t) size, + GNUNET_CRYPTO_aes_encrypt (in, (uint16_t) size, &n->encrypt_key, iv, out)); GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes encrypted"), size, GNUNET_NO); #if DEBUG_CORE > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted %u bytes for `%4s' using key %u, IV %u\n", - (unsigned int) size, - GNUNET_i2s (&n->peer), - (unsigned int) n->encrypt_key.crc32, - GNUNET_CRYPTO_crc32_n (iv, sizeof (iv))); + (unsigned int) size, GNUNET_i2s (&n->peer), + (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (iv, + sizeof + (iv))); #endif return GNUNET_OK; } @@ -1902,38 +1882,36 @@ send_keep_alive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) me->deadline = GNUNET_TIME_relative_to_absolute (MAX_PING_DELAY); me->priority = PING_PRIORITY; me->size = sizeof (struct PingMessage); - GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, - n->encrypted_tail, n->encrypted_tail, me); + GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail, + n->encrypted_tail, me); pm = (struct PingMessage *) &me[1]; pm->header.size = htons (sizeof (struct PingMessage)); pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING); - pm->iv_seed = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, - UINT32_MAX); + pm->iv_seed = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); derive_iv (&iv, &n->encrypt_key, pm->iv_seed, &n->peer); pp.challenge = n->ping_challenge; pp.target = n->peer; #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting `%s' message with challenge %u for `%4s' using key %u, IV %u (salt %u).\n", - "PING", - (unsigned int) n->ping_challenge, - GNUNET_i2s (&n->peer), - (unsigned int) n->encrypt_key.crc32, - GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), pm->iv_seed); + "PING", (unsigned int) n->ping_challenge, GNUNET_i2s (&n->peer), + (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv, + sizeof + (iv)), + pm->iv_seed); #endif - do_encrypt (n, - &iv, - &pp.target, - &pm->target, - sizeof (struct PingMessage) - - ((void *) &pm->target - (void *) pm)); + do_encrypt (n, &iv, &pp.target, &pm->target, + sizeof (struct PingMessage) - ((void *) &pm->target - + (void *) pm)); process_encrypted_neighbour_queue (n); /* reschedule PING job */ left = GNUNET_TIME_absolute_get_remaining (get_neighbour_timeout (n)); - retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2), - MIN_PING_FREQUENCY); - n->keep_alive_task - = GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, n); + retry = + GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2), + MIN_PING_FREQUENCY); + n->keep_alive_task = + GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, n); } @@ -1973,16 +1951,15 @@ consider_free_neighbour (struct Neighbour *n) { if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->dead_clean_task); - n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (left, - &consider_free_task, n); + n->dead_clean_task = + GNUNET_SCHEDULER_add_delayed (left, &consider_free_task, n); return; } /* actually free the neighbour... */ GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (neighbours, &n->peer.hashPubKey, n)); - GNUNET_STATISTICS_set (stats, - gettext_noop ("# neighbour entries allocated"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# neighbour entries allocated"), GNUNET_CONTAINER_multihashmap_size (neighbours), GNUNET_NO); free_neighbour (n); @@ -2029,9 +2006,9 @@ notify_encrypted_transmit_ready (void *cls, size_t size, void *buf) #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copied message of type %u and size %u into transport buffer for `%4s'\n", - (unsigned int) - ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), - (unsigned int) ret, GNUNET_i2s (&n->peer)); + (unsigned int) ntohs (((struct GNUNET_MessageHeader *) &m[1])-> + type), (unsigned int) ret, + GNUNET_i2s (&n->peer)); #endif process_encrypted_neighbour_queue (n); } @@ -2040,9 +2017,8 @@ notify_encrypted_transmit_ready (void *cls, size_t size, void *buf) #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission of message of type %u and size %u failed\n", - (unsigned int) - ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), - (unsigned int) m->size); + (unsigned int) ntohs (((struct GNUNET_MessageHeader *) &m[1])-> + type), (unsigned int) m->size); #endif } GNUNET_free (m); @@ -2094,14 +2070,13 @@ process_encrypted_neighbour_queue (struct Neighbour *n) #if DEBUG_CORE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n", - (unsigned int) m->size, - GNUNET_i2s (&n->peer), - (unsigned long long) - GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value); + (unsigned int) m->size, GNUNET_i2s (&n->peer), + (unsigned long long) GNUNET_TIME_absolute_get_remaining (m-> + deadline). + rel_value); #endif n->th = - GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, - m->size, + GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, m->priority, GNUNET_TIME_absolute_get_remaining (m->deadline), @@ -2153,16 +2128,15 @@ do_decrypt (struct Neighbour *n, GNUNET_break (0); return GNUNET_SYSERR; } - GNUNET_STATISTICS_update (stats, - gettext_noop ("# bytes decrypted"), - size, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes decrypted"), size, + GNUNET_NO); #if DEBUG_CORE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted %u bytes from `%4s' using key %u, IV %u\n", - (unsigned int) size, - GNUNET_i2s (&n->peer), - (unsigned int) n->decrypt_key.crc32, - GNUNET_CRYPTO_crc32_n (iv, sizeof (*iv))); + (unsigned int) size, GNUNET_i2s (&n->peer), + (unsigned int) n->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (iv, + sizeof + (*iv))); #endif return GNUNET_OK; } @@ -2186,8 +2160,8 @@ do_decrypt (struct Neighbour *n, * defer scheduling overall; in that case, retry_time is set. */ static size_t -select_messages (struct Neighbour *n, - size_t size, struct GNUNET_TIME_Relative *retry_time) +select_messages (struct Neighbour *n, size_t size, + struct GNUNET_TIME_Relative *retry_time) { struct MessageEntry *pos; struct MessageEntry *min; @@ -2253,8 +2227,8 @@ select_messages (struct Neighbour *n, { // FIXME: HUH? Check! t = pos->deadline; - avail += GNUNET_BANDWIDTH_value_get_available_until (n->bw_out, - delta); + avail += + GNUNET_BANDWIDTH_value_get_available_until (n->bw_out, delta); } if (avail < pos->size) { @@ -2267,9 +2241,10 @@ select_messages (struct Neighbour *n, /* update slack, considering both its absolute deadline * and relative deadlines caused by other messages * with their respective load */ - slack = GNUNET_TIME_relative_min (slack, - GNUNET_BANDWIDTH_value_get_delay_for - (n->bw_out, avail)); + slack = + GNUNET_TIME_relative_min (slack, + GNUNET_BANDWIDTH_value_get_delay_for + (n->bw_out, avail)); if (pos->deadline.abs_value <= now.abs_value) { /* now or never */ @@ -2278,9 +2253,10 @@ select_messages (struct Neighbour *n, else if (GNUNET_YES == pos->got_slack) { /* should be soon now! */ - slack = GNUNET_TIME_relative_min (slack, - GNUNET_TIME_absolute_get_remaining - (pos->slack_deadline)); + slack = + GNUNET_TIME_relative_min (slack, + GNUNET_TIME_absolute_get_remaining + (pos->slack_deadline)); } else { @@ -2289,9 +2265,10 @@ select_messages (struct Neighbour *n, GNUNET_TIME_absolute_get_difference (now, pos->deadline)); pos->got_slack = GNUNET_YES; - pos->slack_deadline = GNUNET_TIME_absolute_min (pos->deadline, - GNUNET_TIME_relative_to_absolute - (GNUNET_CONSTANTS_MAX_CORK_DELAY)); + pos->slack_deadline = + GNUNET_TIME_absolute_min (pos->deadline, + GNUNET_TIME_relative_to_absolute + (GNUNET_CONSTANTS_MAX_CORK_DELAY)); } } } @@ -2336,8 +2313,8 @@ select_messages (struct Neighbour *n, #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deferring transmission for %llums due to underfull message buffer size (%u/%u)\n", - (unsigned long long) retry_time->rel_value, - (unsigned int) off, (unsigned int) size); + (unsigned long long) retry_time->rel_value, (unsigned int) off, + (unsigned int) size); #endif return 0; } @@ -2371,9 +2348,8 @@ select_messages (struct Neighbour *n, #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Selected %llu/%llu bytes of %u/%u plaintext messages for transmission to `%4s'.\n", - (unsigned long long) off, (unsigned long long) tsize, - queue_size, (unsigned int) MAX_PEER_QUEUE_SIZE, - GNUNET_i2s (&n->peer)); + (unsigned long long) off, (unsigned long long) tsize, queue_size, + (unsigned int) MAX_PEER_QUEUE_SIZE, GNUNET_i2s (&n->peer)); #endif return off; } @@ -2392,9 +2368,7 @@ select_messages (struct Neighbour *n, * @return number of bytes written to buf (can be zero) */ static size_t -batch_message (struct Neighbour *n, - char *buf, - size_t size, +batch_message (struct Neighbour *n, char *buf, size_t size, struct GNUNET_TIME_Absolute *deadline, struct GNUNET_TIME_Relative *retry_time, unsigned int *priority) { @@ -2439,10 +2413,11 @@ batch_message (struct Neighbour *n, GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct NotifyTrafficMessage)) { memcpy (&ntm[1], &pos[1], pos->size); - ntm->header.size = htons (sizeof (struct NotifyTrafficMessage) + - sizeof (struct GNUNET_MessageHeader)); - send_to_all_clients (&ntm->header, - GNUNET_YES, GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND); + ntm->header.size = + htons (sizeof (struct NotifyTrafficMessage) + + sizeof (struct GNUNET_MessageHeader)); + send_to_all_clients (&ntm->header, GNUNET_YES, + GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND); } else { @@ -2450,10 +2425,10 @@ batch_message (struct Neighbour *n, * least the 'hdr' type */ memcpy (&ntm[1], &pos[1], sizeof (struct GNUNET_MessageHeader)); } - ntm->header.size = htons (sizeof (struct NotifyTrafficMessage) + - pos->size); - send_to_all_clients (&ntm->header, - GNUNET_YES, GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); + ntm->header.size = + htons (sizeof (struct NotifyTrafficMessage) + pos->size); + send_to_all_clients (&ntm->header, GNUNET_YES, + GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND); #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting %u bytes with message of type %u and size %u\n", @@ -2461,8 +2436,8 @@ batch_message (struct Neighbour *n, (unsigned int) ntohs (((const struct GNUNET_MessageHeader *) &pos[1])->type), (unsigned int) - ntohs (((const struct GNUNET_MessageHeader *) - &pos[1])->size)); + ntohs (((const struct GNUNET_MessageHeader *) &pos[1])-> + size)); #endif /* copy for encrypted transmission */ memcpy (&buf[ret], &pos[1], pos->size); @@ -2473,8 +2448,9 @@ batch_message (struct Neighbour *n, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding plaintext message of size %u with deadline %llu ms to batch\n", (unsigned int) pos->size, - (unsigned long long) - GNUNET_TIME_absolute_get_remaining (pos->deadline).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_remaining (pos-> + deadline). + rel_value); #endif deadline->abs_value = GNUNET_MIN (deadline->abs_value, pos->deadline.abs_value); @@ -2584,8 +2560,8 @@ set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct Neighbour *n = cls; #if DEBUG_CORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Retrying key transmission to `%4s'\n", GNUNET_i2s (&n->peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Retrying key transmission to `%4s'\n", + GNUNET_i2s (&n->peer)); #endif n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; n->set_key_retry_frequency = @@ -2632,9 +2608,9 @@ process_plaintext_neighbour_queue (struct Neighbour *n) return; case PEER_STATE_KEY_SENT: if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) - n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, - &set_key_retry_task, n); + n->retry_set_key_task = + GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, + &set_key_retry_task, n); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not yet connected to `%4s', deferring processing of plaintext messages.\n", @@ -2643,9 +2619,9 @@ process_plaintext_neighbour_queue (struct Neighbour *n) return; case PEER_STATE_KEY_RECEIVED: if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) - n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, - &set_key_retry_task, n); + n->retry_set_key_task = + GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, + &set_key_retry_task, n); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not yet connected to `%4s', deferring processing of plaintext messages.\n", @@ -2680,10 +2656,10 @@ process_plaintext_neighbour_queue (struct Neighbour *n) deadline = GNUNET_TIME_UNIT_FOREVER_ABS; priority = 0; used = sizeof (struct EncryptedMessage); - used += batch_message (n, - &pbuf[used], - GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE, - &deadline, &retry_time, &priority); + used += + batch_message (n, &pbuf[used], + GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE, &deadline, + &retry_time, &priority); if (used == sizeof (struct EncryptedMessage)) { #if DEBUG_CORE > 1 @@ -2693,8 +2669,8 @@ process_plaintext_neighbour_queue (struct Neighbour *n) #endif /* no messages selected for sending, try again later... */ n->retry_plaintext_task = - GNUNET_SCHEDULER_add_delayed (retry_time, - &retry_plaintext_processing, n); + GNUNET_SCHEDULER_add_delayed (retry_time, &retry_plaintext_processing, + n); return; } #if DEBUG_CORE_QUOTA @@ -2729,10 +2705,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) GNUNET_TIME_absolute_get_remaining (deadline).rel_value); #endif GNUNET_assert (GNUNET_OK == - do_encrypt (n, - &iv, - &ph->sequence_number, - &em->sequence_number, + do_encrypt (n, &iv, &ph->sequence_number, &em->sequence_number, used - ENCRYPTED_HEADER_SIZE)); derive_auth_key (&auth_key, &n->encrypt_key, ph->iv_seed, n->encrypt_key_created); @@ -2747,8 +2720,8 @@ process_plaintext_neighbour_queue (struct Neighbour *n) GNUNET_h2s (&em->hmac)); #endif /* append to transmission list */ - GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, - n->encrypted_tail, n->encrypted_tail, me); + GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail, + n->encrypted_tail, me); process_encrypted_neighbour_queue (n); schedule_peer_messages (n); } @@ -2761,9 +2734,9 @@ process_plaintext_neighbour_queue (struct Neighbour *n) * @param cls neighbour for the quota update * @param tc context */ -static void -neighbour_quota_update (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void neighbour_quota_update (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** @@ -2775,9 +2748,9 @@ static void schedule_quota_update (struct Neighbour *n) { GNUNET_assert (n->quota_update_task == GNUNET_SCHEDULER_NO_TASK); - n->quota_update_task - = GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY, - &neighbour_quota_update, n); + n->quota_update_task = + GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY, + &neighbour_quota_update, n); } @@ -2808,12 +2781,11 @@ create_neighbour (const struct GNUNET_PeerIdentity *pid) n->bw_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; n->bw_out_internal_limit = GNUNET_BANDWIDTH_value_init (UINT32_MAX); n->bw_out_external_limit = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; - n->ping_challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, - UINT32_MAX); + n->ping_challenge = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (neighbours, - &n->peer.hashPubKey, - n, + &n->peer.hashPubKey, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); GNUNET_STATISTICS_set (stats, gettext_noop ("# neighbour entries allocated"), GNUNET_CONTAINER_multihashmap_size (neighbours), @@ -2832,8 +2804,7 @@ create_neighbour (const struct GNUNET_PeerIdentity *pid) * @param message the "struct SendMessage" */ static void -handle_client_send (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_send (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct SendMessage *sm; @@ -2852,8 +2823,7 @@ handle_client_send (void *cls, sizeof (struct SendMessage) + sizeof (struct GNUNET_MessageHeader)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "msize is %u, should be at least %u (in %s:%d)\n", - msize, + "msize is %u, should be at least %u (in %s:%d)\n", msize, sizeof (struct SendMessage) + sizeof (struct GNUNET_MessageHeader), __FILE__, __LINE__); GNUNET_break (0); @@ -2867,17 +2837,14 @@ handle_client_send (void *cls, memcmp (&sm->peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) { /* loopback */ - GNUNET_SERVER_mst_receive (mst, - &self, - (const char *) &sm[1], - msize, GNUNET_YES, GNUNET_NO); + GNUNET_SERVER_mst_receive (mst, &self, (const char *) &sm[1], msize, + GNUNET_YES, GNUNET_NO); if (client != NULL) GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } n = find_neighbour (&sm->peer); - if ((n == NULL) || - (GNUNET_YES != n->is_connected) || + if ((n == NULL) || (GNUNET_YES != n->is_connected) || (n->status != PEER_STATE_KEY_CONFIRMED)) { /* attempt to send message to peer that is not connected anymore @@ -2932,8 +2899,7 @@ handle_client_send (void *cls, #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queue full (%u/%u), discarding new request (%u bytes of type %u)\n", - queue_size, - (unsigned int) MAX_PEER_QUEUE_SIZE, + queue_size, (unsigned int) MAX_PEER_QUEUE_SIZE, (unsigned int) msize, (unsigned int) ntohs (message->type)); #endif GNUNET_STATISTICS_update (stats, @@ -3004,15 +2970,14 @@ handle_client_send (void *cls, * @param message the "struct ConnectMessage" */ static void -handle_client_request_connect (void *cls, - struct GNUNET_SERVER_Client *client, +handle_client_request_connect (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct ConnectMessage *cm = (const struct ConnectMessage *) message; struct Neighbour *n; - if (0 == memcmp (&cm->peer, - &my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 == + memcmp (&cm->peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) { /* In this case a client has asked us to connect to ourselves, not really an error! */ GNUNET_SERVER_receive_done (client, GNUNET_OK); @@ -3025,8 +2990,8 @@ handle_client_request_connect (void *cls, "REQUEST_CONNECT", GNUNET_i2s (&cm->peer)); #endif GNUNET_STATISTICS_update (stats, - gettext_noop ("# connection requests received"), - 1, GNUNET_NO); + gettext_noop ("# connection requests received"), 1, + GNUNET_NO); GNUNET_SERVER_receive_done (client, GNUNET_OK); n = find_neighbour (&cm->peer); if ((n == NULL) || (GNUNET_YES != n->is_connected)) @@ -3054,8 +3019,7 @@ handle_client_request_connect (void *cls, * @param err_msg NULL if successful, otherwise contains error message */ static void -process_hello_retry_send_key (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_hello_retry_send_key (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { @@ -3071,8 +3035,7 @@ process_hello_retry_send_key (void *cls, if (peer == NULL) { #if DEBUG_CORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Entered `%s' and `%s' is NULL!\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered `%s' and `%s' is NULL!\n", "process_hello_retry_send_key", "peer"); #endif n->pitr = NULL; @@ -3101,16 +3064,15 @@ process_hello_retry_send_key (void *cls, ("# Delayed connecting due to lack of public key"), 1, GNUNET_NO); if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) - n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, - &set_key_retry_task, n); + n->retry_set_key_task = + GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, + &set_key_retry_task, n); } return; } #if DEBUG_CORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Entered `%s' for peer `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered `%s' for peer `%4s'\n", "process_hello_retry_send_key", GNUNET_i2s (peer)); #endif if (n->public_key != NULL) @@ -3196,11 +3158,11 @@ send_key (struct Neighbour *n) GNUNET_i2s (&n->peer)); #endif GNUNET_assert (n->pitr == NULL); - n->pitr = GNUNET_PEERINFO_iterate (peerinfo, - &n->peer, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 20), - &process_hello_retry_send_key, n); + n->pitr = + GNUNET_PEERINFO_iterate (peerinfo, &n->peer, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 20), + &process_hello_retry_send_key, n); return; } pos = n->encrypted_head; @@ -3212,8 +3174,8 @@ send_key (struct Neighbour *n) { #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s' message for `%4s' queued already\n", - "SET_KEY", GNUNET_i2s (&n->peer)); + "`%s' message for `%4s' queued already\n", "SET_KEY", + GNUNET_i2s (&n->peer)); #endif goto trigger_processing; } @@ -3257,13 +3219,15 @@ send_key (struct Neighbour *n) me->is_setkey = GNUNET_YES; me->got_slack = GNUNET_YES; /* do not defer this one! */ me->sender_status = n->status; - GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, - n->encrypted_tail, n->encrypted_tail, me); + GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail, + n->encrypted_tail, me); sm = (struct SetKeyMessage *) &me[1]; sm->header.size = htons (sizeof (struct SetKeyMessage)); sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SET_KEY); - sm->sender_status = htonl ((int32_t) ((n->status == PEER_STATE_DOWN) ? - PEER_STATE_KEY_SENT : n->status)); + sm->sender_status = + htonl ((int32_t) + ((n->status == + PEER_STATE_DOWN) ? PEER_STATE_KEY_SENT : n->status)); sm->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + @@ -3291,18 +3255,13 @@ send_key (struct Neighbour *n) #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting `%s' and `%s' messages with challenge %u for `%4s' using key %u, IV %u (salt %u).\n", - "SET_KEY", "PING", - (unsigned int) n->ping_challenge, - GNUNET_i2s (&n->peer), - (unsigned int) n->encrypt_key.crc32, + "SET_KEY", "PING", (unsigned int) n->ping_challenge, + GNUNET_i2s (&n->peer), (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), pm->iv_seed); #endif - do_encrypt (n, - &iv, - &pp.target, - &pm->target, - sizeof (struct PingMessage) - - ((void *) &pm->target - (void *) pm)); + do_encrypt (n, &iv, &pp.target, &pm->target, + sizeof (struct PingMessage) - ((void *) &pm->target - + (void *) pm)); GNUNET_STATISTICS_update (stats, gettext_noop ("# SET_KEY and PING messages created"), 1, @@ -3310,18 +3269,18 @@ send_key (struct Neighbour *n) #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %llu ms left for `%s' transmission.\n", - (unsigned long long) - GNUNET_TIME_absolute_get_remaining (me->deadline).rel_value, - "SET_KEY"); + (unsigned long long) GNUNET_TIME_absolute_get_remaining (me-> + deadline). + rel_value, "SET_KEY"); #endif trigger_processing: /* trigger queue processing */ process_encrypted_neighbour_queue (n); if ((n->status != PEER_STATE_KEY_CONFIRMED) && (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task)) - n->retry_set_key_task - = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, - &set_key_retry_task, n); + n->retry_set_key_task = + GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency, + &set_key_retry_task, n); } @@ -3334,11 +3293,9 @@ trigger_processing: * @param ats performance data * @param ats_count number of entries in ats (excluding 0-termination) */ -static void -handle_set_key (struct Neighbour *n, - const struct SetKeyMessage *m, - const struct GNUNET_TRANSPORT_ATS_Information *ats, - uint32_t ats_count); +static void handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m, + const struct GNUNET_TRANSPORT_ATS_Information *ats, + uint32_t ats_count); @@ -3450,8 +3407,7 @@ update_neighbour_performance (struct Neighbour *n, * @param ats_count number of entries in ats (excluding 0-termination) */ static void -handle_ping (struct Neighbour *n, - const struct PingMessage *m, +handle_ping (struct Neighbour *n, const struct PingMessage *m, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -3463,32 +3419,28 @@ handle_ping (struct Neighbour *n, #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core service receives `%s' request from `%4s'.\n", - "PING", GNUNET_i2s (&n->peer)); + "Core service receives `%s' request from `%4s'.\n", "PING", + GNUNET_i2s (&n->peer)); #endif derive_iv (&iv, &n->decrypt_key, m->iv_seed, &my_identity); if (GNUNET_OK != - do_decrypt (n, - &iv, - &m->target, - &t.target, - sizeof (struct PingMessage) - - ((void *) &m->target - (void *) m))) + do_decrypt (n, &iv, &m->target, &t.target, + sizeof (struct PingMessage) - ((void *) &m->target - + (void *) m))) return; #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted `%s' to `%4s' with challenge %u decrypted using key %u, IV %u (salt %u)\n", - "PING", - GNUNET_i2s (&t.target), - (unsigned int) t.challenge, - (unsigned int) n->decrypt_key.crc32, - GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), m->iv_seed); + "PING", GNUNET_i2s (&t.target), (unsigned int) t.challenge, + (unsigned int) n->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv, + sizeof + (iv)), + m->iv_seed); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# PING messages decrypted"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# PING messages decrypted"), 1, GNUNET_NO); - if (0 != memcmp (&t.target, - &my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (&t.target, &my_identity, sizeof (struct GNUNET_PeerIdentity))) { char sender[9]; char peer[9]; @@ -3505,8 +3457,8 @@ handle_ping (struct Neighbour *n, update_neighbour_performance (n, ats, ats_count); me = GNUNET_malloc (sizeof (struct MessageEntry) + sizeof (struct PongMessage)); - GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, - n->encrypted_tail, n->encrypted_tail, me); + GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail, + n->encrypted_tail, me); me->deadline = GNUNET_TIME_relative_to_absolute (MAX_PONG_DELAY); me->priority = PONG_PRIORITY; me->size = sizeof (struct PongMessage); @@ -3519,22 +3471,19 @@ handle_ping (struct Neighbour *n, tp->iv_seed = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); derive_pong_iv (&iv, &n->encrypt_key, tp->iv_seed, t.challenge, &n->peer); - do_encrypt (n, - &iv, - &tx.challenge, - &tp->challenge, - sizeof (struct PongMessage) - - ((void *) &tp->challenge - (void *) tp)); - GNUNET_STATISTICS_update (stats, - gettext_noop ("# PONG messages created"), - 1, GNUNET_NO); + do_encrypt (n, &iv, &tx.challenge, &tp->challenge, + sizeof (struct PongMessage) - ((void *) &tp->challenge - + (void *) tp)); + GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages created"), 1, + GNUNET_NO); #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypting `%s' with challenge %u using key %u, IV %u (salt %u)\n", - "PONG", - (unsigned int) t.challenge, - (unsigned int) n->encrypt_key.crc32, - GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), tp->iv_seed); + "PONG", (unsigned int) t.challenge, + (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv, + sizeof + (iv)), + tp->iv_seed); #endif /* trigger queue processing */ process_encrypted_neighbour_queue (n); @@ -3550,8 +3499,7 @@ handle_ping (struct Neighbour *n, * @param ats_count number of entries in ats (excluding 0-termination) */ static void -handle_pong (struct Neighbour *n, - const struct PongMessage *m, +handle_pong (struct Neighbour *n, const struct PongMessage *m, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -3564,47 +3512,41 @@ handle_pong (struct Neighbour *n, #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core service receives `%s' response from `%4s'.\n", - "PONG", GNUNET_i2s (&n->peer)); + "Core service receives `%s' response from `%4s'.\n", "PONG", + GNUNET_i2s (&n->peer)); #endif /* mark as garbage, just to be sure */ memset (&t, 255, sizeof (t)); derive_pong_iv (&iv, &n->decrypt_key, m->iv_seed, n->ping_challenge, &my_identity); if (GNUNET_OK != - do_decrypt (n, - &iv, - &m->challenge, - &t.challenge, - sizeof (struct PongMessage) - - ((void *) &m->challenge - (void *) m))) + do_decrypt (n, &iv, &m->challenge, &t.challenge, + sizeof (struct PongMessage) - ((void *) &m->challenge - + (void *) m))) { GNUNET_break_op (0); return; } - GNUNET_STATISTICS_update (stats, - gettext_noop ("# PONG messages decrypted"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages decrypted"), 1, GNUNET_NO); #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted `%s' from `%4s' with challenge %u using key %u, IV %u (salt %u)\n", - "PONG", - GNUNET_i2s (&t.target), - (unsigned int) t.challenge, - (unsigned int) n->decrypt_key.crc32, - GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), m->iv_seed); + "PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge, + (unsigned int) n->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv, + sizeof + (iv)), + m->iv_seed); #endif - if ((0 != memcmp (&t.target, - &n->peer, - sizeof (struct GNUNET_PeerIdentity))) || - (n->ping_challenge != t.challenge)) + if ((0 != memcmp (&t.target, &n->peer, sizeof (struct GNUNET_PeerIdentity))) + || (n->ping_challenge != t.challenge)) { /* PONG malformed */ #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received malformed `%s' wanted sender `%4s' with challenge %u\n", - "PONG", - GNUNET_i2s (&n->peer), (unsigned int) n->ping_challenge); + "PONG", GNUNET_i2s (&n->peer), + (unsigned int) n->ping_challenge); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received malformed `%s' received from `%4s' with challenge %u\n", "PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge); @@ -3636,16 +3578,17 @@ handle_pong (struct Neighbour *n, if (n->bw_out_external_limit.value__ != t.inbound_bw_limit.value__) { n->bw_out_external_limit = t.inbound_bw_limit; - n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit, - n->bw_out_internal_limit); + n->bw_out = + GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit, + n->bw_out_internal_limit); GNUNET_BANDWIDTH_tracker_update_quota (&n->available_send_window, n->bw_out); GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out); } #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Confirmed key via `%s' message for peer `%4s'\n", - "PONG", GNUNET_i2s (&n->peer)); + "Confirmed key via `%s' message for peer `%4s'\n", "PONG", + GNUNET_i2s (&n->peer)); #endif if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) { @@ -3653,14 +3596,16 @@ handle_pong (struct Neighbour *n, n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; } update_neighbour_performance (n, ats, ats_count); - size = sizeof (struct ConnectNotifyMessage) + + size = + sizeof (struct ConnectNotifyMessage) + (n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) { GNUNET_break (0); /* recovery strategy: throw away performance data */ GNUNET_array_grow (n->ats, n->ats_count, 0); - size = sizeof (struct PeerStatusNotifyMessage) + + size = + sizeof (struct PeerStatusNotifyMessage) + n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information); } cnm = (struct ConnectNotifyMessage *) buf; @@ -3669,21 +3614,19 @@ handle_pong (struct Neighbour *n, cnm->ats_count = htonl (n->ats_count); cnm->peer = n->peer; mats = &cnm->ats; - memcpy (mats, - n->ats, + memcpy (mats, n->ats, n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); mats[n->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); mats[n->ats_count].value = htonl (0); - send_to_all_clients (&cnm->header, - GNUNET_NO, GNUNET_CORE_OPTION_SEND_CONNECT); + send_to_all_clients (&cnm->header, GNUNET_NO, + GNUNET_CORE_OPTION_SEND_CONNECT); process_encrypted_neighbour_queue (n); /* fall-through! */ case PEER_STATE_KEY_CONFIRMED: n->last_activity = GNUNET_TIME_absolute_get (); if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->keep_alive_task); - n->keep_alive_task - = + n->keep_alive_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), &send_keep_alive, n); @@ -3706,8 +3649,7 @@ handle_pong (struct Neighbour *n, * @param ats_count number of entries in ats (excluding 0-termination) */ static void -handle_set_key (struct Neighbour *n, - const struct SetKeyMessage *m, +handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -3720,8 +3662,8 @@ handle_set_key (struct Neighbour *n, #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core service receives `%s' request from `%4s'.\n", - "SET_KEY", GNUNET_i2s (&n->peer)); + "Core service receives `%s' request from `%4s'.\n", "SET_KEY", + GNUNET_i2s (&n->peer)); #endif if (n->public_key == NULL) { @@ -3743,18 +3685,17 @@ handle_set_key (struct Neighbour *n, /* lookup n's public key, then try again */ GNUNET_assert (n->skm == NULL); n->skm = m_cpy; - n->pitr = GNUNET_PEERINFO_iterate (peerinfo, - &n->peer, - GNUNET_TIME_UNIT_MINUTES, - &process_hello_retry_handle_set_key, n); + n->pitr = + GNUNET_PEERINFO_iterate (peerinfo, &n->peer, GNUNET_TIME_UNIT_MINUTES, + &process_hello_retry_handle_set_key, n); GNUNET_STATISTICS_update (stats, gettext_noop ("# SET_KEY messages deferred (need public key)"), 1, GNUNET_NO); return; } - if (0 != memcmp (&m->target, - &my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (&m->target, &my_identity, sizeof (struct GNUNET_PeerIdentity))) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ @@ -3768,8 +3709,8 @@ handle_set_key (struct Neighbour *n, sizeof (struct GNUNET_CRYPTO_RsaEncryptedData) + sizeof (struct GNUNET_PeerIdentity)) || (GNUNET_OK != - GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_SET_KEY, - &m->purpose, &m->signature, n->public_key))) + GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_SET_KEY, &m->purpose, + &m->signature, n->public_key))) { /* invalid signature */ GNUNET_break_op (0); @@ -3789,11 +3730,10 @@ handle_set_key (struct Neighbour *n, #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypting key material.\n"); #endif - if ((GNUNET_CRYPTO_rsa_decrypt (my_private_key, - &m->encrypted_key, - &k, - sizeof (struct GNUNET_CRYPTO_AesSessionKey)) - != sizeof (struct GNUNET_CRYPTO_AesSessionKey)) || + if ((GNUNET_CRYPTO_rsa_decrypt + (my_private_key, &m->encrypted_key, &k, + sizeof (struct GNUNET_CRYPTO_AesSessionKey)) != + sizeof (struct GNUNET_CRYPTO_AesSessionKey)) || (GNUNET_OK != GNUNET_CRYPTO_aes_check_session_key (&k))) { /* failed to decrypt !? */ @@ -3801,8 +3741,8 @@ handle_set_key (struct Neighbour *n, return; } GNUNET_STATISTICS_update (stats, - gettext_noop ("# SET_KEY messages decrypted"), - 1, GNUNET_NO); + gettext_noop ("# SET_KEY messages decrypted"), 1, + GNUNET_NO); n->decrypt_key = k; if (n->decrypt_key_created.abs_value != t.abs_value) { @@ -3879,10 +3819,11 @@ handle_set_key (struct Neighbour *n, * @param msize number of bytes in buf to transmit */ static void -send_p2p_message_to_client (struct Neighbour *sender, - struct Client *client, const void *m, size_t msize) +send_p2p_message_to_client (struct Neighbour *sender, struct Client *client, + const void *m, size_t msize) { - size_t size = msize + sizeof (struct NotifyTrafficMessage) + + size_t size = + msize + sizeof (struct NotifyTrafficMessage) + (sender->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); char buf[size]; struct NotifyTrafficMessage *ntm; @@ -3894,15 +3835,16 @@ send_p2p_message_to_client (struct Neighbour *sender, GNUNET_break (0); /* recovery strategy: throw performance data away... */ GNUNET_array_grow (sender->ats, sender->ats_count, 0); - size = msize + sizeof (struct NotifyTrafficMessage) + + size = + msize + sizeof (struct NotifyTrafficMessage) + (sender->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information); } #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service passes message from `%4s' of type %u to client.\n", GNUNET_i2s (&sender->peer), - (unsigned int) - ntohs (((const struct GNUNET_MessageHeader *) m)->type)); + (unsigned int) ntohs (((const struct GNUNET_MessageHeader *) m)-> + type)); #endif ntm = (struct NotifyTrafficMessage *) buf; ntm->header.size = htons (size); @@ -3910,8 +3852,7 @@ send_p2p_message_to_client (struct Neighbour *sender, ntm->ats_count = htonl (sender->ats_count); ntm->peer = sender->peer; ats = &ntm->ats; - memcpy (ats, - sender->ats, + memcpy (ats, sender->ats, sizeof (struct GNUNET_TRANSPORT_ATS_Information) * sender->ats_count); ats[sender->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); ats[sender->ats_count].value = htonl (0); @@ -3945,8 +3886,7 @@ deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m) "Received encapsulated message of type %u and size %u from `%4s'\n", (unsigned int) type, ntohs (m->size), GNUNET_i2s (&sender->peer)); #endif - GNUNET_snprintf (buf, - sizeof (buf), + GNUNET_snprintf (buf, sizeof (buf), gettext_noop ("# bytes of messages of type %u received"), (unsigned int) type); GNUNET_STATISTICS_update (stats, buf, msize, GNUNET_NO); @@ -4010,8 +3950,7 @@ deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m) * @param ats_count number of entries in ats (excluding 0-termination) */ static void -handle_encrypted_message (struct Neighbour *n, - const struct EncryptedMessage *m, +handle_encrypted_message (struct Neighbour *n, const struct EncryptedMessage *m, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -4030,10 +3969,10 @@ handle_encrypted_message (struct Neighbour *n, "ENCRYPTED_MESSAGE", GNUNET_i2s (&n->peer)); #endif /* validate hash */ - derive_auth_key (&auth_key, - &n->decrypt_key, m->iv_seed, n->decrypt_key_created); - GNUNET_CRYPTO_hmac (&auth_key, - &m->sequence_number, size - ENCRYPTED_HEADER_SIZE, &ph); + derive_auth_key (&auth_key, &n->decrypt_key, m->iv_seed, + n->decrypt_key_created); + GNUNET_CRYPTO_hmac (&auth_key, &m->sequence_number, + size - ENCRYPTED_HEADER_SIZE, &ph); #if DEBUG_HANDSHAKE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Re-Authenticated %u bytes of ciphertext (`%u'): `%s'\n", @@ -4052,10 +3991,8 @@ handle_encrypted_message (struct Neighbour *n, derive_iv (&iv, &n->decrypt_key, m->iv_seed, &my_identity); /* decrypt */ if (GNUNET_OK != - do_decrypt (n, - &iv, - &m->sequence_number, - &buf[ENCRYPTED_HEADER_SIZE], size - ENCRYPTED_HEADER_SIZE)) + do_decrypt (n, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE], + size - ENCRYPTED_HEADER_SIZE)) return; pt = (struct EncryptedMessage *) buf; @@ -4116,8 +4053,7 @@ handle_encrypted_message (struct Neighbour *n, MAX_MESSAGE_AGE.rel_value) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _ - ("Message received far too old (%llu ms). Content ignored.\n"), + _("Message received far too old (%llu ms). Content ignored.\n"), GNUNET_TIME_absolute_get_duration (t).rel_value); GNUNET_STATISTICS_update (stats, gettext_noop @@ -4136,8 +4072,9 @@ handle_encrypted_message (struct Neighbour *n, GNUNET_i2s (&n->peer)); #endif n->bw_out_external_limit = pt->inbound_bw_limit; - n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit, - n->bw_out_internal_limit); + n->bw_out = + GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit, + n->bw_out_internal_limit); GNUNET_BANDWIDTH_tracker_update_quota (&n->available_send_window, n->bw_out); GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out); @@ -4145,8 +4082,7 @@ handle_encrypted_message (struct Neighbour *n, n->last_activity = GNUNET_TIME_absolute_get (); if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->keep_alive_task); - n->keep_alive_task - = + n->keep_alive_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), &send_keep_alive, n); @@ -4155,13 +4091,10 @@ handle_encrypted_message (struct Neighbour *n, size - sizeof (struct EncryptedMessage), GNUNET_NO); handle_peer_status_change (n); update_neighbour_performance (n, ats, ats_count); - if (GNUNET_OK != GNUNET_SERVER_mst_receive (mst, - n, - &buf[sizeof - (struct EncryptedMessage)], - size - - sizeof (struct EncryptedMessage), - GNUNET_YES, GNUNET_NO)) + if (GNUNET_OK != + GNUNET_SERVER_mst_receive (mst, n, &buf[sizeof (struct EncryptedMessage)], + size - sizeof (struct EncryptedMessage), + GNUNET_YES, GNUNET_NO)) GNUNET_break_op (0); } @@ -4176,8 +4109,7 @@ handle_encrypted_message (struct Neighbour *n, * @param ats_count number of entries in ats (excluding 0-termination) */ static void -handle_transport_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -4218,14 +4150,13 @@ handle_transport_receive (void *cls, GNUNET_break_op (0); return; } - GNUNET_STATISTICS_update (stats, - gettext_noop ("# session keys received"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# session keys received"), 1, GNUNET_NO); handle_set_key (n, (const struct SetKeyMessage *) message, ats, ats_count); break; case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: - if (size < sizeof (struct EncryptedMessage) + - sizeof (struct GNUNET_MessageHeader)) + if (size < + sizeof (struct EncryptedMessage) + sizeof (struct GNUNET_MessageHeader)) { GNUNET_break_op (0); return; @@ -4240,9 +4171,8 @@ handle_transport_receive (void *cls, send_key (n); return; } - handle_encrypted_message (n, - (const struct EncryptedMessage *) message, - ats, ats_count); + handle_encrypted_message (n, (const struct EncryptedMessage *) message, ats, + ats_count); break; case GNUNET_MESSAGE_TYPE_CORE_PING: if (size != sizeof (struct PingMessage)) @@ -4303,15 +4233,13 @@ handle_transport_receive (void *cls, changed = GNUNET_YES; if (!up) { - GNUNET_STATISTICS_update (stats, - gettext_noop ("# established sessions"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), 1, GNUNET_NO); n->time_established = now; } if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->keep_alive_task); - n->keep_alive_task - = + n->keep_alive_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), &send_keep_alive, n); @@ -4411,10 +4339,8 @@ neighbour_quota_update (void *cls, #if DEBUG_CORE_QUOTA GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Current quota for `%4s' is %u/%llu b/s in (old: %u b/s) / %u out (%u internal)\n", - GNUNET_i2s (&n->peer), - (unsigned int) ntohl (q_in.value__), - bandwidth_target_out_bps, - (unsigned int) ntohl (n->bw_in.value__), + GNUNET_i2s (&n->peer), (unsigned int) ntohl (q_in.value__), + bandwidth_target_out_bps, (unsigned int) ntohl (n->bw_in.value__), (unsigned int) ntohl (n->bw_out.value__), (unsigned int) ntohl (n->bw_out_internal_limit.value__)); #endif @@ -4470,17 +4396,17 @@ handle_transport_notify_connect (void *cls, n = create_neighbour (peer); } GNUNET_STATISTICS_update (stats, - gettext_noop ("# peers connected (transport)"), - 1, GNUNET_NO); + gettext_noop ("# peers connected (transport)"), 1, + GNUNET_NO); n->is_connected = GNUNET_YES; update_neighbour_performance (n, ats, ats_count); - GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, - n->bw_out, MAX_WINDOW_TIME_S); - GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window, - n->bw_in, MAX_WINDOW_TIME_S); + GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, n->bw_out, + MAX_WINDOW_TIME_S); + GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window, n->bw_in, + MAX_WINDOW_TIME_S); #if DEBUG_CORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received connection from `%4s'.\n", GNUNET_i2s (&n->peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n", + GNUNET_i2s (&n->peer)); #endif GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out); send_key (n); @@ -4552,8 +4478,8 @@ handle_transport_notify_disconnect (void *cls, } GNUNET_STATISTICS_update (stats, - gettext_noop ("# peers connected (transport)"), - -1, GNUNET_NO); + gettext_noop ("# peers connected (transport)"), -1, + GNUNET_NO); if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->dead_clean_task); left = @@ -4595,8 +4521,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (transport != NULL); GNUNET_TRANSPORT_disconnect (transport); transport = NULL; - GNUNET_CONTAINER_multihashmap_iterate (neighbours, - &free_neighbour_helper, NULL); + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper, + NULL); GNUNET_CONTAINER_multihashmap_destroy (neighbours); neighbours = NULL; GNUNET_STATISTICS_set (stats, gettext_noop ("# neighbour entries allocated"), @@ -4624,8 +4550,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -4656,19 +4581,14 @@ run (void *cls, cfg = c; /* parse configuration */ if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "CORE", - "TOTAL_QUOTA_IN", + GNUNET_CONFIGURATION_get_value_number (c, "CORE", "TOTAL_QUOTA_IN", &bandwidth_target_in_bps)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "CORE", - "TOTAL_QUOTA_OUT", + GNUNET_CONFIGURATION_get_value_number (c, "CORE", "TOTAL_QUOTA_OUT", &bandwidth_target_out_bps)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", - "HOSTKEY", &keyfile))) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -4697,29 +4617,27 @@ run (void *cls, } neighbours = GNUNET_CONTAINER_multihashmap_create (128); GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); - GNUNET_CRYPTO_hash (&my_public_key, - sizeof (my_public_key), &my_identity.hashPubKey); + GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), + &my_identity.hashPubKey); self.public_key = &my_public_key; self.peer = my_identity; self.last_activity = GNUNET_TIME_UNIT_FOREVER_ABS; self.status = PEER_STATE_KEY_CONFIRMED; self.is_connected = GNUNET_YES; /* setup notification */ - notifier = GNUNET_SERVER_notification_context_create (server, - MAX_NOTIFY_QUEUE); + notifier = + GNUNET_SERVER_notification_context_create (server, MAX_NOTIFY_QUEUE); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); /* setup transport connection */ - transport = GNUNET_TRANSPORT_connect (cfg, - &my_identity, - NULL, - &handle_transport_receive, - &handle_transport_notify_connect, - &handle_transport_notify_disconnect); + transport = + GNUNET_TRANSPORT_connect (cfg, &my_identity, NULL, + &handle_transport_receive, + &handle_transport_notify_connect, + &handle_transport_notify_disconnect); GNUNET_assert (NULL != transport); stats = GNUNET_STATISTICS_create ("core", cfg); - GNUNET_STATISTICS_set (stats, - gettext_noop ("# discarded CORE_SEND requests"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded CORE_SEND requests"), 0, GNUNET_NO); GNUNET_STATISTICS_set (stats, gettext_noop @@ -4727,12 +4645,12 @@ run (void *cls, GNUNET_NO); mst = GNUNET_SERVER_mst_create (&deliver_message, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleaning_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, + NULL); /* process client requests */ GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Core service of `%4s' ready.\n"), GNUNET_i2s (&my_identity)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"), + GNUNET_i2s (&my_identity)); } @@ -4748,10 +4666,8 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "core", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, argv, "core", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } /* end of gnunet-service-core.c */ diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index b5e93a8a2..28805a372 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -150,8 +150,7 @@ transmit_ready (void *cls, size_t size, void *buf) static void -connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct PeerContext *pc = cls; @@ -173,15 +172,13 @@ connect_notify (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking core (1) for transmission to peer `%4s'\n", GNUNET_i2s (&p2.id)); - if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_YES, - 0, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - 45), &p2.id, - sizeof (struct - GNUNET_MessageHeader), - &transmit_ready, &p1)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 45), + &p2.id, + sizeof (struct GNUNET_MessageHeader), + &transmit_ready, &p1)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", @@ -199,14 +196,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) return; pc->connect_status = 0; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", + GNUNET_i2s (peer)); } static int -inbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -217,8 +213,7 @@ inbound_notify (void *cls, static int -outbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -231,13 +226,12 @@ outbound_notify (void *cls, static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message from `%4s'.\n", + GNUNET_i2s (peer)); GNUNET_assert (ok == 5); OKPP; GNUNET_SCHEDULER_cancel (err_task); @@ -260,8 +254,9 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) con_task = GNUNET_SCHEDULER_NO_TASK; return; } - con_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &connect_task, NULL); + con_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &connect_task, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking core (1) to connect to peer `%4s'\n", GNUNET_i2s (&p2.id)); @@ -269,15 +264,13 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -init_notify (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { struct PeerContext *p = cls; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core connection to `%4s' established\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established\n", GNUNET_i2s (my_identity)); GNUNET_assert (server != NULL); p->id = *my_identity; @@ -287,15 +280,11 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - p2.ch = GNUNET_CORE_connect (p2.cfg, 1, - &p2, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, - &outbound_notify, GNUNET_YES, handlers); + p2.ch = + GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, + GNUNET_YES, &outbound_notify, GNUNET_YES, + handlers); } else { @@ -312,12 +301,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); @@ -327,9 +317,8 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; @@ -353,8 +342,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -377,8 +365,8 @@ check () GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-core-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-core-api", "nohelp", options, &run, &ok); stop_arm (&p1); stop_arm (&p2); return ok; diff --git a/src/core/test_core_api_preferences.c b/src/core/test_core_api_preferences.c index 200ae4176..e5d5deb1b 100644 --- a/src/core/test_core_api_preferences.c +++ b/src/core/test_core_api_preferences.c @@ -151,13 +151,11 @@ transmit_ready (void *cls, size_t size, void *buf) return sizeof (struct GNUNET_MessageHeader); } -static void -preference_cb (void *cls, - const struct - GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - int32_t amount, - struct GNUNET_TIME_Relative res_delay, uint64_t preference); +static void preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, + int32_t amount, + struct GNUNET_TIME_Relative res_delay, + uint64_t preference); static void do_reserve (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) @@ -173,20 +171,17 @@ do_reserve (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting reservatin of 32k from core in 1s!\n"); - irc = GNUNET_CORE_peer_change_preference (p1.ch, - &p2.id, - GNUNET_TIME_UNIT_SECONDS, - GNUNET_BANDWIDTH_VALUE_MAX, - 1000000 /* bandwidth for 1s */ , - 0, &preference_cb, pc); + irc = + GNUNET_CORE_peer_change_preference (p1.ch, &p2.id, + GNUNET_TIME_UNIT_SECONDS, + GNUNET_BANDWIDTH_VALUE_MAX, + 1000000 /* bandwidth for 1s */ , + 0, &preference_cb, pc); } static void -preference_cb (void *cls, - const struct - GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - int32_t amount, +preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer, + struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, int32_t amount, struct GNUNET_TIME_Relative res_delay, uint64_t preference) { struct PeerContext *pc = cls; @@ -212,15 +207,14 @@ preference_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking core (1) for transmission to peer `%4s'\n", GNUNET_i2s (&p2.id)); - if (NULL == (th = GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_YES, - 0, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - 45), &p2.id, - sizeof (struct - GNUNET_MessageHeader), - &transmit_ready, &p1))) + if (NULL == + (th = + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 45), + &p2.id, + sizeof (struct GNUNET_MessageHeader), + &transmit_ready, &p1))) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", @@ -230,8 +224,7 @@ preference_cb (void *cls, static void -connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct PeerContext *pc = cls; @@ -286,14 +279,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) th = NULL; } } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", + GNUNET_i2s (peer)); } static int -inbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -304,8 +296,7 @@ inbound_notify (void *cls, static int -outbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -318,13 +309,12 @@ outbound_notify (void *cls, static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message from `%4s'.\n", + GNUNET_i2s (peer)); GNUNET_assert (ok == 5); OKPP; GNUNET_SCHEDULER_cancel (err_task); @@ -345,8 +335,8 @@ static void ask_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { ask_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &ask_connect_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &ask_connect_task, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking core (1) AGAIN to connect to peer `%4s'\n", GNUNET_i2s (&p2.id)); @@ -355,15 +345,13 @@ ask_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -init_notify (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { struct PeerContext *p = cls; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Core connection to `%4s' established\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established\n", GNUNET_i2s (my_identity)); GNUNET_assert (server != NULL); p->id = *my_identity; @@ -373,14 +361,9 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (p2.cfg, 1, - &p2, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); + GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &outbound_notify, GNUNET_YES, handlers); } else { @@ -432,12 +415,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); @@ -447,22 +431,16 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; setup_peer (&p1, "test_core_quota_asymmetric_recv_limited_peer1.conf"); setup_peer (&p2, "test_core_quota_asymmetric_recv_limited_peer2.conf"); - GNUNET_CORE_connect (p1.cfg, 1, - &p1, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); + GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &outbound_notify, GNUNET_YES, handlers); } static void @@ -473,8 +451,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -497,9 +474,9 @@ check () GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-core-api-preferences", "nohelp", options, - &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-core-api-preferences", "nohelp", options, &run, + &ok); stop_arm (&p1); stop_arm (&p2); return ok; diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 1f82a0058..afe6ad269 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -132,8 +132,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TRANSPORT_disconnect (p2.th); p2.th = NULL; delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; - fprintf (stderr, - "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); + fprintf (stderr, "\nThroughput was %llu kb/s\n", + total_bytes * 1000 / 1024 / delta); GAUGER ("CORE", "Core throughput/s", total_bytes * 1000 / 1024 / delta, "kb/s"); ok = 0; @@ -183,11 +183,8 @@ transmit_ready (void *cls, size_t size, void *buf) { if (p1.ch != NULL) GNUNET_break (NULL != - GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_NO, - 0, - FAST_TIMEOUT, - &p2.id, + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, + FAST_TIMEOUT, &p2.id, get_size (tr_n), &transmit_ready, &p1)); return 0; @@ -229,8 +226,7 @@ transmit_ready (void *cls, size_t size, void *buf) static void -connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct PeerContext *pc = cls; @@ -252,11 +248,8 @@ connect_notify (void *cls, GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); start_time = GNUNET_TIME_absolute_get (); GNUNET_break (NULL != - GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_NO, - 0, - TIMEOUT, - &p2.id, + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, + TIMEOUT, &p2.id, get_size (0), &transmit_ready, &p1)); } @@ -271,14 +264,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) return; pc->connect_status = 0; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", + GNUNET_i2s (peer)); } static int -inbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -291,8 +283,7 @@ inbound_notify (void *cls, static int -outbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -308,8 +299,7 @@ outbound_notify (void *cls, static size_t transmit_ready (void *cls, size_t size, void *buf); static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -340,8 +330,7 @@ process_mtype (void *cls, return GNUNET_SYSERR; } #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got message %u of size %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", ntohl (hdr->num), ntohs (message->size)); #endif n++; @@ -356,11 +345,8 @@ process_mtype (void *cls, { if (n == tr_n) GNUNET_break (NULL != - GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_NO, - 0, - FAST_TIMEOUT, - &p2.id, + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, + FAST_TIMEOUT, &p2.id, get_size (tr_n), &transmit_ready, &p1)); } @@ -376,8 +362,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { static void -init_notify (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -394,14 +379,9 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (p2.cfg, 1, - &p2, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); + GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &outbound_notify, GNUNET_YES, handlers); } else { @@ -444,12 +424,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); @@ -459,9 +440,8 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; @@ -469,14 +449,9 @@ run (void *cls, setup_peer (&p2, "test_core_api_peer2.conf"); err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); - GNUNET_CORE_connect (p1.cfg, 1, - &p1, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); + GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &outbound_notify, GNUNET_YES, handlers); } @@ -488,8 +463,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -512,9 +486,9 @@ check () GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-core-api-reliability", "nohelp", options, - &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-core-api-reliability", "nohelp", options, &run, + &ok); stop_arm (&p1); stop_arm (&p2); return ok; diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c index 09d6edacc..808447fa1 100644 --- a/src/core/test_core_api_send_to_self.c +++ b/src/core/test_core_api_send_to_self.c @@ -79,8 +79,8 @@ cleanup (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tskctx) if (GNUNET_OS_process_wait (arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", GNUNET_OS_process_get_pid (arm_proc)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", + GNUNET_OS_process_get_pid (arm_proc)); GNUNET_OS_process_close (arm_proc); arm_proc = NULL; @@ -143,10 +143,8 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to myself; sending message!\n"); - GNUNET_CORE_notify_transmit_ready (core, - GNUNET_YES, - 0, GNUNET_TIME_UNIT_FOREVER_REL, - peer, + GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 0, + GNUNET_TIME_UNIT_FOREVER_REL, peer, sizeof (struct GNUNET_MessageHeader), send_message, NULL); } @@ -162,9 +160,8 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer, * @param cfg configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const static struct GNUNET_CORE_MessageHandler handlers[] = { {&receive, GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP, 0}, @@ -173,23 +170,21 @@ run (void *cls, core_cfg = GNUNET_CONFIGURATION_create (); - arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_core_api_peer1.conf", NULL); + "-c", "test_core_api_peer1.conf", NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (core_cfg, "test_core_api_peer1.conf")); - core = GNUNET_CORE_connect (core_cfg, - 42, - NULL, - &init, - &connect_cb, - NULL, NULL, NULL, 0, NULL, 0, handlers); + core = + GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL, NULL, + NULL, 0, NULL, 0, handlers); die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply @@ -217,11 +212,10 @@ check () ret = 1; return (GNUNET_OK == - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test_core_api_send_to_self", - gettext_noop ("help text"), - options, &run, NULL)) ? ret : 1; + gettext_noop ("help text"), options, &run, + NULL)) ? ret : 1; } /** diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 36d964796..ca301f51e 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -66,8 +66,7 @@ static int ok; static void -connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { } @@ -80,8 +79,7 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) static int -inbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -90,8 +88,7 @@ inbound_notify (void *cls, static int -outbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -118,8 +115,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -init_notify (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -130,15 +126,11 @@ init_notify (void *cls, if (cls == &p1) { /* connect p2 */ - p2.ch = GNUNET_CORE_connect (p2.cfg, 1, - &p2, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, - &outbound_notify, GNUNET_YES, handlers); + p2.ch = + GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, + GNUNET_YES, &outbound_notify, GNUNET_YES, + handlers); } else { @@ -154,12 +146,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -185,9 +178,8 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; @@ -213,8 +205,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -241,9 +232,8 @@ check () GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-core-api-start-only", "nohelp", options, &run, - &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-core-api-start-only", "nohelp", options, &run, &ok); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test finished\n"); stop_arm (&p1); stop_arm (&p2); diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 5dcc20597..88ba2c0f2 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -173,16 +173,15 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -print_stat (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { if (cls == &p1) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer1 %50s = %12llu\n", name, (unsigned long long) value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer1 %50s = %12llu\n", name, + (unsigned long long) value); if (cls == &p2) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer2 %50s = %12llu\n", name, (unsigned long long) value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer2 %50s = %12llu\n", name, + (unsigned long long) value); return GNUNET_OK; } @@ -225,38 +224,28 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else ok = 0; - GNUNET_STATISTICS_get (p1.stats, - "core", - "# discarded CORE_SEND requests", + GNUNET_STATISTICS_get (p1.stats, "core", "# discarded CORE_SEND requests", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p1); - GNUNET_STATISTICS_get (p1.stats, - "core", + GNUNET_STATISTICS_get (p1.stats, "core", "# discarded CORE_SEND request bytes", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p1); - GNUNET_STATISTICS_get (p1.stats, - "core", + GNUNET_STATISTICS_get (p1.stats, "core", "# discarded lower priority CORE_SEND requests", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, NULL); - GNUNET_STATISTICS_get (p1.stats, - "core", + GNUNET_STATISTICS_get (p1.stats, "core", "# discarded lower priority CORE_SEND request bytes", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p1); - GNUNET_STATISTICS_get (p2.stats, - "core", - "# discarded CORE_SEND requests", + GNUNET_STATISTICS_get (p2.stats, "core", "# discarded CORE_SEND requests", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); - GNUNET_STATISTICS_get (p2.stats, - "core", + GNUNET_STATISTICS_get (p2.stats, "core", "# discarded CORE_SEND request bytes", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); - GNUNET_STATISTICS_get (p2.stats, - "core", + GNUNET_STATISTICS_get (p2.stats, "core", "# discarded lower priority CORE_SEND requests", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); - GNUNET_STATISTICS_get (p2.stats, - "core", + GNUNET_STATISTICS_get (p2.stats, "core", "# discarded lower priority CORE_SEND request bytes", GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); @@ -312,11 +301,8 @@ transmit_ready (void *cls, size_t size, void *buf) { if ((p1.ch != NULL) && (p1.connect_status == 1)) GNUNET_break (NULL != - GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_NO, - 0, - FAST_TIMEOUT, - &p2.id, + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, + FAST_TIMEOUT, &p2.id, MESSAGESIZE, &transmit_ready, &p1)); return 0; @@ -330,8 +316,8 @@ transmit_ready (void *cls, size_t size, void *buf) { #if DEBUG_TRANSMISSION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message %u of size %u at offset %u\n", - tr_n, MESSAGESIZE, ret); + "Sending message %u of size %u at offset %u\n", tr_n, + MESSAGESIZE, ret); #endif hdr.header.size = htons (MESSAGESIZE); hdr.header.type = htons (MTYPE); @@ -346,8 +332,8 @@ transmit_ready (void *cls, size_t size, void *buf) } while (size - ret >= MESSAGESIZE); GNUNET_SCHEDULER_cancel (err_task); - err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &terminate_task_error, NULL); + err_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); total_bytes_sent += ret; return ret; @@ -356,8 +342,7 @@ transmit_ready (void *cls, size_t size, void *buf) static void -connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct PeerContext *pc = cls; @@ -378,22 +363,19 @@ connect_notify (void *cls, #endif if (err_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (err_task); - err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &terminate_task_error, NULL); + err_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); start_time = GNUNET_TIME_absolute_get (); running = GNUNET_YES; measure_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_LENGTH, &measurement_stop, NULL); - GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_NO, - 0, - TIMEOUT, - &p2.id, - MESSAGESIZE, - &transmit_ready, - &p1)); + GNUNET_break (NULL != + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, + TIMEOUT, &p2.id, + MESSAGESIZE, + &transmit_ready, &p1)); } } @@ -407,15 +389,14 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) return; pc->connect_status = 0; #if DEBUG_TRANSMISSION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", + GNUNET_i2s (peer)); #endif } static int -inbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -430,8 +411,7 @@ inbound_notify (void *cls, static int -outbound_notify (void *cls, - const struct GNUNET_PeerIdentity *other, +outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -447,8 +427,7 @@ outbound_notify (void *cls, static size_t transmit_ready (void *cls, size_t size, void *buf); static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -477,8 +456,7 @@ process_mtype (void *cls, return GNUNET_SYSERR; } #if DEBUG_TRANSMISSION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got message %u of size %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", ntohl (hdr->num), ntohs (message->size)); #endif n++; @@ -488,11 +466,8 @@ process_mtype (void *cls, if (running == GNUNET_YES) GNUNET_break (NULL != - GNUNET_CORE_notify_transmit_ready (p1.ch, - GNUNET_NO, - 0, - FAST_TIMEOUT, - &p2.id, + GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0, + FAST_TIMEOUT, &p2.id, MESSAGESIZE, &transmit_ready, &p1)); return GNUNET_OK; @@ -507,8 +482,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { static void -init_notify (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -525,14 +499,9 @@ init_notify (void *cls, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (p2.cfg, 1, - &p2, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); + GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &outbound_notify, GNUNET_YES, handlers); } else { @@ -580,12 +549,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->stats = GNUNET_STATISTICS_create ("core", p->cfg); @@ -597,14 +567,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &terminate_task_error, NULL); + err_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); if (test == SYMMETRIC) { setup_peer (&p1, "test_core_quota_peer1.conf"); @@ -622,31 +591,26 @@ run (void *cls, } GNUNET_assert (test != -1); - GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p1.cfg, - "CORE", - "TOTAL_QUOTA_IN", - ¤t_quota_p1_in)); - GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p2.cfg, - "CORE", - "TOTAL_QUOTA_IN", - ¤t_quota_p2_in)); - GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p1.cfg, - "CORE", - "TOTAL_QUOTA_OUT", - ¤t_quota_p1_out)); - GNUNET_assert (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number (p2.cfg, - "CORE", - "TOTAL_QUOTA_OUT", - ¤t_quota_p2_out)); - - GNUNET_CORE_connect (p1.cfg, 1, - &p1, - &init_notify, - &connect_notify, - &disconnect_notify, - NULL, - &inbound_notify, - GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); + GNUNET_assert (GNUNET_SYSERR != + GNUNET_CONFIGURATION_get_value_number (p1.cfg, "CORE", + "TOTAL_QUOTA_IN", + ¤t_quota_p1_in)); + GNUNET_assert (GNUNET_SYSERR != + GNUNET_CONFIGURATION_get_value_number (p2.cfg, "CORE", + "TOTAL_QUOTA_IN", + ¤t_quota_p2_in)); + GNUNET_assert (GNUNET_SYSERR != + GNUNET_CONFIGURATION_get_value_number (p1.cfg, "CORE", + "TOTAL_QUOTA_OUT", + ¤t_quota_p1_out)); + GNUNET_assert (GNUNET_SYSERR != + GNUNET_CONFIGURATION_get_value_number (p2.cfg, "CORE", + "TOTAL_QUOTA_OUT", + ¤t_quota_p2_out)); + + GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &outbound_notify, GNUNET_YES, handlers); } @@ -658,8 +622,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -684,9 +647,9 @@ check () GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-core-quota-compliance", "nohelp", options, - &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-core-quota-compliance", "nohelp", options, &run, + &ok); stop_arm (&p1); stop_arm (&p2); return ok; diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index a17eb9628..9d12fbc3e 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c @@ -105,8 +105,8 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size) GNUNET_assert (h->utilization >= size); h->utilization -= size; GNUNET_CONTAINER_bloomfilter_remove (h->filter, key); - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# bytes stored"), -size, GNUNET_NO); + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), -size, + GNUNET_NO); } @@ -131,16 +131,16 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_get_value_number (cfg, section, "QUOTA", "a)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "QUOTA", section); + _("No `%s' specified for `%s' in configuration!\n"), "QUOTA", + section); return NULL; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, "DATABASE", &name)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "DATABASE", section); + _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", + section); return NULL; } bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */ @@ -164,8 +164,8 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, ret->env.cls = ret; ret->env.delete_notify = &env_delete_notify; ret->env.quota = quota; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' datacache plugin\n"), name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datacache plugin\n"), + name); GNUNET_asprintf (&libname, "libgnunet_plugin_datacache_%s", name); ret->short_name = name; ret->lib_name = libname; @@ -199,8 +199,8 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) if (h->bloom_name != NULL) { if (0 != UNLINK (h->bloom_name)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", h->bloom_name); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + h->bloom_name); GNUNET_free (h->bloom_name); } GNUNET_STATISTICS_destroy (h->stats, GNUNET_NO); @@ -221,10 +221,8 @@ GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) */ int GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, - const GNUNET_HashCode * key, - size_t size, - const char *data, - enum GNUNET_BLOCK_Type type, + const GNUNET_HashCode * key, size_t size, + const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time) { uint32_t used; @@ -235,8 +233,8 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, GNUNET_break (0); return GNUNET_SYSERR; } - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# bytes stored"), size, GNUNET_NO); + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size, + GNUNET_NO); GNUNET_CONTAINER_bloomfilter_add (h->filter, key); while (h->utilization + used > h->env.quota) GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls)); @@ -258,12 +256,11 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, */ unsigned int GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, - const GNUNET_HashCode * key, - enum GNUNET_BLOCK_Type type, + const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls) { - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# requests received"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1, + GNUNET_NO); if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) { GNUNET_STATISTICS_update (h->stats, diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index 3af76dbb6..a5dc02362 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c @@ -44,10 +44,9 @@ static const char *plugin_name; static int -checkIt (void *cls, - struct GNUNET_TIME_Absolute exp, - const GNUNET_HashCode * key, - size_t size, const char *data, enum GNUNET_BLOCK_Type type) +checkIt (void *cls, struct GNUNET_TIME_Absolute exp, + const GNUNET_HashCode * key, size_t size, const char *data, + enum GNUNET_BLOCK_Type type) { if ((size == sizeof (GNUNET_HashCode)) && (0 == memcmp (data, cls, size))) found++; @@ -56,9 +55,8 @@ checkIt (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DATACACHE_Handle *h; GNUNET_HashCode k; @@ -86,21 +84,17 @@ run (void *cls, if (0 == i % (ITERATIONS / 80)) fprintf (stderr, "."); GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); - ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, - &k, - sizeof (GNUNET_HashCode), - (const char *) &n, - 1 + i % 16, exp)); + ASSERT (GNUNET_OK == + GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode), + (const char *) &n, 1 + i % 16, exp)); k = n; } fprintf (stderr, "\n"); - fprintf (stdout, "Stored %u items in %llums\n", - ITERATIONS, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value); + fprintf (stdout, "Stored %u items in %llums\n", ITERATIONS, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value); GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name); - GAUGER (gstr, - "Time to PUT item in datacache", + GAUGER (gstr, "Time to PUT item in datacache", GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS, "ms/item"); start = GNUNET_TIME_absolute_get (); @@ -117,12 +111,10 @@ run (void *cls, fprintf (stdout, "Found %u/%u items in %llums (%u were deleted during storage processing)\n", found, ITERATIONS, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value, - ITERATIONS - found); + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value, ITERATIONS - found); if (found > 0) - GAUGER (gstr, - "Time to GET item from datacache", + GAUGER (gstr, "Time to GET item from datacache", GNUNET_TIME_absolute_get_duration (start).rel_value / found, "ms/item"); GNUNET_DATACACHE_destroy (h); @@ -170,13 +162,12 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), - "perf_datacache_data_%s.conf", plugin_name); + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "perf_datacache_data_%s.conf", + plugin_name); if (pos != plugin_name) pos[0] = '.'; - GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, - xargv, "perf-datacache", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, + "perf-datacache", "nohelp", options, &run, NULL); if (ok != 0) fprintf (stderr, "Missed some perfcases: %d\n", ok); return ok; diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c index f4530ccef..62787eea6 100644 --- a/src/datacache/plugin_datacache_mysql.c +++ b/src/datacache/plugin_datacache_mysql.c @@ -222,8 +222,8 @@ get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg) #endif GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Trying to use file `%s' for MySQL configuration.\n"), cnffile); - if ((0 != STAT (cnffile, &st)) || - (0 != ACCESS (cnffile, R_OK)) || (!S_ISREG (st.st_mode))) + if ((0 != STAT (cnffile, &st)) || (0 != ACCESS (cnffile, R_OK)) || + (!S_ISREG (st.st_mode))) { if (configured == GNUNET_YES) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -303,9 +303,9 @@ iopen (struct Plugin *ret) mysql_options (ret->dbf, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout); mysql_options (ret->dbf, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout); mysql_dbname = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (ret->env->cfg, - "datacache-mysql", - "DATABASE")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (ret->env->cfg, "datacache-mysql", + "DATABASE")) GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (ret->env->cfg, "datacache-mysql", @@ -314,8 +314,9 @@ iopen (struct Plugin *ret) else mysql_dbname = GNUNET_strdup ("gnunet"); mysql_user = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (ret->env->cfg, - "datacache-mysql", "USER")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (ret->env->cfg, "datacache-mysql", + "USER")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (ret->env->cfg, @@ -323,9 +324,9 @@ iopen (struct Plugin *ret) "USER", &mysql_user)); } mysql_password = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (ret->env->cfg, - "datacache-mysql", - "PASSWORD")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (ret->env->cfg, "datacache-mysql", + "PASSWORD")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (ret->env->cfg, @@ -334,8 +335,9 @@ iopen (struct Plugin *ret) &mysql_password)); } mysql_server = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (ret->env->cfg, - "datacache-mysql", "HOST")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (ret->env->cfg, "datacache-mysql", + "HOST")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (ret->env->cfg, @@ -344,8 +346,9 @@ iopen (struct Plugin *ret) &mysql_server)); } mysql_port = 0; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (ret->env->cfg, - "datacache-mysql", "PORT")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (ret->env->cfg, "datacache-mysql", + "PORT")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (ret->env->cfg, @@ -450,8 +453,8 @@ prepare_statement (struct Plugin *plugin, * @return GNUNET_SYSERR on error, GNUNET_OK on success */ static int -init_params (struct Plugin *plugin, - struct GNUNET_MysqlStatementHandle *s, va_list ap) +init_params (struct Plugin *plugin, struct GNUNET_MysqlStatementHandle *s, + va_list ap) { MYSQL_BIND qbind[MAX_PARAM]; unsigned int pc; @@ -512,8 +515,8 @@ init_params (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_param", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_bind_param", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -521,8 +524,8 @@ init_params (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_execute", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_execute", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -538,8 +541,7 @@ init_params (struct Plugin *plugin, * @param values values returned by MySQL * @return GNUNET_OK to continue iterating, GNUNET_SYSERR to abort */ -typedef int (*GNUNET_MysqlDataProcessor) (void *cls, - unsigned int num_values, +typedef int (*GNUNET_MysqlDataProcessor) (void *cls, unsigned int num_values, MYSQL_BIND * values); @@ -561,12 +563,10 @@ typedef int (*GNUNET_MysqlDataProcessor) (void *cls, */ static int prepared_statement_run_select (struct Plugin *plugin, - struct GNUNET_MysqlStatementHandle - *s, - unsigned int result_size, - MYSQL_BIND * results, - GNUNET_MysqlDataProcessor - processor, void *processor_cls, ...) + struct GNUNET_MysqlStatementHandle *s, + unsigned int result_size, MYSQL_BIND * results, + GNUNET_MysqlDataProcessor processor, + void *processor_cls, ...) { va_list ap; int ret; @@ -596,8 +596,8 @@ prepared_statement_run_select (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_result", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_bind_result", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -612,8 +612,8 @@ prepared_statement_run_select (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_fetch", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_fetch", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -676,17 +676,17 @@ static int itable (struct Plugin *plugin) { #define MRUNS(a) (GNUNET_OK != run_statement (plugin, a) ) - if (MRUNS ("CREATE TEMPORARY TABLE gn080dstore (" - " type INT(11) UNSIGNED NOT NULL DEFAULT 0," - " puttime BIGINT UNSIGNED NOT NULL DEFAULT 0," - " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," - " hash BINARY(64) NOT NULL DEFAULT ''," - " vhash BINARY(64) NOT NULL DEFAULT ''," - " value BLOB NOT NULL DEFAULT ''," - " INDEX hashidx (hash(64),type,expire)," - " INDEX allidx (hash(64),vhash(64),type)," - " INDEX expireidx (puttime)" ") ENGINE=InnoDB") || - MRUNS ("SET AUTOCOMMIT = 1")) + if (MRUNS + ("CREATE TEMPORARY TABLE gn080dstore (" + " type INT(11) UNSIGNED NOT NULL DEFAULT 0," + " puttime BIGINT UNSIGNED NOT NULL DEFAULT 0," + " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," + " hash BINARY(64) NOT NULL DEFAULT ''," + " vhash BINARY(64) NOT NULL DEFAULT ''," + " value BLOB NOT NULL DEFAULT ''," + " INDEX hashidx (hash(64),type,expire)," + " INDEX allidx (hash(64),vhash(64),type)," " INDEX expireidx (puttime)" + ") ENGINE=InnoDB") || MRUNS ("SET AUTOCOMMIT = 1")) return GNUNET_SYSERR; #undef MRUNS #define PINIT(a,b) (NULL == (a = prepared_statement_create(plugin, b))) @@ -714,11 +714,8 @@ itable (struct Plugin *plugin) * @return 0 on error, number of bytes used otherwise */ static size_t -mysql_plugin_put (void *cls, - const GNUNET_HashCode * key, - size_t size, - const char *data, - enum GNUNET_BLOCK_Type type, +mysql_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, + const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time) { struct Plugin *plugin = cls; @@ -745,23 +742,12 @@ mysql_plugin_put (void *cls, v_now = (unsigned long long) now.abs_value; v_discard_time = (unsigned long long) discard_time.abs_value; if (GNUNET_OK == - prepared_statement_run (plugin, - plugin->update_value, - NULL, - MYSQL_TYPE_LONGLONG, - &v_now, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &v_discard_time, - GNUNET_YES, - MYSQL_TYPE_BLOB, - key, - sizeof (GNUNET_HashCode), - &k_length, - MYSQL_TYPE_BLOB, - &vhash, - sizeof (GNUNET_HashCode), - &h_length, + prepared_statement_run (plugin, plugin->update_value, NULL, + MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, + MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode), + &k_length, MYSQL_TYPE_BLOB, &vhash, + sizeof (GNUNET_HashCode), &h_length, MYSQL_TYPE_LONG, &v_type, GNUNET_YES, -1)) return GNUNET_OK; @@ -770,29 +756,16 @@ mysql_plugin_put (void *cls, k_length = sizeof (GNUNET_HashCode); v_length = size; if (GNUNET_OK != - (ret = prepared_statement_run (plugin, - plugin->insert_value, - NULL, - MYSQL_TYPE_LONG, - &type, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &v_now, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &v_discard_time, - GNUNET_YES, - MYSQL_TYPE_BLOB, - key, - sizeof (GNUNET_HashCode), - &k_length, - MYSQL_TYPE_BLOB, - &vhash, - sizeof (GNUNET_HashCode), - &h_length, - MYSQL_TYPE_BLOB, - data, - (unsigned long) size, &v_length, -1))) + (ret = + prepared_statement_run (plugin, plugin->insert_value, NULL, + MYSQL_TYPE_LONG, &type, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &v_discard_time, GNUNET_YES, + MYSQL_TYPE_BLOB, key, sizeof (GNUNET_HashCode), + &k_length, MYSQL_TYPE_BLOB, &vhash, + sizeof (GNUNET_HashCode), &h_length, + MYSQL_TYPE_BLOB, data, (unsigned long) size, + &v_length, -1))) { if (ret == GNUNET_SYSERR) itable (plugin); @@ -821,10 +794,9 @@ return_ok (void *cls, unsigned int num_values, MYSQL_BIND * values) * @return the number of results found */ static unsigned int -mysql_plugin_get (void *cls, - const GNUNET_HashCode * key, - enum GNUNET_BLOCK_Type type, - GNUNET_DATACACHE_Iterator iter, void *iter_cls) +mysql_plugin_get (void *cls, const GNUNET_HashCode * key, + enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, + void *iter_cls) { struct Plugin *plugin = cls; MYSQL_BIND rbind[3]; @@ -852,22 +824,13 @@ mysql_plugin_get (void *cls, v_type = type; v_now = (unsigned long long) now.abs_value; if ((GNUNET_OK != - (ret = prepared_statement_run_select (plugin, - plugin->count_value, - 1, - rbind, - return_ok, - NULL, - MYSQL_TYPE_BLOB, - key, - sizeof - (GNUNET_HashCode), - &h_length, - MYSQL_TYPE_LONG, - &v_type, GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &v_now, GNUNET_YES, - -1))) || (-1 == total)) + (ret = + prepared_statement_run_select (plugin, plugin->count_value, 1, rbind, + return_ok, NULL, MYSQL_TYPE_BLOB, key, + sizeof (GNUNET_HashCode), &h_length, + MYSQL_TYPE_LONG, &v_type, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, + -1))) || (-1 == total)) { if (ret == GNUNET_SYSERR) itable (plugin); @@ -890,25 +853,13 @@ mysql_plugin_get (void *cls, rbind[1].buffer = &v_expire; off = (off + 1) % total; if (GNUNET_OK != - (ret = prepared_statement_run_select (plugin, - plugin->select_value, - 2, - rbind, - return_ok, - NULL, - MYSQL_TYPE_BLOB, - key, - sizeof - (GNUNET_HashCode), - &h_length, - MYSQL_TYPE_LONG, - &v_type, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &v_now, - GNUNET_YES, - MYSQL_TYPE_LONG, - &off, GNUNET_YES, -1))) + (ret = + prepared_statement_run_select (plugin, plugin->select_value, 2, rbind, + return_ok, NULL, MYSQL_TYPE_BLOB, key, + sizeof (GNUNET_HashCode), &h_length, + MYSQL_TYPE_LONG, &v_type, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &v_now, GNUNET_YES, + MYSQL_TYPE_LONG, &off, GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) itable (plugin); @@ -965,32 +916,20 @@ mysql_plugin_del (void *cls) rbind[3].length = &v_length; rbind[3].buffer = buffer; if ((GNUNET_OK != - (ret = prepared_statement_run_select (plugin, - plugin->select_old_value, - 4, - rbind, - return_ok, - NULL, - -1))) || + (ret = + prepared_statement_run_select (plugin, plugin->select_old_value, 4, + rbind, return_ok, NULL, -1))) || (GNUNET_OK != - (ret = prepared_statement_run (plugin, - plugin->delete_value, - NULL, - MYSQL_TYPE_BLOB, - &v_key, - sizeof (GNUNET_HashCode), - &k_length, - MYSQL_TYPE_BLOB, - &vhash, - sizeof (GNUNET_HashCode), - &h_length, - MYSQL_TYPE_LONG, - &v_type, - GNUNET_YES, - MYSQL_TYPE_BLOB, - buffer, - (unsigned long) - sizeof (buffer), &v_length, -1)))) + (ret = + prepared_statement_run (plugin, plugin->delete_value, NULL, + MYSQL_TYPE_BLOB, &v_key, + sizeof (GNUNET_HashCode), &k_length, + MYSQL_TYPE_BLOB, &vhash, + sizeof (GNUNET_HashCode), &h_length, + MYSQL_TYPE_LONG, &v_type, GNUNET_YES, + MYSQL_TYPE_BLOB, buffer, + (unsigned long) sizeof (buffer), &v_length, + -1)))) { if (ret == GNUNET_SYSERR) itable (plugin); @@ -1036,8 +975,8 @@ libgnunet_plugin_datacache_mysql_init (void *cls) api->get = &mysql_plugin_get; api->put = &mysql_plugin_put; api->del = &mysql_plugin_del; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "mysql", _("MySQL datacache running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "mysql", + _("MySQL datacache running\n")); return api; } diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index fdc377b8f..c5730078a 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c @@ -61,9 +61,7 @@ struct Plugin * @return GNUNET_OK if the result is acceptable */ static int -check_result (struct Plugin *plugin, - PGresult * ret, - int expected_status, +check_result (struct Plugin *plugin, PGresult * ret, int expected_status, const char *command, const char *args, int line) { if (ret == NULL) @@ -78,9 +76,8 @@ check_result (struct Plugin *plugin, { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "datastore-postgres", - _("`%s:%s' failed at %s:%d with error: %s"), - command, args, __FILE__, line, - PQerrorMessage (plugin->dbh)); + _("`%s:%s' failed at %s:%d with error: %s"), command, args, + __FILE__, line, PQerrorMessage (plugin->dbh)); PQclear (ret); return GNUNET_SYSERR; } @@ -97,8 +94,8 @@ pq_exec (struct Plugin *plugin, const char *sql, int line) PGresult *ret; ret = PQexec (plugin->dbh, sql); - if (GNUNET_OK != check_result (plugin, - ret, PGRES_COMMAND_OK, "PQexec", sql, line)) + if (GNUNET_OK != + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexec", sql, line)) return GNUNET_SYSERR; PQclear (ret); return GNUNET_OK; @@ -109,8 +106,8 @@ pq_exec (struct Plugin *plugin, const char *sql, int line) * Prepare SQL statement. */ static int -pq_prepare (struct Plugin *plugin, - const char *name, const char *sql, int nparms, int line) +pq_prepare (struct Plugin *plugin, const char *name, const char *sql, + int nparms, int line) { PGresult *ret; @@ -136,8 +133,8 @@ init_connection (struct Plugin *plugin) /* Open database and precompile statements */ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, - "datacache-postgres", - "CONFIG", &conninfo)) + "datacache-postgres", "CONFIG", + &conninfo)) conninfo = NULL; plugin->dbh = PQconnectdb (conninfo == NULL ? "" : conninfo); GNUNET_free_non_null (conninfo); @@ -148,28 +145,27 @@ init_connection (struct Plugin *plugin) } if (PQstatus (plugin->dbh) != CONNECTION_OK) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "datacache-postgres", _("Unable to initialize Postgres: %s"), PQerrorMessage (plugin->dbh)); PQfinish (plugin->dbh); plugin->dbh = NULL; return GNUNET_SYSERR; } - ret = PQexec (plugin->dbh, - "CREATE TEMPORARY TABLE gn090dc (" - " type INTEGER NOT NULL DEFAULT 0," - " discard_time BIGINT NOT NULL DEFAULT 0," - " key BYTEA NOT NULL DEFAULT ''," - " value BYTEA NOT NULL DEFAULT '')" "WITH OIDS"); + ret = + PQexec (plugin->dbh, + "CREATE TEMPORARY TABLE gn090dc (" + " type INTEGER NOT NULL DEFAULT 0," + " discard_time BIGINT NOT NULL DEFAULT 0," + " key BYTEA NOT NULL DEFAULT ''," + " value BYTEA NOT NULL DEFAULT '')" "WITH OIDS"); if ((ret == NULL) || ((PQresultStatus (ret) != PGRES_COMMAND_OK) && (0 != strcmp ("42P07", /* duplicate table */ PQresultErrorField (ret, PG_DIAG_SQLSTATE))))) { - (void) check_result (plugin, - ret, PGRES_COMMAND_OK, "CREATE TABLE", "gn090dc", - __LINE__); + (void) check_result (plugin, ret, PGRES_COMMAND_OK, "CREATE TABLE", + "gn090dc", __LINE__); PQfinish (plugin->dbh); plugin->dbh = NULL; return GNUNET_SYSERR; @@ -190,11 +186,12 @@ init_connection (struct Plugin *plugin) } PQclear (ret); #if 1 - ret = PQexec (plugin->dbh, - "ALTER TABLE gn090dc ALTER value SET STORAGE EXTERNAL"); + ret = + PQexec (plugin->dbh, + "ALTER TABLE gn090dc ALTER value SET STORAGE EXTERNAL"); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090dc", __LINE__)) + check_result (plugin, ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090dc", + __LINE__)) { PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -203,8 +200,8 @@ init_connection (struct Plugin *plugin) PQclear (ret); ret = PQexec (plugin->dbh, "ALTER TABLE gn090dc ALTER key SET STORAGE PLAIN"); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090dc", __LINE__)) + check_result (plugin, ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090dc", + __LINE__)) { PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -213,35 +210,22 @@ init_connection (struct Plugin *plugin) PQclear (ret); #endif if ((GNUNET_OK != - pq_prepare (plugin, - "getkt", + pq_prepare (plugin, "getkt", "SELECT discard_time,type,value FROM gn090dc " - "WHERE key=$1 AND type=$2 ", - 2, - __LINE__)) || + "WHERE key=$1 AND type=$2 ", 2, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "getk", + pq_prepare (plugin, "getk", "SELECT discard_time,type,value FROM gn090dc " - "WHERE key=$1", - 1, - __LINE__)) || + "WHERE key=$1", 1, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "getm", + pq_prepare (plugin, "getm", "SELECT length(value),oid,key FROM gn090dc " - "ORDER BY discard_time ASC LIMIT 1", - 0, - __LINE__)) || + "ORDER BY discard_time ASC LIMIT 1", 0, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "delrow", - "DELETE FROM gn090dc WHERE oid=$1", - 1, + pq_prepare (plugin, "delrow", "DELETE FROM gn090dc WHERE oid=$1", 1, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "put", + pq_prepare (plugin, "put", "INSERT INTO gn090dc (type, discard_time, key, value) " "VALUES ($1, $2, $3, $4)", 4, __LINE__))) { @@ -268,12 +252,11 @@ delete_by_rowid (struct Plugin *plugin, uint32_t rowid) const int paramFormats[] = { 1 }; PGresult *ret; - ret = PQexecPrepared (plugin->dbh, - "delrow", - 1, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecPrepared (plugin->dbh, "delrow", 1, paramValues, paramLengths, + paramFormats, 1); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "PQexecPrepared", "delrow", + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexecPrepared", "delrow", __LINE__)) { return GNUNET_SYSERR; @@ -295,11 +278,8 @@ delete_by_rowid (struct Plugin *plugin, uint32_t rowid) * @return 0 on error, number of bytes used otherwise */ static size_t -postgres_plugin_put (void *cls, - const GNUNET_HashCode * key, - size_t size, - const char *data, - enum GNUNET_BLOCK_Type type, +postgres_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, + const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time) { struct Plugin *plugin = cls; @@ -321,11 +301,12 @@ postgres_plugin_put (void *cls, }; const int paramFormats[] = { 1, 1, 1, 1 }; - ret = PQexecPrepared (plugin->dbh, - "put", 4, paramValues, paramLengths, paramFormats, 1); - if (GNUNET_OK != check_result (plugin, ret, - PGRES_COMMAND_OK, - "PQexecPrepared", "put", __LINE__)) + ret = + PQexecPrepared (plugin->dbh, "put", 4, paramValues, paramLengths, + paramFormats, 1); + if (GNUNET_OK != + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexecPrepared", "put", + __LINE__)) return GNUNET_SYSERR; PQclear (ret); return size + OVERHEAD; @@ -344,8 +325,7 @@ postgres_plugin_put (void *cls, * @return the number of results found */ static unsigned int -postgres_plugin_get (void *cls, - const GNUNET_HashCode * key, +postgres_plugin_get (void *cls, const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls) { @@ -368,19 +348,16 @@ postgres_plugin_get (void *cls, PGresult *res; cnt = 0; - res = PQexecPrepared (plugin->dbh, - (type == 0) ? "getk" : "getkt", - (type == 0) ? 1 : 2, - paramValues, paramLengths, paramFormats, 1); - if (GNUNET_OK != check_result (plugin, - res, - PGRES_TUPLES_OK, - "PQexecPrepared", - (type == 0) ? "getk" : "getkt", __LINE__)) + res = + PQexecPrepared (plugin->dbh, (type == 0) ? "getk" : "getkt", + (type == 0) ? 1 : 2, paramValues, paramLengths, + paramFormats, 1); + if (GNUNET_OK != + check_result (plugin, res, PGRES_TUPLES_OK, "PQexecPrepared", + (type == 0) ? "getk" : "getkt", __LINE__)) { #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", "Ending iteration (postgres error)\n"); #endif return 0; @@ -390,8 +367,7 @@ postgres_plugin_get (void *cls, { /* no result */ #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", "Ending iteration (no more results)\n"); #endif PQclear (res); @@ -402,8 +378,7 @@ postgres_plugin_get (void *cls, PQclear (res); return cnt; } - if ((3 != PQnfields (res)) || - (sizeof (uint64_t) != PQfsize (res, 0)) || + if ((3 != PQnfields (res)) || (sizeof (uint64_t) != PQfsize (res, 0)) || (sizeof (uint32_t) != PQfsize (res, 1))) { GNUNET_break (0); @@ -417,19 +392,16 @@ postgres_plugin_get (void *cls, type = ntohl (*(uint32_t *) PQgetvalue (res, i, 1)); size = PQgetlength (res, i, 2); #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", "Found result of size %u bytes and type %u in database\n", (unsigned int) size, (unsigned int) type); #endif if (GNUNET_SYSERR == - iter (iter_cls, - expiration_time, - key, size, PQgetvalue (res, i, 2), (enum GNUNET_BLOCK_Type) type)) + iter (iter_cls, expiration_time, key, size, PQgetvalue (res, i, 2), + (enum GNUNET_BLOCK_Type) type)) { #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", "Ending iteration (client error)\n"); #endif PQclear (res); @@ -458,14 +430,12 @@ postgres_plugin_del (void *cls) PGresult *res; res = PQexecPrepared (plugin->dbh, "getm", 0, NULL, NULL, NULL, 1); - if (GNUNET_OK != check_result (plugin, - res, - PGRES_TUPLES_OK, - "PQexecPrepared", "getm", __LINE__)) + if (GNUNET_OK != + check_result (plugin, res, PGRES_TUPLES_OK, "PQexecPrepared", "getm", + __LINE__)) { #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", "Ending iteration (postgres error)\n"); #endif return 0; @@ -474,15 +444,13 @@ postgres_plugin_del (void *cls) { /* no result */ #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datacache-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datacache-postgres", "Ending iteration (no more results)\n"); #endif PQclear (res); return GNUNET_SYSERR; } - if ((3 != PQnfields (res)) || - (sizeof (size) != PQfsize (res, 0)) || + if ((3 != PQnfields (res)) || (sizeof (size) != PQfsize (res, 0)) || (sizeof (oid) != PQfsize (res, 1)) || (sizeof (GNUNET_HashCode) != PQgetlength (res, 0, 2))) { @@ -528,8 +496,8 @@ libgnunet_plugin_datacache_postgres_init (void *cls) api->get = &postgres_plugin_get; api->put = &postgres_plugin_put; api->del = &postgres_plugin_del; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "datacache-postgres", _("Postgres datacache running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datacache-postgres", + _("Postgres datacache running\n")); return api; } diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 5f534227f..3d67ffc22 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c @@ -78,8 +78,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded { /* OUT: Statement handle */ char *dummy; - return sqlite3_prepare (dbh, - zSql, strlen (zSql), ppStmt, (const char **) &dummy); + return sqlite3_prepare (dbh, zSql, strlen (zSql), ppStmt, + (const char **) &dummy); } @@ -95,11 +95,8 @@ sq_prepare (sqlite3 * dbh, const char *zSql, /* SQL statement, UTF-8 encoded * @return 0 on error, number of bytes used otherwise */ static size_t -sqlite_plugin_put (void *cls, - const GNUNET_HashCode * key, - size_t size, - const char *data, - enum GNUNET_BLOCK_Type type, +sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, + const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time) { struct Plugin *plugin = cls; @@ -109,48 +106,44 @@ sqlite_plugin_put (void *cls, #if DEBUG_DATACACHE_SQLITE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n", - "PUT", - (unsigned int) size, - GNUNET_h2s (key), + "PUT", (unsigned int) size, GNUNET_h2s (key), (unsigned long long) GNUNET_TIME_absolute_get_remaining (discard_time).rel_value); #endif dval = (int64_t) discard_time.abs_value; if (dval < 0) dval = INT64_MAX; - if (sq_prepare (plugin->dbh, - "INSERT INTO ds090 " - "(type, expire, key, value) " - "VALUES (?, ?, ?, ?)", &stmt) != SQLITE_OK) + if (sq_prepare + (plugin->dbh, + "INSERT INTO ds090 " "(type, expire, key, value) " "VALUES (?, ?, ?, ?)", + &stmt) != SQLITE_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); return 0; } if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) || (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) || - (SQLITE_OK != sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode), - SQLITE_TRANSIENT)) || + (SQLITE_OK != + sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode), + SQLITE_TRANSIENT)) || (SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size, SQLITE_TRANSIENT))) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_xxx"); sqlite3_finalize (stmt); return 0; } if (SQLITE_DONE != sqlite3_step (stmt)) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); sqlite3_finalize (stmt); return 0; } if (SQLITE_OK != sqlite3_finalize (stmt)) - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_finalize"); return size + OVERHEAD; } @@ -168,10 +161,9 @@ sqlite_plugin_put (void *cls, * @return the number of results found */ static unsigned int -sqlite_plugin_get (void *cls, - const GNUNET_HashCode * key, - enum GNUNET_BLOCK_Type type, - GNUNET_DATACACHE_Iterator iter, void *iter_cls) +sqlite_plugin_get (void *cls, const GNUNET_HashCode * key, + enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, + void *iter_cls) { struct Plugin *plugin = cls; sqlite3_stmt *stmt; @@ -187,16 +179,17 @@ sqlite_plugin_get (void *cls, now = GNUNET_TIME_absolute_get (); #if DEBUG_DATACACHE_SQLITE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' for key `%4s'\n", "GET", GNUNET_h2s (key)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' for key `%4s'\n", "GET", + GNUNET_h2s (key)); #endif - if (sq_prepare (plugin->dbh, - "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", - &stmt) != SQLITE_OK) + if (sq_prepare + (plugin->dbh, + "SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?", + &stmt) != SQLITE_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); return 0; } ntime = (int64_t) now.abs_value; @@ -204,12 +197,10 @@ sqlite_plugin_get (void *cls, if ((SQLITE_OK != sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT)) || - (SQLITE_OK != - sqlite3_bind_int (stmt, 2, type)) || + (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_xxx"); sqlite3_finalize (stmt); return 0; @@ -217,8 +208,7 @@ sqlite_plugin_get (void *cls, if (SQLITE_ROW != sqlite3_step (stmt)) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite_step"); sqlite3_finalize (stmt); return 0; @@ -233,27 +223,23 @@ sqlite_plugin_get (void *cls, while (cnt < total) { off = (off + 1) % total; - GNUNET_snprintf (scratch, - sizeof (scratch), + GNUNET_snprintf (scratch, sizeof (scratch), "SELECT value,expire FROM ds090 WHERE key=? AND type=? AND expire >= ? LIMIT 1 OFFSET %u", off); if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sq_prepare", __FILE__, __LINE__, - sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); return cnt; } if ((SQLITE_OK != sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT)) || - (SQLITE_OK != - sqlite3_bind_int (stmt, 2, type)) || + (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) || (SQLITE_OK != sqlite3_bind_int64 (stmt, 3, now.abs_value))) { - LOG_SQLITE (plugin->dbh, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_xxx"); sqlite3_finalize (stmt); return cnt; @@ -301,13 +287,14 @@ sqlite_plugin_del (void *cls) #endif stmt = NULL; dstmt = NULL; - if (sq_prepare (plugin->dbh, - "SELECT type, key, value FROM ds090 ORDER BY expire ASC LIMIT 1", - &stmt) != SQLITE_OK) + if (sq_prepare + (plugin->dbh, + "SELECT type, key, value FROM ds090 ORDER BY expire ASC LIMIT 1", + &stmt) != SQLITE_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); if (stmt != NULL) (void) sqlite3_finalize (stmt); return GNUNET_SYSERR; @@ -315,9 +302,8 @@ sqlite_plugin_del (void *cls) if (SQLITE_ROW != sqlite3_step (stmt)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sqlite3_step", __FILE__, __LINE__, - sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_step", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); (void) sqlite3_finalize (stmt); return GNUNET_SYSERR; } @@ -329,54 +315,44 @@ sqlite_plugin_del (void *cls) memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (GNUNET_HashCode)); if (SQLITE_OK != sqlite3_finalize (stmt)) GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sqlite3_step", __FILE__, __LINE__, - sqlite3_errmsg (plugin->dbh)); - if (sq_prepare (plugin->dbh, - "DELETE FROM ds090 " - "WHERE key=? AND value=? AND type=?", &dstmt) != SQLITE_OK) + _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_step", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); + if (sq_prepare + (plugin->dbh, "DELETE FROM ds090 " "WHERE key=? AND value=? AND type=?", + &dstmt) != SQLITE_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sq_prepare", __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sq_prepare", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); if (stmt != NULL) (void) sqlite3_finalize (stmt); return GNUNET_SYSERR; } if ((SQLITE_OK != - sqlite3_bind_blob (dstmt, - 1, &hc, - sizeof (GNUNET_HashCode), - SQLITE_TRANSIENT)) || - (SQLITE_OK != - sqlite3_bind_blob (dstmt, - 2, blob, - dsize, + sqlite3_bind_blob (dstmt, 1, &hc, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT)) || - (SQLITE_OK != sqlite3_bind_int (dstmt, 3, dtype))) + (SQLITE_OK != sqlite3_bind_blob (dstmt, 2, blob, dsize, SQLITE_TRANSIENT)) + || (SQLITE_OK != sqlite3_bind_int (dstmt, 3, dtype))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sqlite3_bind", __FILE__, __LINE__, - sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_bind", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); (void) sqlite3_finalize (dstmt); return GNUNET_SYSERR; } if (sqlite3_step (dstmt) != SQLITE_DONE) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sqlite3_step", __FILE__, __LINE__, - sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_step", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); (void) sqlite3_finalize (dstmt); return GNUNET_SYSERR; } plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD); if (SQLITE_OK != sqlite3_finalize (dstmt)) GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - _("`%s' failed at %s:%d with error: %s\n"), - "sqlite3_finalize", __FILE__, __LINE__, - sqlite3_errmsg (plugin->dbh)); + _("`%s' failed at %s:%d with error: %s\n"), "sqlite3_finalize", + __FILE__, __LINE__, sqlite3_errmsg (plugin->dbh)); return GNUNET_OK; } @@ -425,8 +401,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) SQLITE3_EXEC (dbh, "PRAGMA count_changes=OFF"); SQLITE3_EXEC (dbh, "PRAGMA page_size=4092"); SQLITE3_EXEC (dbh, - "CREATE TABLE ds090 (" - " type INTEGER NOT NULL DEFAULT 0," + "CREATE TABLE ds090 (" " type INTEGER NOT NULL DEFAULT 0," " expire INTEGER NOT NULL DEFAULT 0," " key BLOB NOT NULL DEFAULT ''," " value BLOB NOT NULL DEFAULT '')"); @@ -440,8 +415,8 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) api->get = &sqlite_plugin_get; api->put = &sqlite_plugin_put; api->del = &sqlite_plugin_del; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "sqlite", _("Sqlite datacache running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "sqlite", + _("Sqlite datacache running\n")); return api; } @@ -474,22 +449,20 @@ libgnunet_plugin_datacache_sqlite_done (void *cls) #if SQLITE_VERSION_NUMBER >= 3007000 if (result == SQLITE_BUSY) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite", _ ("Tried to close sqlite without finalizing all prepared statements.\n")); stmt = sqlite3_next_stmt (plugin->dbh, NULL); while (stmt != NULL) { #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", "Closing statement %p\n", stmt); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", + "Closing statement %p\n", stmt); #endif result = sqlite3_finalize (stmt); #if DEBUG_SQLITE if (result != SQLITE_OK) - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Failed to close statement %p: %d\n", stmt, result); #endif stmt = sqlite3_next_stmt (plugin->dbh, NULL); diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index 865f431d7..046c603ad 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c @@ -52,11 +52,8 @@ struct Plugin * @return 0 on error, number of bytes used otherwise */ static size_t -template_plugin_put (void *cls, - const GNUNET_HashCode * key, - size_t size, - const char *data, - enum GNUNET_BLOCK_Type type, +template_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size, + const char *data, enum GNUNET_BLOCK_Type type, struct GNUNET_TIME_Absolute discard_time) { GNUNET_break (0); @@ -76,8 +73,7 @@ template_plugin_put (void *cls, * @return the number of results found */ static unsigned int -template_plugin_get (void *cls, - const GNUNET_HashCode * key, +template_plugin_get (void *cls, const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, GNUNET_DATACACHE_Iterator iter, void *iter_cls) { @@ -121,8 +117,8 @@ libgnunet_plugin_datacache_template_init (void *cls) api->get = &template_plugin_get; api->put = &template_plugin_put; api->del = &template_plugin_del; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "template", _("Template datacache running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "template", + _("Template datacache running\n")); return api; } diff --git a/src/datacache/test_datacache.c b/src/datacache/test_datacache.c index c04facc15..abf0209d8 100644 --- a/src/datacache/test_datacache.c +++ b/src/datacache/test_datacache.c @@ -39,10 +39,9 @@ static const char *plugin_name; static int -checkIt (void *cls, - struct GNUNET_TIME_Absolute exp, - const GNUNET_HashCode * key, - size_t size, const char *data, enum GNUNET_BLOCK_Type type) +checkIt (void *cls, struct GNUNET_TIME_Absolute exp, + const GNUNET_HashCode * key, size_t size, const char *data, + enum GNUNET_BLOCK_Type type) { if (size != sizeof (GNUNET_HashCode)) { @@ -59,9 +58,8 @@ checkIt (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DATACACHE_Handle *h; GNUNET_HashCode k; @@ -83,11 +81,9 @@ run (void *cls, for (i = 0; i < 100; i++) { GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); - ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, - &k, - sizeof (GNUNET_HashCode), - (const char *) &n, - 1 + i % 16, exp)); + ASSERT (GNUNET_OK == + GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode), + (const char *) &n, 1 + i % 16, exp)); k = n; } memset (&k, 0, sizeof (GNUNET_HashCode)); @@ -100,12 +96,10 @@ run (void *cls, memset (&k, 42, sizeof (GNUNET_HashCode)); GNUNET_CRYPTO_hash (&k, sizeof (GNUNET_HashCode), &n); - ASSERT (GNUNET_OK == GNUNET_DATACACHE_put (h, - &k, - sizeof (GNUNET_HashCode), - (const char *) &n, - 792, - GNUNET_TIME_UNIT_FOREVER_ABS)); + ASSERT (GNUNET_OK == + GNUNET_DATACACHE_put (h, &k, sizeof (GNUNET_HashCode), + (const char *) &n, 792, + GNUNET_TIME_UNIT_FOREVER_ABS)); ASSERT (0 != GNUNET_DATACACHE_get (h, &k, 792, &checkIt, &n)); GNUNET_DATACACHE_destroy (h); @@ -153,13 +147,12 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), - "test_datacache_data_%s.conf", plugin_name); + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf", + plugin_name); if (pos != plugin_name) pos[0] = '.'; - GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, - xargv, "test-datacache", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, + "test-datacache", "nohelp", options, &run, NULL); if (ok != 0) fprintf (stderr, "Missed some testcases: %d\n", ok); return ok; diff --git a/src/datacache/test_datacache_quota.c b/src/datacache/test_datacache_quota.c index f943844a4..ad8681cec 100644 --- a/src/datacache/test_datacache_quota.c +++ b/src/datacache/test_datacache_quota.c @@ -44,9 +44,8 @@ static const char *plugin_name; * some of the data from the last iteration is still there. */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DATACACHE_Handle *h; GNUNET_HashCode k; @@ -140,14 +139,12 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), - "test_datacache_data_%s.conf", plugin_name); + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datacache_data_%s.conf", + plugin_name); if (pos != plugin_name) pos[0] = '.'; - GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, - xargv, "test-datacache-quota", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, + "test-datacache-quota", "nohelp", options, &run, NULL); if (ok != 0) fprintf (stderr, "Missed some testcases: %d\n", ok); return ok; diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 85e402a4d..ff49c106e 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -367,8 +367,8 @@ timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_DATASTORE_QueueEntry *qe = cls; GNUNET_STATISTICS_update (qe->h->stats, - gettext_noop ("# queue entry timeouts"), - 1, GNUNET_NO); + gettext_noop ("# queue entry timeouts"), 1, + GNUNET_NO); qe->task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (qe->was_transmitted == GNUNET_NO); #if DEBUG_DATASTORE @@ -394,10 +394,8 @@ timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return NULL if the queue is full */ static struct GNUNET_DATASTORE_QueueEntry * -make_queue_entry (struct GNUNET_DATASTORE_Handle *h, - size_t msize, - unsigned int queue_priority, - unsigned int max_queue_size, +make_queue_entry (struct GNUNET_DATASTORE_Handle *h, size_t msize, + unsigned int queue_priority, unsigned int max_queue_size, struct GNUNET_TIME_Relative timeout, GNUNET_CLIENT_MessageHandler response_proc, const union QueueContext *qc) @@ -408,16 +406,16 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, c = 0; pos = h->queue_head; - while ((pos != NULL) && - (c < max_queue_size) && (pos->priority >= queue_priority)) + while ((pos != NULL) && (c < max_queue_size) && + (pos->priority >= queue_priority)) { c++; pos = pos->next; } if (c >= max_queue_size) { - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# queue overflows"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# queue overflows"), 1, + GNUNET_NO); return NULL; } ret = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_QueueEntry) + msize); @@ -443,8 +441,7 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, pos = h->queue_head; } c++; - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# queue entries created"), + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# queue entries created"), 1, GNUNET_NO); GNUNET_CONTAINER_DLL_insert_after (h->queue_head, h->queue_tail, pos, ret); h->queue_size++; @@ -540,15 +537,14 @@ do_disconnect (struct GNUNET_DATASTORE_Handle *h) return; } #if 0 - GNUNET_STATISTICS_update (stats, - gettext_noop ("# reconnected to DATASTORE"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# reconnected to DATASTORE"), 1, GNUNET_NO); #endif GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); h->skip_next_messages = 0; h->client = NULL; - h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->retry_time, - &try_reconnect, h); + h->reconnect_task = + GNUNET_SCHEDULER_add_delayed (h->retry_time, &try_reconnect, h); } @@ -628,12 +624,11 @@ transmit_request (void *cls, size_t size, void *buf) qe->task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (GNUNET_NO == h->in_receive); h->in_receive = GNUNET_YES; - GNUNET_CLIENT_receive (h->client, - &receive_cb, - h, GNUNET_TIME_absolute_get_remaining (qe->timeout)); + GNUNET_CLIENT_receive (h->client, &receive_cb, h, + GNUNET_TIME_absolute_get_remaining (qe->timeout)); GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# bytes sent to datastore"), - 1, GNUNET_NO); + gettext_noop ("# bytes sent to datastore"), 1, + GNUNET_NO); return msize; } @@ -686,11 +681,11 @@ process_queue (struct GNUNET_DATASTORE_Handle *h) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing %u byte request to DATASTORE\n", qe->message_size); #endif - h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, - qe->message_size, - GNUNET_TIME_absolute_get_remaining - (qe->timeout), GNUNET_YES, - &transmit_request, h); + h->th = + GNUNET_CLIENT_notify_transmit_ready (h->client, qe->message_size, + GNUNET_TIME_absolute_get_remaining + (qe->timeout), GNUNET_YES, + &transmit_request, h); GNUNET_assert (GNUNET_NO == h->in_receive); GNUNET_break (NULL != h->th); } @@ -768,8 +763,7 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) else process_queue (h); if (rc.cont != NULL) - rc.cont (rc.cont_cls, - GNUNET_SYSERR, + rc.cont (rc.cont_cls, GNUNET_SYSERR, _("Failed to receive status response from database.")); return; } @@ -782,8 +776,7 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) h->retry_time = GNUNET_TIME_UNIT_ZERO; do_disconnect (h); if (rc.cont != NULL) - rc.cont (rc.cont_cls, - GNUNET_SYSERR, + rc.cont (rc.cont_cls, GNUNET_SYSERR, _("Error reading response from datastore service")); return; } @@ -805,12 +798,12 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) emsg = _("Invalid error message received from datastore service"); } #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received status %d/%s\n", (int) status, emsg); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received status %d/%s\n", (int) status, + emsg); #endif GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# status messages received"), - 1, GNUNET_NO); + gettext_noop ("# status messages received"), 1, + GNUNET_NO); h->retry_time.rel_value = 0; process_queue (h); if (rc.cont != NULL) @@ -845,18 +838,13 @@ process_status_message (void *cls, const struct GNUNET_MessageHeader *msg) * (or rather, will already have been invoked) */ struct GNUNET_DATASTORE_QueueEntry * -GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, - uint32_t rid, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, uint32_t rid, + const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, - unsigned int queue_priority, - unsigned int max_queue_size, + unsigned int queue_priority, unsigned int max_queue_size, struct GNUNET_TIME_Relative timeout, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls) @@ -869,16 +857,14 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to put %u bytes of data under key `%s' for %llu ms\n", - size, - GNUNET_h2s (key), + size, GNUNET_h2s (key), GNUNET_TIME_absolute_get_remaining (expiration).rel_value); #endif msize = sizeof (struct DataMessage) + size; GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); qc.sc.cont = cont; qc.sc.cont_cls = cont_cls; - qe = make_queue_entry (h, msize, - queue_priority, max_queue_size, timeout, + qe = make_queue_entry (h, msize, queue_priority, max_queue_size, timeout, &process_status_message, &qc); if (qe == NULL) { @@ -888,8 +874,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, #endif return NULL; } - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# PUT requests executed"), + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# PUT requests executed"), 1, GNUNET_NO); dm = (struct DataMessage *) &qe[1]; dm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_PUT); @@ -930,10 +915,8 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, * (or rather, will already have been invoked) */ struct GNUNET_DATASTORE_QueueEntry * -GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, - uint64_t amount, - uint32_t entries, - unsigned int queue_priority, +GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, + uint32_t entries, unsigned int queue_priority, unsigned int max_queue_size, struct GNUNET_TIME_Relative timeout, GNUNET_DATASTORE_ContinuationWithStatus cont, @@ -952,9 +935,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, #endif qc.sc.cont = cont; qc.sc.cont_cls = cont_cls; - qe = make_queue_entry (h, sizeof (struct ReserveMessage), - queue_priority, max_queue_size, timeout, - &process_status_message, &qc); + qe = make_queue_entry (h, sizeof (struct ReserveMessage), queue_priority, + max_queue_size, timeout, &process_status_message, &qc); if (qe == NULL) { #if DEBUG_DATASTORE @@ -964,8 +946,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, return NULL; } GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# RESERVE requests executed"), - 1, GNUNET_NO); + gettext_noop ("# RESERVE requests executed"), 1, + GNUNET_NO); rm = (struct ReserveMessage *) &qe[1]; rm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE); rm->header.size = htons (sizeof (struct ReserveMessage)); @@ -999,8 +981,7 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, */ struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, - uint32_t rid, - unsigned int queue_priority, + uint32_t rid, unsigned int queue_priority, unsigned int max_queue_size, struct GNUNET_TIME_Relative timeout, GNUNET_DATASTORE_ContinuationWithStatus cont, @@ -1059,8 +1040,7 @@ GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, * (or rather, will already have been invoked) */ struct GNUNET_DATASTORE_QueueEntry * -GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, - uint64_t uid, +GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid, uint32_t priority, struct GNUNET_TIME_Absolute expiration, unsigned int queue_priority, @@ -1078,15 +1058,13 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to update entry %llu raising priority by %u and expiration to %llu\n", - uid, - (unsigned int) priority, + uid, (unsigned int) priority, (unsigned long long) expiration.abs_value); #endif qc.sc.cont = cont; qc.sc.cont_cls = cont_cls; - qe = make_queue_entry (h, sizeof (struct UpdateMessage), - queue_priority, max_queue_size, timeout, - &process_status_message, &qc); + qe = make_queue_entry (h, sizeof (struct UpdateMessage), queue_priority, + max_queue_size, timeout, &process_status_message, &qc); if (qe == NULL) { #if DEBUG_DATASTORE @@ -1096,8 +1074,8 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, return NULL; } GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# UPDATE requests executed"), - 1, GNUNET_NO); + gettext_noop ("# UPDATE requests executed"), 1, + GNUNET_NO); um = (struct UpdateMessage *) &qe[1]; um->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE); um->header.size = htons (sizeof (struct UpdateMessage)); @@ -1132,10 +1110,8 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, */ struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, - const GNUNET_HashCode * key, - size_t size, - const void *data, - unsigned int queue_priority, + const GNUNET_HashCode * key, size_t size, + const void *data, unsigned int queue_priority, unsigned int max_queue_size, struct GNUNET_TIME_Relative timeout, GNUNET_DATASTORE_ContinuationWithStatus cont, @@ -1150,15 +1126,14 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, cont = &drop_status_cont; #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asked to remove %u bytes under key `%s'\n", - size, GNUNET_h2s (key)); + "Asked to remove %u bytes under key `%s'\n", size, + GNUNET_h2s (key)); #endif qc.sc.cont = cont; qc.sc.cont_cls = cont_cls; msize = sizeof (struct DataMessage) + size; GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); - qe = make_queue_entry (h, msize, - queue_priority, max_queue_size, timeout, + qe = make_queue_entry (h, msize, queue_priority, max_queue_size, timeout, &process_status_message, &qc); if (qe == NULL) { @@ -1169,8 +1144,8 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, return NULL; } GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# REMOVE requests executed"), - 1, GNUNET_NO); + gettext_noop ("# REMOVE requests executed"), 1, + GNUNET_NO); dm = (struct DataMessage *) &qe[1]; dm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE); dm->header.size = htons (msize); @@ -1222,8 +1197,8 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg) process_queue (h); } if (rc.proc != NULL) - rc.proc (rc.proc_cls, - NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); + rc.proc (rc.proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, + 0); return; } if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END) @@ -1239,8 +1214,8 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg) h->queue_size); #endif if (rc.proc != NULL) - rc.proc (rc.proc_cls, - NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); + rc.proc (rc.proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, + 0); h->retry_time.rel_value = 0; h->result_count = 0; process_queue (h); @@ -1256,8 +1231,8 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg) h->retry_time = GNUNET_TIME_UNIT_ZERO; do_disconnect (h); if (rc.proc != NULL) - rc.proc (rc.proc_cls, - NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); + rc.proc (rc.proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, + 0); return; } if ((ntohs (msg->size) < sizeof (struct DataMessage)) || @@ -1271,30 +1246,25 @@ process_result_message (void *cls, const struct GNUNET_MessageHeader *msg) h->retry_time = GNUNET_TIME_UNIT_ZERO; do_disconnect (h); if (rc.proc != NULL) - rc.proc (rc.proc_cls, - NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); + rc.proc (rc.proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, + 0); return; } - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# Results received"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# Results received"), 1, + GNUNET_NO); dm = (const struct DataMessage *) msg; #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received result %llu with type %u and size %u with key %s\n", - (unsigned long long) GNUNET_ntohll (dm->uid), - ntohl (dm->type), ntohl (dm->size), GNUNET_h2s (&dm->key)); + (unsigned long long) GNUNET_ntohll (dm->uid), ntohl (dm->type), + ntohl (dm->size), GNUNET_h2s (&dm->key)); #endif free_queue_entry (qe); h->retry_time.rel_value = 0; process_queue (h); if (rc.proc != NULL) - rc.proc (rc.proc_cls, - &dm->key, - ntohl (dm->size), - &dm[1], - ntohl (dm->type), - ntohl (dm->priority), - ntohl (dm->anonymity), + rc.proc (rc.proc_cls, &dm->key, ntohl (dm->size), &dm[1], ntohl (dm->type), + ntohl (dm->priority), ntohl (dm->anonymity), GNUNET_TIME_absolute_ntoh (dm->expiration), GNUNET_ntohll (dm->uid)); } @@ -1401,8 +1371,8 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to get %llu-th zero-anonymity entry of type %d in %llu ms\n", - (unsigned long long) offset, - type, (unsigned long long) timeout.rel_value); + (unsigned long long) offset, type, + (unsigned long long) timeout.rel_value); #endif qc.rc.proc = proc; qc.rc.proc_cls = proc_cls; @@ -1453,8 +1423,7 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, * cancel */ struct GNUNET_DATASTORE_QueueEntry * -GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, - uint64_t offset, +GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, uint64_t offset, const GNUNET_HashCode * key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, @@ -1474,19 +1443,17 @@ GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, #endif qc.rc.proc = proc; qc.rc.proc_cls = proc_cls; - qe = make_queue_entry (h, sizeof (struct GetMessage), - queue_priority, max_queue_size, timeout, - &process_result_message, &qc); + qe = make_queue_entry (h, sizeof (struct GetMessage), queue_priority, + max_queue_size, timeout, &process_result_message, &qc); if (qe == NULL) { #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Could not queue request for `%s'\n", GNUNET_h2s (key)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Could not queue request for `%s'\n", + GNUNET_h2s (key)); #endif return NULL; } - GNUNET_STATISTICS_update (h->stats, - gettext_noop ("# GET requests executed"), + GNUNET_STATISTICS_update (h->stats, gettext_noop ("# GET requests executed"), 1, GNUNET_NO); gm = (struct GetMessage *) &qe[1]; gm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_GET); @@ -1522,8 +1489,8 @@ GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe) h = qe->h; #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Pending DATASTORE request %p cancelled (%d, %d)\n", - qe, qe->was_transmitted, h->queue_head == qe); + "Pending DATASTORE request %p cancelled (%d, %d)\n", qe, + qe->was_transmitted, h->queue_head == qe); #endif if (GNUNET_YES == qe->was_transmitted) { diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index c01de5891..8efb706c1 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -276,8 +276,8 @@ static struct GNUNET_STATISTICS_GetHandle *stat_get; * @param cls not used * @param tc task context */ -static void -delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void delete_expired (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -301,45 +301,38 @@ delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); * GNUNET_NO to delete the item and continue (if supported) */ static int -expired_processor (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +expired_processor (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct GNUNET_TIME_Absolute now; if (key == NULL) { - expired_kill_task - = GNUNET_SCHEDULER_add_delayed (MAX_EXPIRE_DELAY, - &delete_expired, NULL); + expired_kill_task = + GNUNET_SCHEDULER_add_delayed (MAX_EXPIRE_DELAY, &delete_expired, NULL); return GNUNET_SYSERR; } now = GNUNET_TIME_absolute_get (); if (expiration.abs_value > now.abs_value) { /* finished processing */ - expired_kill_task - = GNUNET_SCHEDULER_add_delayed (MAX_EXPIRE_DELAY, - &delete_expired, NULL); + expired_kill_task = + GNUNET_SCHEDULER_add_delayed (MAX_EXPIRE_DELAY, &delete_expired, NULL); return GNUNET_SYSERR; } #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting content `%s' of type %u that expired %llu ms ago\n", - GNUNET_h2s (key), - type, + GNUNET_h2s (key), type, (unsigned long long) (now.abs_value - expiration.abs_value)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# bytes expired"), size, GNUNET_YES); + GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes expired"), size, + GNUNET_YES); GNUNET_CONTAINER_bloomfilter_remove (filter, key); - expired_kill_task - = GNUNET_SCHEDULER_add_delayed (MIN_EXPIRE_DELAY, &delete_expired, NULL); + expired_kill_task = + GNUNET_SCHEDULER_add_delayed (MIN_EXPIRE_DELAY, &delete_expired, NULL); return GNUNET_NO; } @@ -381,13 +374,9 @@ delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * GNUNET_NO to delete the item and continue (if supported) */ static int -quota_processor (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +quota_processor (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { unsigned long long *need = cls; @@ -507,10 +496,10 @@ transmit (struct GNUNET_SERVER_Client *client, struct GNUNET_MessageHeader *msg) tcc->msg = msg; tcc->client = client; if (NULL == - (tcc->th = GNUNET_SERVER_notify_transmit_ready (client, - ntohs (msg->size), - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_callback, tcc))) + (tcc->th = + GNUNET_SERVER_notify_transmit_ready (client, ntohs (msg->size), + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_callback, tcc))) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -572,14 +561,10 @@ transmit_status (struct GNUNET_SERVER_Client *client, int code, const char *msg) * GNUNET_NO to delete the item and continue (if supported) */ static int -transmit_item (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +transmit_item (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct GNUNET_SERVER_Client *client = cls; struct GNUNET_MessageHeader *end; @@ -589,8 +574,8 @@ transmit_item (void *cls, { /* transmit 'DATA_END' */ #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting `%s' message\n", "DATA_END"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message\n", + "DATA_END"); #endif end = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader)); end->size = htons (sizeof (struct GNUNET_MessageHeader)); @@ -618,14 +603,12 @@ transmit_item (void *cls, #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message for `%s' of type %u with expiration %llu (now: %llu)\n", - "DATA", - GNUNET_h2s (key), - type, + "DATA", GNUNET_h2s (key), type, (unsigned long long) expiration.abs_value, (unsigned long long) GNUNET_TIME_absolute_get ().abs_value); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# results found"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# results found"), 1, + GNUNET_NO); transmit (client, &dm->header); GNUNET_SERVER_client_drop (client); return GNUNET_OK; @@ -640,8 +623,7 @@ transmit_item (void *cls, * @param message the actual message */ static void -handle_reserve (void *cls, - struct GNUNET_SERVER_Client *client, +handle_reserve (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { /** @@ -696,8 +678,8 @@ handle_reserve (void *cls, return; } reserved += req; - GNUNET_STATISTICS_set (stats, - gettext_noop ("# reserved"), reserved, GNUNET_NO); + GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved, + GNUNET_NO); e = GNUNET_malloc (sizeof (struct ReservationList)); e->next = reservations; reservations = e; @@ -719,8 +701,7 @@ handle_reserve (void *cls, * @param message the actual message */ static void -handle_release_reserve (void *cls, - struct GNUNET_SERVER_Client *client, +handle_release_reserve (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct ReleaseReserveMessage *msg = @@ -732,8 +713,8 @@ handle_release_reserve (void *cls, unsigned long long rem; #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request\n", "RELEASE_RESERVE"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", + "RELEASE_RESERVE"); #endif next = reservations; prev = NULL; @@ -751,8 +732,8 @@ handle_release_reserve (void *cls, ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->entries; GNUNET_assert (reserved >= rem); reserved -= rem; - GNUNET_STATISTICS_set (stats, - gettext_noop ("# reserved"), reserved, GNUNET_NO); + GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved, + GNUNET_NO); #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Returning %llu remaining reserved bytes to storage pool\n", @@ -830,20 +811,15 @@ execute_put (struct GNUNET_SERVER_Client *client, const struct DataMessage *dm) size = ntohl (dm->size); msg = NULL; - ret = plugin->api->put (plugin->api->cls, - &dm->key, - size, - &dm[1], - ntohl (dm->type), - ntohl (dm->priority), - ntohl (dm->anonymity), - ntohl (dm->replication), - GNUNET_TIME_absolute_ntoh (dm->expiration), &msg); + ret = + plugin->api->put (plugin->api->cls, &dm->key, size, &dm[1], + ntohl (dm->type), ntohl (dm->priority), + ntohl (dm->anonymity), ntohl (dm->replication), + GNUNET_TIME_absolute_ntoh (dm->expiration), &msg); if (GNUNET_OK == ret) { - GNUNET_STATISTICS_update (stats, - gettext_noop ("# bytes stored"), - size, GNUNET_YES); + GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes stored"), size, + GNUNET_YES); GNUNET_CONTAINER_bloomfilter_add (filter, &dm->key); #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -884,14 +860,10 @@ execute_put (struct GNUNET_SERVER_Client *client, const struct DataMessage *dm) * GNUNET_NO to delete the item */ static int -check_present (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +check_present (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct PutContext *pc = cls; const struct DataMessage *dm; @@ -905,8 +877,9 @@ check_present (void *cls, return GNUNET_OK; } if ((GNUNET_BLOCK_TYPE_FS_DBLOCK == type) || - (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || - ((size == ntohl (dm->size)) && (0 == memcmp (&dm[1], data, size)))) + (GNUNET_BLOCK_TYPE_FS_IBLOCK == type) || ((size == ntohl (dm->size)) && + (0 == + memcmp (&dm[1], data, size)))) { #if DEBUG_MYSQL GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -916,8 +889,7 @@ check_present (void *cls, if ((ntohl (dm->priority) > 0) || (GNUNET_TIME_absolute_ntoh (dm->expiration).abs_value > expiration.abs_value)) - plugin->api->update (plugin->api->cls, - uid, + plugin->api->update (plugin->api->cls, uid, (int32_t) ntohl (dm->priority), GNUNET_TIME_absolute_ntoh (dm->expiration), NULL); transmit_status (pc->client, GNUNET_NO, NULL); @@ -942,8 +914,7 @@ check_present (void *cls, * @param message the actual message */ static void -handle_put (void *cls, - struct GNUNET_SERVER_Client *client, +handle_put (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct DataMessage *dm = check_data (message); @@ -961,8 +932,8 @@ handle_put (void *cls, } #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request for `%s' of type %u\n", - "PUT", GNUNET_h2s (&dm->key), ntohl (dm->type)); + "Processing `%s' request for `%s' of type %u\n", "PUT", + GNUNET_h2s (&dm->key), ntohl (dm->type)); #endif rid = ntohl (dm->rid); size = ntohl (dm->size); @@ -979,8 +950,8 @@ handle_put (void *cls, pos->entries--; pos->amount -= size; reserved -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD); - GNUNET_STATISTICS_set (stats, - gettext_noop ("# reserved"), reserved, GNUNET_NO); + GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved, + GNUNET_NO); } } if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (filter, &dm->key)) @@ -991,10 +962,8 @@ handle_put (void *cls, pc->client = client; GNUNET_SERVER_client_keep (client); memcpy (&pc[1], dm, size + sizeof (struct DataMessage)); - plugin->api->get_key (plugin->api->cls, - 0, - &dm->key, - &vhash, ntohl (dm->type), &check_present, pc); + plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash, + ntohl (dm->type), &check_present, pc); return; } execute_put (client, dm); @@ -1009,8 +978,7 @@ handle_put (void *cls, * @param message the actual message */ static void -handle_get (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct GetMessage *msg; @@ -1027,12 +995,11 @@ handle_get (void *cls, msg = (const struct GetMessage *) message; #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request for `%s' of type %u\n", - "GET", GNUNET_h2s (&msg->key), ntohl (msg->type)); + "Processing `%s' request for `%s' of type %u\n", "GET", + GNUNET_h2s (&msg->key), ntohl (msg->type)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# GET requests received"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# GET requests received"), 1, + GNUNET_NO); GNUNET_SERVER_client_keep (client); if ((size == sizeof (struct GetMessage)) && (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key))) @@ -1051,8 +1018,7 @@ handle_get (void *cls, 0); return; } - plugin->api->get_key (plugin->api->cls, - GNUNET_ntohll (msg->offset), + plugin->api->get_key (plugin->api->cls, GNUNET_ntohll (msg->offset), ((size == sizeof (struct GetMessage)) ? &msg->key : NULL), NULL, ntohl (msg->type), &transmit_item, client); @@ -1067,29 +1033,25 @@ handle_get (void *cls, * @param message the actual message */ static void -handle_update (void *cls, - struct GNUNET_SERVER_Client *client, +handle_update (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct UpdateMessage *msg; int ret; char *emsg; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# UPDATE requests received"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# UPDATE requests received"), 1, GNUNET_NO); msg = (const struct UpdateMessage *) message; emsg = NULL; #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request for %llu\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request for %llu\n", "UPDATE", (unsigned long long) GNUNET_ntohll (msg->uid)); #endif - ret = plugin->api->update (plugin->api->cls, - GNUNET_ntohll (msg->uid), - (int32_t) ntohl (msg->priority), - GNUNET_TIME_absolute_ntoh (msg->expiration), - &emsg); + ret = + plugin->api->update (plugin->api->cls, GNUNET_ntohll (msg->uid), + (int32_t) ntohl (msg->priority), + GNUNET_TIME_absolute_ntoh (msg->expiration), &emsg); transmit_status (client, ret, emsg); GNUNET_free_non_null (emsg); } @@ -1103,13 +1065,12 @@ handle_update (void *cls, * @param message the actual message */ static void -handle_get_replication (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get_replication (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request\n", "GET_REPLICATION"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", + "GET_REPLICATION"); #endif GNUNET_STATISTICS_update (stats, gettext_noop @@ -1128,8 +1089,7 @@ handle_get_replication (void *cls, * @param message the actual message */ static void -handle_get_zero_anonymity (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get_zero_anonymity (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct GetZeroAnonymityMessage *msg = @@ -1144,8 +1104,8 @@ handle_get_zero_anonymity (void *cls, return; } #if DEBUG_DATASTORE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request\n", "GET_ZERO_ANONYMITY"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing `%s' request\n", + "GET_ZERO_ANONYMITY"); #endif GNUNET_STATISTICS_update (stats, gettext_noop @@ -1153,8 +1113,8 @@ handle_get_zero_anonymity (void *cls, GNUNET_NO); GNUNET_SERVER_client_keep (client); plugin->api->get_zero_anonymity (plugin->api->cls, - GNUNET_ntohll (msg->offset), - type, &transmit_item, client); + GNUNET_ntohll (msg->offset), type, + &transmit_item, client); } @@ -1163,13 +1123,9 @@ handle_get_zero_anonymity (void *cls, * in to be deleted (by returning GNUNET_NO). */ static int -remove_callback (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +remove_callback (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct GNUNET_SERVER_Client *client = cls; @@ -1207,8 +1163,7 @@ remove_callback (void *cls, * @param message the actual message */ static void -handle_remove (void *cls, - struct GNUNET_SERVER_Client *client, +handle_remove (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct DataMessage *dm = check_data (message); @@ -1222,18 +1177,14 @@ handle_remove (void *cls, } #if DEBUG_DATASTORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' request for `%s' of type %u\n", - "REMOVE", GNUNET_h2s (&dm->key), ntohl (dm->type)); + "Processing `%s' request for `%s' of type %u\n", "REMOVE", + GNUNET_h2s (&dm->key), ntohl (dm->type)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# REMOVE requests received"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# REMOVE requests received"), 1, GNUNET_NO); GNUNET_SERVER_client_keep (client); GNUNET_CRYPTO_hash (&dm[1], ntohl (dm->size), &vhash); - plugin->api->get_key (plugin->api->cls, - 0, - &dm->key, - &vhash, + plugin->api->get_key (plugin->api->cls, 0, &dm->key, &vhash, (enum GNUNET_BLOCK_Type) ntohl (dm->type), &remove_callback, client); } @@ -1247,8 +1198,7 @@ handle_remove (void *cls, * @param message the actual message */ static void -handle_drop (void *cls, - struct GNUNET_SERVER_Client *client, +handle_drop (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { #if DEBUG_DATASTORE @@ -1298,9 +1248,8 @@ disk_utilization_change_cb (void *cls, int delta) * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -process_stat_in (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +process_stat_in (void *cls, const char *subsystem, const char *name, + uint64_t value, int is_persistent) { GNUNET_assert (stats_worked == GNUNET_NO); stats_worked = GNUNET_YES; @@ -1336,20 +1285,20 @@ load_plugin () char *name; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "DATASTORE", "DATABASE", &name)) + GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", + &name)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "DATABASE", "DATASTORE"); + _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", + "DATASTORE"); return NULL; } ret = GNUNET_malloc (sizeof (struct DatastorePlugin)); ret->env.cfg = cfg; ret->env.duc = &disk_utilization_change_cb; ret->env.cls = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' datastore plugin\n"), name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), + name); GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); ret->short_name = name; ret->lib_name = libname; @@ -1444,8 +1393,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_cancel (expired_kill_task); expired_kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (&unload_task, - NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&unload_task, NULL, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -1486,8 +1435,8 @@ cleanup_reservations (void *cls, struct GNUNET_SERVER_Client *client) } pos = next; } - GNUNET_STATISTICS_set (stats, - gettext_noop ("# reserved"), reserved, GNUNET_NO); + GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved, + GNUNET_NO); } @@ -1499,8 +1448,7 @@ cleanup_reservations (void *cls, struct GNUNET_SERVER_Client *client) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -1532,21 +1480,19 @@ run (void *cls, GNUNET_CONFIGURATION_get_value_number (cfg, "DATASTORE", "QUOTA", "a)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "QUOTA", "DATASTORE"); + _("No `%s' specified for `%s' in configuration!\n"), "QUOTA", + "DATASTORE"); return; } stats = GNUNET_STATISTICS_create ("datastore", cfg); GNUNET_STATISTICS_set (stats, gettext_noop ("# quota"), quota, GNUNET_NO); cache_size = quota / 8; /* Or should we make this an option? */ - GNUNET_STATISTICS_set (stats, - gettext_noop ("# cache size"), cache_size, GNUNET_NO); + GNUNET_STATISTICS_set (stats, gettext_noop ("# cache size"), cache_size, + GNUNET_NO); bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */ fn = NULL; if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "DATASTORE", - "BLOOMFILTER", + GNUNET_CONFIGURATION_get_value_filename (cfg, "DATASTORE", "BLOOMFILTER", &fn)) || (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn))) { @@ -1584,19 +1530,17 @@ run (void *cls, } return; } - stat_get = GNUNET_STATISTICS_get (stats, - "datastore", - QUOTA_STAT_NAME, - GNUNET_TIME_UNIT_SECONDS, - &process_stat_done, - &process_stat_in, plugin); + stat_get = + GNUNET_STATISTICS_get (stats, "datastore", QUOTA_STAT_NAME, + GNUNET_TIME_UNIT_SECONDS, &process_stat_done, + &process_stat_in, plugin); GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); GNUNET_SERVER_add_handlers (server, handlers); - expired_kill_task - = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, - &delete_expired, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleaning_task, NULL); + expired_kill_task = + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, + &delete_expired, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, + NULL); } @@ -1612,11 +1556,10 @@ main (int argc, char *const *argv) { int ret; - ret = (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "datastore", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "datastore", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; return ret; } diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 9d567aacd..cf9911329 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -104,8 +104,8 @@ struct CpsRunContext -static void -run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void run_continuation (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); @@ -138,8 +138,8 @@ check_success (void *cls, int success, const char *msg) else crc->phase = RP_CUT; } - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -172,14 +172,10 @@ remove_next (void *cls, int success, const char *msg) static void -delete_value (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +delete_value (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; @@ -191,11 +187,8 @@ delete_value (void *cls, if (stored_bytes < MAX_SIZE) crc->phase = RP_PUT; GNUNET_assert (NULL != - GNUNET_DATASTORE_remove (datastore, - key, - size, - data, - 1, 1, TIMEOUT, &remove_next, crc)); + GNUNET_DATASTORE_remove (datastore, key, size, data, 1, 1, + TIMEOUT, &remove_next, crc)); } @@ -228,12 +221,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) memset (data, i - 255, size / 2); data[0] = k; GNUNET_assert (NULL != - GNUNET_DATASTORE_put (datastore, - 0, - &key, - size, - data, - i + 1, + GNUNET_DATASTORE_put (datastore, 0, &key, size, data, i + 1, GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100), i, 0, @@ -247,9 +235,9 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) case RP_CUT: /* trim down below MAX_SIZE again */ GNUNET_assert (NULL != - GNUNET_DATASTORE_get_for_replication (datastore, - 1, 1, TIMEOUT, - &delete_value, crc)); + GNUNET_DATASTORE_get_for_replication (datastore, 1, 1, + TIMEOUT, &delete_value, + crc)); break; case RP_REPORT: printf ( @@ -263,15 +251,13 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (start_time).rel_value)); crc->phase = RP_PUT; crc->j = 0; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case RP_DONE: GNUNET_snprintf (gstr, sizeof (gstr), "DATASTORE-%s", plugin_name); if ((crc->i == ITERATIONS) && (stored_ops > 0)) - GAUGER (gstr, - "PUT operation duration", + GAUGER (gstr, "PUT operation duration", GNUNET_TIME_absolute_get_duration (start_time).rel_value / stored_ops, "ms/operation"); GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); @@ -302,15 +288,14 @@ run_tests (void *cls, int success, const char *msg) GNUNET_free (crc); return; } - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; static GNUNET_HashCode zkey; @@ -321,10 +306,8 @@ run (void *cls, crc->cfg = cfg; crc->phase = RP_PUT; if (NULL == - GNUNET_DATASTORE_put (datastore, 0, - &zkey, 4, "TEST", - GNUNET_BLOCK_TYPE_TEST, - 0, 0, 0, + GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", + GNUNET_BLOCK_TYPE_TEST, 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), 0, 1, GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) @@ -355,19 +338,18 @@ check () GNUNET_GETOPT_OPTION_END }; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datastore_api_data_%s.conf", plugin_name); - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfg_name, NULL); + "-c", cfg_name, NULL); GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "perf-datastore-api", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "perf-datastore-api", "nohelp", options, &run, NULL); sleep (1); /* give datastore chance to process 'DROP' */ if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { @@ -398,9 +380,8 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (dir_name, - sizeof (dir_name), - "/tmp/test-gnunet-datastore-%s", plugin_name); + GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", + plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("perf-datastore-api", #if VERBOSE diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index f8a3705e4..1e2a29f14 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -149,14 +149,10 @@ static void test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); static int -iterate_zeros (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +iterate_zeros (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; int i; @@ -187,8 +183,7 @@ iterate_zeros (void *cls, (unsigned long long) (crc->end.abs_value - crc->start.abs_value), bc, crc->cnt); if (crc->cnt > 0) - GAUGER (category, - "Select random zero-anonymity item", + GAUGER (category, "Select random zero-anonymity item", (crc->end.abs_value - crc->start.abs_value) / crc->cnt, "ms/item"); memset (hits, 0, sizeof (hits)); @@ -202,13 +197,9 @@ iterate_zeros (void *cls, static int -expiration_get (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +expiration_get (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct CpsRunContext *crc = cls; @@ -234,8 +225,7 @@ expiration_get (void *cls, (unsigned long long) (crc->end.abs_value - crc->start.abs_value), bc, (unsigned int) PUT_10); if (crc->cnt > 0) - GAUGER (category, - "Selecting and deleting by expiration", + GAUGER (category, "Selecting and deleting by expiration", (crc->end.abs_value - crc->start.abs_value) / crc->cnt, "ms/item"); memset (hits, 0, sizeof (hits)); @@ -252,13 +242,9 @@ expiration_get (void *cls, static int -replication_get (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +replication_get (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct CpsRunContext *crc = cls; @@ -285,8 +271,7 @@ replication_get (void *cls, (unsigned long long) (crc->end.abs_value - crc->start.abs_value), bc, (unsigned int) PUT_10); if (crc->cnt > 0) - GAUGER (category, - "Selecting random item for replication", + GAUGER (category, "Selecting random item for replication", (crc->end.abs_value - crc->start.abs_value) / crc->cnt, "ms/item"); memset (hits, 0, sizeof (hits)); @@ -316,12 +301,12 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api, char *libname; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "DATASTORE", "DATABASE", &name)) + GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", + &name)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "DATABASE", "DATASTORE"); + _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", + "DATASTORE"); return; } GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); @@ -375,13 +360,11 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) putValue (crc->api, j, crc->i); crc->end = GNUNET_TIME_absolute_get (); { - printf ("%s took %llu ms for %llu items\n", - "Storing an item", + printf ("%s took %llu ms for %llu items\n", "Storing an item", (unsigned long long) (crc->end.abs_value - crc->start.abs_value), PUT_10); if (PUT_10 > 0) - GAUGER (category, - "Storing an item", + GAUGER (category, "Storing an item", (crc->end.abs_value - crc->start.abs_value) / PUT_10, "ms/item"); } @@ -394,8 +377,8 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) crc->api->get_replication (crc->api->cls, &replication_get, crc); break; case RP_ZA_GET: - crc->api->get_zero_anonymity (crc->api->cls, - crc->offset++, 1, &iterate_zeros, crc); + crc->api->get_zero_anonymity (crc->api->cls, crc->offset++, 1, + &iterate_zeros, crc); break; case RP_EXP_GET: crc->api->get_expiration (crc->api->cls, &expiration_get, crc); @@ -422,19 +405,19 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) char *libname; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "DATASTORE", "DATABASE", &name)) + GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", + &name)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "DATABASE", "DATASTORE"); + _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", + "DATASTORE"); return NULL; } env.cfg = cfg; env.duc = &disk_utilization_change_cb; env.cls = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' datastore plugin\n"), name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), + name); GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env))) { @@ -448,9 +431,8 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_DATASTORE_PluginFunctions *api; struct CpsRunContext *crc; @@ -490,12 +472,10 @@ check () }; GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name); - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "perf_plugin_datastore_data_%s.conf", plugin_name); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "perf-plugin-datastore", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "perf-plugin-datastore", "nohelp", options, &run, NULL); if (ok != 0) fprintf (stderr, "Missed some testcases: %u\n", ok); return ok; @@ -519,9 +499,8 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (dir_name, - sizeof (dir_name), - "/tmp/perf-gnunet-datastore-%s", plugin_name); + GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/perf-gnunet-datastore-%s", + plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("perf-plugin-datastore", #if VERBOSE diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index a9b039981..63b065b0c 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c @@ -314,8 +314,8 @@ get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg) GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Trying to use file `%s' for MySQL configuration.\n"), cnffile); - if ((0 != STAT (cnffile, &st)) || - (0 != ACCESS (cnffile, R_OK)) || (!S_ISREG (st.st_mode))) + if ((0 != STAT (cnffile, &st)) || (0 != ACCESS (cnffile, R_OK)) || + (!S_ISREG (st.st_mode))) { if (configured == GNUNET_YES) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -383,16 +383,16 @@ iopen (struct Plugin *plugin) reconnect = 0; mysql_options (plugin->dbf, MYSQL_OPT_RECONNECT, &reconnect); timeout = 120; /* in seconds */ - mysql_options (plugin->dbf, - MYSQL_OPT_CONNECT_TIMEOUT, (const void *) &timeout); + mysql_options (plugin->dbf, MYSQL_OPT_CONNECT_TIMEOUT, + (const void *) &timeout); mysql_options (plugin->dbf, MYSQL_SET_CHARSET_NAME, "UTF8"); timeout = 60; /* in seconds */ mysql_options (plugin->dbf, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout); mysql_options (plugin->dbf, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout); mysql_dbname = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (plugin->env->cfg, - "datastore-mysql", - "DATABASE")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (plugin->env->cfg, "datastore-mysql", + "DATABASE")) GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, "datastore-mysql", @@ -401,8 +401,9 @@ iopen (struct Plugin *plugin) else mysql_dbname = GNUNET_strdup ("gnunet"); mysql_user = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (plugin->env->cfg, - "datastore-mysql", "USER")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (plugin->env->cfg, "datastore-mysql", + "USER")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, @@ -410,9 +411,9 @@ iopen (struct Plugin *plugin) "USER", &mysql_user)); } mysql_password = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (plugin->env->cfg, - "datastore-mysql", - "PASSWORD")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (plugin->env->cfg, "datastore-mysql", + "PASSWORD")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, @@ -421,8 +422,9 @@ iopen (struct Plugin *plugin) &mysql_password)); } mysql_server = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (plugin->env->cfg, - "datastore-mysql", "HOST")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (plugin->env->cfg, "datastore-mysql", + "HOST")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, @@ -431,8 +433,9 @@ iopen (struct Plugin *plugin) &mysql_server)); } mysql_port = 0; - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (plugin->env->cfg, - "datastore-mysql", "PORT")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (plugin->env->cfg, "datastore-mysql", + "PORT")) { GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (plugin->env->cfg, @@ -441,11 +444,9 @@ iopen (struct Plugin *plugin) } GNUNET_assert (mysql_dbname != NULL); - mysql_real_connect (plugin->dbf, - mysql_server, - mysql_user, mysql_password, - mysql_dbname, - (unsigned int) mysql_port, NULL, CLIENT_IGNORE_SIGPIPE); + mysql_real_connect (plugin->dbf, mysql_server, mysql_user, mysql_password, + mysql_dbname, (unsigned int) mysql_port, NULL, + CLIENT_IGNORE_SIGPIPE); GNUNET_free_non_null (mysql_server); GNUNET_free_non_null (mysql_user); GNUNET_free_non_null (mysql_password); @@ -524,8 +525,7 @@ prepare_statement (struct Plugin *plugin, } if (mysql_stmt_prepare (ret->statement, ret->query, strlen (ret->query))) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "mysql", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql", _("Failed to prepare statement `%s'\n"), ret->query); LOG_MYSQL (GNUNET_ERROR_TYPE_ERROR, "mysql_stmt_prepare", plugin); mysql_stmt_close (ret->statement); @@ -549,8 +549,8 @@ prepare_statement (struct Plugin *plugin, * @return GNUNET_SYSERR on error, GNUNET_OK on success */ static int -init_params (struct Plugin *plugin, - struct GNUNET_MysqlStatementHandle *s, va_list ap) +init_params (struct Plugin *plugin, struct GNUNET_MysqlStatementHandle *s, + va_list ap) { MYSQL_BIND qbind[MAX_PARAM]; unsigned int pc; @@ -611,8 +611,8 @@ init_params (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_param", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_bind_param", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -620,8 +620,8 @@ init_params (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' for `%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_execute", - s->query, __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_execute", s->query, __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -671,8 +671,8 @@ prepared_statement_run_select_va (struct Plugin *plugin, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_result", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_bind_result", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; } @@ -682,8 +682,7 @@ prepared_statement_run_select_va (struct Plugin *plugin, if (ret != 0) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_fetch", + _("`%s' failed at %s:%d with error: %s\n"), "mysql_stmt_fetch", __FILE__, __LINE__, mysql_stmt_error (s->statement)); iclose (plugin); return GNUNET_SYSERR; @@ -710,8 +709,8 @@ prepared_statement_run_select_va (struct Plugin *plugin, static int prepared_statement_run_select (struct Plugin *plugin, struct GNUNET_MysqlStatementHandle *s, - unsigned int result_size, - MYSQL_BIND * results, ...) + unsigned int result_size, MYSQL_BIND * results, + ...) { va_list ap; int ret; @@ -774,13 +773,12 @@ do_delete_entry (struct Plugin *plugin, unsigned long long uid) int ret; #if DEBUG_MYSQL - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Deleting value %llu from gn090 table\n", uid); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting value %llu from gn090 table\n", + uid); #endif - ret = prepared_statement_run (plugin, - plugin->delete_entry_by_uid, - NULL, - MYSQL_TYPE_LONGLONG, &uid, GNUNET_YES, -1); + ret = + prepared_statement_run (plugin, plugin->delete_entry_by_uid, NULL, + MYSQL_TYPE_LONGLONG, &uid, GNUNET_YES, -1); if (ret >= 0) return GNUNET_OK; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -831,14 +829,9 @@ mysql_plugin_estimate_size (void *cls) * @return GNUNET_OK on success */ static int -mysql_plugin_put (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - uint32_t replication, +mysql_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, char **msg) { struct Plugin *plugin = cls; @@ -864,9 +857,7 @@ mysql_plugin_put (void *cls, lsize = size; GNUNET_CRYPTO_hash (data, size, &vhash); if (GNUNET_OK != - prepared_statement_run (plugin, - plugin->insert_entry, - NULL, + prepared_statement_run (plugin, plugin->insert_entry, NULL, MYSQL_TYPE_LONG, &irepl, GNUNET_YES, MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONG, &ipriority, GNUNET_YES, @@ -912,9 +903,8 @@ mysql_plugin_put (void *cls, * @return GNUNET_OK on success */ static int -mysql_plugin_update (void *cls, - uint64_t uid, - int delta, struct GNUNET_TIME_Absolute expire, char **msg) +mysql_plugin_update (void *cls, uint64_t uid, int delta, + struct GNUNET_TIME_Absolute expire, char **msg) { struct Plugin *plugin = cls; unsigned long long vkey = uid; @@ -926,17 +916,16 @@ mysql_plugin_update (void *cls, "Updating value %llu adding %d to priority and maxing exp at %llu\n", vkey, delta, lexpire); #endif - ret = prepared_statement_run (plugin, - plugin->update_entry, - NULL, - MYSQL_TYPE_LONG, &delta, GNUNET_NO, - MYSQL_TYPE_LONGLONG, &lexpire, GNUNET_YES, - MYSQL_TYPE_LONGLONG, &lexpire, GNUNET_YES, - MYSQL_TYPE_LONGLONG, &vkey, GNUNET_YES, -1); + ret = + prepared_statement_run (plugin, plugin->update_entry, NULL, + MYSQL_TYPE_LONG, &delta, GNUNET_NO, + MYSQL_TYPE_LONGLONG, &lexpire, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &lexpire, GNUNET_YES, + MYSQL_TYPE_LONGLONG, &vkey, GNUNET_YES, -1); if (ret != GNUNET_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to update value %llu\n", vkey); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to update value %llu\n", + vkey); } return ret; } @@ -953,8 +942,7 @@ mysql_plugin_update (void *cls, * @param ... arguments to initialize stmt */ static void -execute_select (struct Plugin *plugin, - struct GNUNET_MysqlStatementHandle *stmt, +execute_select (struct Plugin *plugin, struct GNUNET_MysqlStatementHandle *stmt, PluginDatumProcessor proc, void *proc_cls, ...) { va_list ap; @@ -1020,8 +1008,9 @@ execute_select (struct Plugin *plugin, #endif GNUNET_assert (size < MAX_DATUM_SIZE); expiration.abs_value = exp; - ret = proc (proc_cls, - &key, size, value, type, priority, anonymity, expiration, uid); + ret = + proc (proc_cls, &key, size, value, type, priority, anonymity, expiration, + uid); if (ret == GNUNET_NO) { do_delete_entry (plugin, uid); @@ -1051,12 +1040,10 @@ execute_select (struct Plugin *plugin, * @param proc_cls closure for proc */ static void -mysql_plugin_get_key (void *cls, - uint64_t offset, - const GNUNET_HashCode * key, +mysql_plugin_get_key (void *cls, uint64_t offset, const GNUNET_HashCode * key, const GNUNET_HashCode * vhash, - enum GNUNET_BLOCK_Type type, - PluginDatumProcessor proc, void *proc_cls) + enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; int ret; @@ -1081,22 +1068,21 @@ mysql_plugin_get_key (void *cls, { ret = prepared_statement_run_select (plugin, - plugin-> - count_entry_by_hash_vhash_and_type, 1, - cbind, MYSQL_TYPE_BLOB, key, hashSize, - &hashSize, MYSQL_TYPE_BLOB, vhash, - hashSize2, &hashSize2, MYSQL_TYPE_LONG, - &type, GNUNET_YES, -1); + plugin->count_entry_by_hash_vhash_and_type, + 1, cbind, MYSQL_TYPE_BLOB, key, + hashSize, &hashSize, MYSQL_TYPE_BLOB, + vhash, hashSize2, &hashSize2, + MYSQL_TYPE_LONG, &type, GNUNET_YES, + -1); } else { ret = prepared_statement_run_select (plugin, plugin->count_entry_by_hash_and_type, - 1, cbind, - MYSQL_TYPE_BLOB, key, hashSize, - &hashSize, MYSQL_TYPE_LONG, &type, - GNUNET_YES, -1); + 1, cbind, MYSQL_TYPE_BLOB, key, + hashSize, &hashSize, MYSQL_TYPE_LONG, + &type, GNUNET_YES, -1); } } else @@ -1106,19 +1092,16 @@ mysql_plugin_get_key (void *cls, ret = prepared_statement_run_select (plugin, plugin->count_entry_by_hash_and_vhash, - 1, cbind, - MYSQL_TYPE_BLOB, key, hashSize, - &hashSize, MYSQL_TYPE_BLOB, vhash, - hashSize2, &hashSize2, -1); + 1, cbind, MYSQL_TYPE_BLOB, key, + hashSize, &hashSize, MYSQL_TYPE_BLOB, + vhash, hashSize2, &hashSize2, -1); } else { ret = - prepared_statement_run_select (plugin, - plugin->count_entry_by_hash, - 1, cbind, - MYSQL_TYPE_BLOB, key, hashSize, + prepared_statement_run_select (plugin, plugin->count_entry_by_hash, 1, + cbind, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, -1); } } @@ -1131,48 +1114,40 @@ mysql_plugin_get_key (void *cls, off = (unsigned long long) offset; #if DEBUG_MYSQL GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Obtaining %llu/%lld result for GET `%s'\n", - off, total, GNUNET_h2s (key)); + "Obtaining %llu/%lld result for GET `%s'\n", off, total, + GNUNET_h2s (key)); #endif if (type != GNUNET_BLOCK_TYPE_ANY) { if (NULL != vhash) { - execute_select (plugin, - plugin->select_entry_by_hash_vhash_and_type, - proc, proc_cls, - MYSQL_TYPE_BLOB, key, hashSize, &hashSize, + execute_select (plugin, plugin->select_entry_by_hash_vhash_and_type, proc, + proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, MYSQL_TYPE_BLOB, vhash, hashSize, &hashSize, - MYSQL_TYPE_LONG, &type, GNUNET_YES, - MYSQL_TYPE_LONGLONG, &off, GNUNET_YES, -1); + MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &off, GNUNET_YES, -1); } else { - execute_select (plugin, - plugin->select_entry_by_hash_and_type, - proc, proc_cls, - MYSQL_TYPE_BLOB, key, hashSize, &hashSize, - MYSQL_TYPE_LONG, &type, GNUNET_YES, - MYSQL_TYPE_LONGLONG, &off, GNUNET_YES, -1); + execute_select (plugin, plugin->select_entry_by_hash_and_type, proc, + proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, + MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &off, GNUNET_YES, -1); } } else { if (NULL != vhash) { - execute_select (plugin, - plugin->select_entry_by_hash_and_vhash, - proc, proc_cls, - MYSQL_TYPE_BLOB, key, hashSize, &hashSize, + execute_select (plugin, plugin->select_entry_by_hash_and_vhash, proc, + proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, MYSQL_TYPE_BLOB, vhash, hashSize, &hashSize, MYSQL_TYPE_LONGLONG, &off, GNUNET_YES, -1); } else { - execute_select (plugin, - plugin->select_entry_by_hash, - proc, proc_cls, + execute_select (plugin, plugin->select_entry_by_hash, proc, proc_cls, MYSQL_TYPE_BLOB, key, hashSize, &hashSize, MYSQL_TYPE_LONGLONG, &off, GNUNET_YES, -1); } @@ -1191,8 +1166,7 @@ mysql_plugin_get_key (void *cls, * @param proc_cls closure for iter */ static void -mysql_plugin_get_zero_anonymity (void *cls, - uint64_t offset, +mysql_plugin_get_zero_anonymity (void *cls, uint64_t offset, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) { @@ -1201,13 +1175,10 @@ mysql_plugin_get_zero_anonymity (void *cls, (unsigned long long) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); - execute_select (plugin, - plugin->zero_iter, - proc, proc_cls, - MYSQL_TYPE_LONG, &type, GNUNET_YES, - MYSQL_TYPE_LONGLONG, &rvalue, GNUNET_YES, - MYSQL_TYPE_LONG, &type, GNUNET_YES, - MYSQL_TYPE_LONGLONG, &rvalue, GNUNET_YES, -1); + execute_select (plugin, plugin->zero_iter, proc, proc_cls, MYSQL_TYPE_LONG, + &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, &rvalue, GNUNET_YES, + MYSQL_TYPE_LONG, &type, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &rvalue, GNUNET_YES, -1); } @@ -1255,14 +1226,10 @@ struct ReplCtx * GNUNET_NO to delete the item and continue (if supported) */ static int -repl_proc (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +repl_proc (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct ReplCtx *rc = cls; struct Plugin *plugin = rc->plugin; @@ -1270,15 +1237,15 @@ repl_proc (void *cls, int ret; int iret; - ret = rc->proc (rc->proc_cls, - key, size, data, type, priority, anonymity, expiration, uid); + ret = + rc->proc (rc->proc_cls, key, size, data, type, priority, anonymity, + expiration, uid); if (NULL != key) { oid = (unsigned long long) uid; - iret = prepared_statement_run (plugin, - plugin->dec_repl, - NULL, - MYSQL_TYPE_LONGLONG, &oid, GNUNET_YES, -1); + iret = + prepared_statement_run (plugin, plugin->dec_repl, NULL, + MYSQL_TYPE_LONGLONG, &oid, GNUNET_YES, -1); if (iret == GNUNET_SYSERR) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -1302,8 +1269,8 @@ repl_proc (void *cls, * @param proc_cls closure for proc */ static void -mysql_plugin_get_replication (void *cls, - PluginDatumProcessor proc, void *proc_cls) +mysql_plugin_get_replication (void *cls, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; struct ReplCtx rc; @@ -1382,26 +1349,22 @@ struct ExpiCtx * GNUNET_NO to delete the item and continue (if supported) */ static int -expi_proc (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +expi_proc (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct ExpiCtx *rc = cls; struct Plugin *plugin = rc->plugin; if (NULL == key) { - execute_select (plugin, - plugin->select_priority, rc->proc, rc->proc_cls, -1); + execute_select (plugin, plugin->select_priority, rc->proc, rc->proc_cls, + -1); return GNUNET_SYSERR; } - return rc->proc (rc->proc_cls, - key, size, data, type, priority, anonymity, expiration, uid); + return rc->proc (rc->proc_cls, key, size, data, type, priority, anonymity, + expiration, uid); } @@ -1414,8 +1377,8 @@ expi_proc (void *cls, * @param proc_cls closure for proc */ static void -mysql_plugin_get_expiration (void *cls, - PluginDatumProcessor proc, void *proc_cls) +mysql_plugin_get_expiration (void *cls, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; long long nt; @@ -1425,9 +1388,8 @@ mysql_plugin_get_expiration (void *cls, rc.proc = proc; rc.proc_cls = proc_cls; nt = (long long) GNUNET_TIME_absolute_get ().abs_value; - execute_select (plugin, - plugin->select_expiration, - expi_proc, &rc, MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES, -1); + execute_select (plugin, plugin->select_expiration, expi_proc, &rc, + MYSQL_TYPE_LONGLONG, &nt, GNUNET_YES, -1); } @@ -1473,28 +1435,25 @@ libgnunet_plugin_datastore_mysql_init (void *cls) } #define MRUNS(a) (GNUNET_OK != run_statement (plugin, a) ) #define PINIT(a,b) (NULL == (a = prepared_statement_create(plugin, b))) - if (MRUNS ("CREATE TABLE IF NOT EXISTS gn090 (" - " repl INT(11) UNSIGNED NOT NULL DEFAULT 0," - " type INT(11) UNSIGNED NOT NULL DEFAULT 0," - " prio INT(11) UNSIGNED NOT NULL DEFAULT 0," - " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0," - " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," - " rvalue BIGINT UNSIGNED NOT NULL," - " hash BINARY(64) NOT NULL DEFAULT ''," - " vhash BINARY(64) NOT NULL DEFAULT ''," - " value BLOB NOT NULL DEFAULT ''," - " uid BIGINT NOT NULL AUTO_INCREMENT," - " PRIMARY KEY (uid)," - " INDEX idx_hash (hash(64))," - " INDEX idx_hash_uid (hash(64),uid)," - " INDEX idx_hash_vhash (hash(64),vhash(64))," - " INDEX idx_hash_type_uid (hash(64),type,rvalue)," - " INDEX idx_prio (prio)," - " INDEX idx_repl_rvalue (repl,rvalue)," - " INDEX idx_expire (expire)," - " INDEX idx_anonLevel_type_rvalue (anonLevel,type,rvalue)" - ") ENGINE=InnoDB") || - MRUNS ("SET AUTOCOMMIT = 1") || + if (MRUNS + ("CREATE TABLE IF NOT EXISTS gn090 (" + " repl INT(11) UNSIGNED NOT NULL DEFAULT 0," + " type INT(11) UNSIGNED NOT NULL DEFAULT 0," + " prio INT(11) UNSIGNED NOT NULL DEFAULT 0," + " anonLevel INT(11) UNSIGNED NOT NULL DEFAULT 0," + " expire BIGINT UNSIGNED NOT NULL DEFAULT 0," + " rvalue BIGINT UNSIGNED NOT NULL," + " hash BINARY(64) NOT NULL DEFAULT ''," + " vhash BINARY(64) NOT NULL DEFAULT ''," + " value BLOB NOT NULL DEFAULT ''," " uid BIGINT NOT NULL AUTO_INCREMENT," + " PRIMARY KEY (uid)," " INDEX idx_hash (hash(64))," + " INDEX idx_hash_uid (hash(64),uid)," + " INDEX idx_hash_vhash (hash(64),vhash(64))," + " INDEX idx_hash_type_uid (hash(64),type,rvalue)," + " INDEX idx_prio (prio)," " INDEX idx_repl_rvalue (repl,rvalue)," + " INDEX idx_expire (expire)," + " INDEX idx_anonLevel_type_rvalue (anonLevel,type,rvalue)" + ") ENGINE=InnoDB") || MRUNS ("SET AUTOCOMMIT = 1") || PINIT (plugin->insert_entry, INSERT_ENTRY) || PINIT (plugin->delete_entry_by_uid, DELETE_ENTRY_BY_UID) || PINIT (plugin->select_entry_by_hash, SELECT_ENTRY_BY_HASH) || @@ -1537,8 +1496,8 @@ libgnunet_plugin_datastore_mysql_init (void *cls) api->get_expiration = &mysql_plugin_get_expiration; api->get_zero_anonymity = &mysql_plugin_get_zero_anonymity; api->drop = &mysql_plugin_drop; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "mysql", _("Mysql database running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "mysql", + _("Mysql database running\n")); return api; } diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index b79178dac..d71d5e0ef 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -75,9 +75,7 @@ struct Plugin * @return GNUNET_OK if the result is acceptable */ static int -check_result (struct Plugin *plugin, - PGresult * ret, - int expected_status, +check_result (struct Plugin *plugin, PGresult * ret, int expected_status, const char *command, const char *args, int line) { if (ret == NULL) @@ -92,9 +90,8 @@ check_result (struct Plugin *plugin, { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "datastore-postgres", - _("`%s:%s' failed at %s:%d with error: %s"), - command, args, __FILE__, line, - PQerrorMessage (plugin->dbh)); + _("`%s:%s' failed at %s:%d with error: %s"), command, args, + __FILE__, line, PQerrorMessage (plugin->dbh)); PQclear (ret); return GNUNET_SYSERR; } @@ -114,8 +111,8 @@ pq_exec (struct Plugin *plugin, const char *sql, int line) PGresult *ret; ret = PQexec (plugin->dbh, sql); - if (GNUNET_OK != check_result (plugin, - ret, PGRES_COMMAND_OK, "PQexec", sql, line)) + if (GNUNET_OK != + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexec", sql, line)) return GNUNET_SYSERR; PQclear (ret); return GNUNET_OK; @@ -132,8 +129,8 @@ pq_exec (struct Plugin *plugin, const char *sql, int line) * @return GNUNET_OK on success */ static int -pq_prepare (struct Plugin *plugin, - const char *name, const char *sql, int nparams, int line) +pq_prepare (struct Plugin *plugin, const char *name, const char *sql, + int nparams, int line) { PGresult *ret; @@ -160,8 +157,8 @@ init_connection (struct Plugin *plugin) /* Open database and precompile statements */ conninfo = NULL; (void) GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, - "datastore-postgres", - "CONFIG", &conninfo); + "datastore-postgres", "CONFIG", + &conninfo); plugin->dbh = PQconnectdb (conninfo == NULL ? "" : conninfo); if (NULL == plugin->dbh) { @@ -171,8 +168,7 @@ init_connection (struct Plugin *plugin) } if (PQstatus (plugin->dbh) != CONNECTION_OK) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "datastore-postgres", _ ("Unable to initialize Postgres with configuration `%s': %s"), conninfo, PQerrorMessage (plugin->dbh)); @@ -182,24 +178,23 @@ init_connection (struct Plugin *plugin) return GNUNET_SYSERR; } GNUNET_free_non_null (conninfo); - ret = PQexec (plugin->dbh, - "CREATE TABLE gn090 (" - " repl INTEGER NOT NULL DEFAULT 0," - " type INTEGER NOT NULL DEFAULT 0," - " prio INTEGER NOT NULL DEFAULT 0," - " anonLevel INTEGER NOT NULL DEFAULT 0," - " expire BIGINT NOT NULL DEFAULT 0," - " rvalue BIGINT NOT NULL DEFAULT 0," - " hash BYTEA NOT NULL DEFAULT ''," - " vhash BYTEA NOT NULL DEFAULT ''," - " value BYTEA NOT NULL DEFAULT '')" "WITH OIDS"); + ret = + PQexec (plugin->dbh, + "CREATE TABLE gn090 (" " repl INTEGER NOT NULL DEFAULT 0," + " type INTEGER NOT NULL DEFAULT 0," + " prio INTEGER NOT NULL DEFAULT 0," + " anonLevel INTEGER NOT NULL DEFAULT 0," + " expire BIGINT NOT NULL DEFAULT 0," + " rvalue BIGINT NOT NULL DEFAULT 0," + " hash BYTEA NOT NULL DEFAULT ''," + " vhash BYTEA NOT NULL DEFAULT ''," + " value BYTEA NOT NULL DEFAULT '')" "WITH OIDS"); if ((ret == NULL) || ((PQresultStatus (ret) != PGRES_COMMAND_OK) && (0 != strcmp ("42P07", /* duplicate table */ PQresultErrorField (ret, PG_DIAG_SQLSTATE))))) { - (void) check_result (plugin, - ret, PGRES_COMMAND_OK, "CREATE TABLE", "gn090", + (void) check_result (plugin, ret, PGRES_COMMAND_OK, "CREATE TABLE", "gn090", __LINE__); PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -211,12 +206,12 @@ init_connection (struct Plugin *plugin) pq_exec (plugin, "CREATE INDEX idx_hash ON gn090 (hash)", __LINE__)) || (GNUNET_OK != pq_exec (plugin, "CREATE INDEX idx_hash_vhash ON gn090 (hash,vhash)", - __LINE__)) - || (GNUNET_OK != - pq_exec (plugin, "CREATE INDEX idx_prio ON gn090 (prio)", __LINE__)) - || (GNUNET_OK != - pq_exec (plugin, "CREATE INDEX idx_expire ON gn090 (expire)", - __LINE__)) || + __LINE__)) || + (GNUNET_OK != + pq_exec (plugin, "CREATE INDEX idx_prio ON gn090 (prio)", __LINE__)) || + (GNUNET_OK != + pq_exec (plugin, "CREATE INDEX idx_expire ON gn090 (expire)", + __LINE__)) || (GNUNET_OK != pq_exec (plugin, "CREATE INDEX idx_prio_anon ON gn090 (prio,anonLevel)", @@ -239,11 +234,12 @@ init_connection (struct Plugin *plugin) } } PQclear (ret); - ret = PQexec (plugin->dbh, - "ALTER TABLE gn090 ALTER value SET STORAGE EXTERNAL"); + ret = + PQexec (plugin->dbh, + "ALTER TABLE gn090 ALTER value SET STORAGE EXTERNAL"); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", __LINE__)) + check_result (plugin, ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", + __LINE__)) { PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -252,8 +248,8 @@ init_connection (struct Plugin *plugin) PQclear (ret); ret = PQexec (plugin->dbh, "ALTER TABLE gn090 ALTER hash SET STORAGE PLAIN"); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", __LINE__)) + check_result (plugin, ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", + __LINE__)) { PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -262,8 +258,8 @@ init_connection (struct Plugin *plugin) PQclear (ret); ret = PQexec (plugin->dbh, "ALTER TABLE gn090 ALTER vhash SET STORAGE PLAIN"); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", __LINE__)) + check_result (plugin, ret, PGRES_COMMAND_OK, "ALTER TABLE", "gn090", + __LINE__)) { PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -271,86 +267,57 @@ init_connection (struct Plugin *plugin) } PQclear (ret); if ((GNUNET_OK != - pq_prepare (plugin, - "getvt", + pq_prepare (plugin, "getvt", "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " "WHERE hash=$1 AND vhash=$2 AND type=$3 " - "ORDER BY oid ASC LIMIT 1 OFFSET $4", - 4, - __LINE__)) || + "ORDER BY oid ASC LIMIT 1 OFFSET $4", 4, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "gett", + pq_prepare (plugin, "gett", "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " "WHERE hash=$1 AND type=$2 " - "ORDER BY oid ASC LIMIT 1 OFFSET $3", - 3, - __LINE__)) || + "ORDER BY oid ASC LIMIT 1 OFFSET $3", 3, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "getv", + pq_prepare (plugin, "getv", "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " "WHERE hash=$1 AND vhash=$2 " - "ORDER BY oid ASC LIMIT 1 OFFSET $3", - 3, - __LINE__)) || + "ORDER BY oid ASC LIMIT 1 OFFSET $3", 3, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "get", + pq_prepare (plugin, "get", "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " - "WHERE hash=$1 " - "ORDER BY oid ASC LIMIT 1 OFFSET $2", - 2, + "WHERE hash=$1 " "ORDER BY oid ASC LIMIT 1 OFFSET $2", 2, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "put", + pq_prepare (plugin, "put", "INSERT INTO gn090 (repl, type, prio, anonLevel, expire, rvalue, hash, vhash, value) " - "VALUES ($1, $2, $3, $4, $5, RANDOM(), $6, $7, $8)", - 9, + "VALUES ($1, $2, $3, $4, $5, RANDOM(), $6, $7, $8)", 9, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "update", + pq_prepare (plugin, "update", "UPDATE gn090 SET prio = prio + $1, expire = CASE WHEN expire < $2 THEN $2 ELSE expire END " - "WHERE oid = $3", - 3, - __LINE__)) || + "WHERE oid = $3", 3, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "decrepl", + pq_prepare (plugin, "decrepl", "UPDATE gn090 SET repl = GREATEST (repl - 1, 0) " - "WHERE oid = $1", - 1, - __LINE__)) || + "WHERE oid = $1", 1, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "select_non_anonymous", + pq_prepare (plugin, "select_non_anonymous", "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " "WHERE anonLevel = 0 AND type = $1 ORDER BY oid DESC LIMIT 1 OFFSET $2", - 1, - __LINE__)) || + 1, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "select_expiration_order", + pq_prepare (plugin, "select_expiration_order", "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " - "WHERE expire < $1 ORDER BY prio ASC LIMIT 1) " - "UNION " + "WHERE expire < $1 ORDER BY prio ASC LIMIT 1) " "UNION " "(SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " - "ORDER BY prio ASC LIMIT 1) " - "ORDER BY expire ASC LIMIT 1", - 1, - __LINE__)) || + "ORDER BY prio ASC LIMIT 1) " "ORDER BY expire ASC LIMIT 1", + 1, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "select_replication_order", + pq_prepare (plugin, "select_replication_order", "SELECT type, prio, anonLevel, expire, hash, value, oid FROM gn090 " - "ORDER BY repl DESC,RANDOM() LIMIT 1", - 0, - __LINE__)) || + "ORDER BY repl DESC,RANDOM() LIMIT 1", 0, __LINE__)) || (GNUNET_OK != - pq_prepare (plugin, - "delrow", "DELETE FROM gn090 " "WHERE oid=$1", 1, __LINE__))) + pq_prepare (plugin, "delrow", "DELETE FROM gn090 " "WHERE oid=$1", 1, + __LINE__))) { PQfinish (plugin->dbh); plugin->dbh = NULL; @@ -378,12 +345,11 @@ delete_by_rowid (struct Plugin *plugin, unsigned int rowid) PGresult *ret; browid = htonl (rowid); - ret = PQexecPrepared (plugin->dbh, - "delrow", - 1, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecPrepared (plugin->dbh, "delrow", 1, paramValues, paramLengths, + paramFormats, 1); if (GNUNET_OK != - check_result (plugin, - ret, PGRES_COMMAND_OK, "PQexecPrepared", "delrow", + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexecPrepared", "delrow", __LINE__)) { return GNUNET_SYSERR; @@ -407,18 +373,17 @@ postgres_plugin_estimate_size (void *cls) unsigned long long total; PGresult *ret; - ret = PQexecParams (plugin->dbh, - "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", - 0, NULL, NULL, NULL, NULL, 1); - if (GNUNET_OK != check_result (plugin, - ret, - PGRES_TUPLES_OK, - "PQexecParams", "get_size", __LINE__)) + ret = + PQexecParams (plugin->dbh, + "SELECT SUM(LENGTH(value))+256*COUNT(*) FROM gn090", 0, + NULL, NULL, NULL, NULL, 1); + if (GNUNET_OK != + check_result (plugin, ret, PGRES_TUPLES_OK, "PQexecParams", "get_size", + __LINE__)) { return 0; } - if ((PQntuples (ret) != 1) || - (PQnfields (ret) != 1) || + if ((PQntuples (ret) != 1) || (PQnfields (ret) != 1) || (PQgetlength (ret, 0, 0) != sizeof (unsigned long long))) { GNUNET_break (0); @@ -447,13 +412,9 @@ postgres_plugin_estimate_size (void *cls) * @return GNUNET_OK on success */ static int -postgres_plugin_put (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +postgres_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, char **msg) { @@ -489,17 +450,17 @@ postgres_plugin_put (void *cls, const int paramFormats[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; GNUNET_CRYPTO_hash (data, size, &vhash); - ret = PQexecPrepared (plugin->dbh, - "put", 8, paramValues, paramLengths, paramFormats, 1); - if (GNUNET_OK != check_result (plugin, ret, - PGRES_COMMAND_OK, - "PQexecPrepared", "put", __LINE__)) + ret = + PQexecPrepared (plugin->dbh, "put", 8, paramValues, paramLengths, + paramFormats, 1); + if (GNUNET_OK != + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexecPrepared", "put", + __LINE__)) return GNUNET_SYSERR; PQclear (ret); plugin->env->duc (plugin->env->cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD); #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres", "Stored %u bytes in database\n", (unsigned int) size); #endif return GNUNET_OK; @@ -517,9 +478,8 @@ postgres_plugin_put (void *cls, * @param line line number for error messages */ static void -process_result (struct Plugin *plugin, - PluginDatumProcessor proc, void *proc_cls, - PGresult * res, int line) +process_result (struct Plugin *plugin, PluginDatumProcessor proc, + void *proc_cls, PGresult * res, int line) { int iret; enum GNUNET_BLOCK_Type type; @@ -530,14 +490,12 @@ process_result (struct Plugin *plugin, struct GNUNET_TIME_Absolute expiration_time; GNUNET_HashCode key; - if (GNUNET_OK != check_result (plugin, - res, - PGRES_TUPLES_OK, - "PQexecPrepared", "select", line)) + if (GNUNET_OK != + check_result (plugin, res, PGRES_TUPLES_OK, "PQexecPrepared", "select", + line)) { #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres", "Ending iteration (postgres error)\n"); #endif proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); @@ -548,16 +506,14 @@ process_result (struct Plugin *plugin, { /* no result */ #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres", "Ending iteration (no more results)\n"); #endif proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); PQclear (res); return; } - if ((1 != PQntuples (res)) || - (7 != PQnfields (res)) || + if ((1 != PQntuples (res)) || (7 != PQnfields (res)) || (sizeof (uint32_t) != PQfsize (res, 0)) || (sizeof (uint32_t) != PQfsize (res, 6))) { @@ -588,17 +544,14 @@ process_result (struct Plugin *plugin, memcpy (&key, PQgetvalue (res, 0, 4), sizeof (GNUNET_HashCode)); size = PQgetlength (res, 0, 5); #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres", "Found result of size %u bytes and type %u in database\n", (unsigned int) size, (unsigned int) type); #endif - iret = proc (proc_cls, - &key, - size, - PQgetvalue (res, 0, 5), - (enum GNUNET_BLOCK_Type) type, - priority, anonymity, expiration_time, rowid); + iret = + proc (proc_cls, &key, size, PQgetvalue (res, 0, 5), + (enum GNUNET_BLOCK_Type) type, priority, anonymity, expiration_time, + rowid); PQclear (res); if (iret == GNUNET_NO) { @@ -609,16 +562,14 @@ process_result (struct Plugin *plugin, if (GNUNET_OK == delete_by_rowid (plugin, rowid)) { #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres", "Deleting %u bytes from database\n", (unsigned int) size); #endif plugin->env->duc (plugin->env->cls, -(size + GNUNET_DATASTORE_ENTRY_OVERHEAD)); #if DEBUG_POSTGRES - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "datastore-postgres", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "datastore-postgres", "Deleted %u bytes from database\n", (unsigned int) size); #endif } @@ -646,12 +597,11 @@ process_result (struct Plugin *plugin, * @param proc_cls closure for iter */ static void -postgres_plugin_get_key (void *cls, - uint64_t offset, +postgres_plugin_get_key (void *cls, uint64_t offset, const GNUNET_HashCode * key, const GNUNET_HashCode * vhash, - enum GNUNET_BLOCK_Type type, - PluginDatumProcessor proc, void *proc_cls) + enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; const int paramFormats[] = { 1, 1, 1, 1, 1 }; @@ -680,9 +630,10 @@ postgres_plugin_get_key (void *cls, paramLengths[3] = sizeof (blimit_off); nparams = 4; pname = "getvt"; - ret = PQexecParams (plugin->dbh, - "SELECT count(*) FROM gn090 WHERE hash=$1 AND vhash=$2 AND type=$3", - 3, NULL, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecParams (plugin->dbh, + "SELECT count(*) FROM gn090 WHERE hash=$1 AND vhash=$2 AND type=$3", + 3, NULL, paramValues, paramLengths, paramFormats, 1); } else { @@ -692,9 +643,10 @@ postgres_plugin_get_key (void *cls, paramLengths[2] = sizeof (blimit_off); nparams = 3; pname = "gett"; - ret = PQexecParams (plugin->dbh, - "SELECT count(*) FROM gn090 WHERE hash=$1 AND type=$2", - 2, NULL, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecParams (plugin->dbh, + "SELECT count(*) FROM gn090 WHERE hash=$1 AND type=$2", + 2, NULL, paramValues, paramLengths, paramFormats, 1); } } else @@ -707,9 +659,10 @@ postgres_plugin_get_key (void *cls, paramLengths[2] = sizeof (blimit_off); nparams = 3; pname = "getv"; - ret = PQexecParams (plugin->dbh, - "SELECT count(*) FROM gn090 WHERE hash=$1 AND vhash=$2", - 2, NULL, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecParams (plugin->dbh, + "SELECT count(*) FROM gn090 WHERE hash=$1 AND vhash=$2", + 2, NULL, paramValues, paramLengths, paramFormats, 1); } else { @@ -717,21 +670,19 @@ postgres_plugin_get_key (void *cls, paramLengths[1] = sizeof (blimit_off); nparams = 2; pname = "get"; - ret = PQexecParams (plugin->dbh, - "SELECT count(*) FROM gn090 WHERE hash=$1", - 1, NULL, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecParams (plugin->dbh, "SELECT count(*) FROM gn090 WHERE hash=$1", + 1, NULL, paramValues, paramLengths, paramFormats, 1); } } - if (GNUNET_OK != check_result (plugin, - ret, - PGRES_TUPLES_OK, - "PQexecParams", pname, __LINE__)) + if (GNUNET_OK != + check_result (plugin, ret, PGRES_TUPLES_OK, "PQexecParams", pname, + __LINE__)) { proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } - if ((PQntuples (ret) != 1) || - (PQnfields (ret) != 1) || + if ((PQntuples (ret) != 1) || (PQnfields (ret) != 1) || (PQgetlength (ret, 0, 0) != sizeof (unsigned long long))) { GNUNET_break (0); @@ -747,9 +698,9 @@ postgres_plugin_get_key (void *cls, return; } blimit_off = GNUNET_htonll (offset % total); - ret = PQexecPrepared (plugin->dbh, - pname, - nparams, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecPrepared (plugin->dbh, pname, nparams, paramValues, paramLengths, + paramFormats, 1); process_result (plugin, proc, proc_cls, ret, __LINE__); } @@ -766,8 +717,7 @@ postgres_plugin_get_key (void *cls, * @param proc_cls closure for proc */ static void -postgres_plugin_get_zero_anonymity (void *cls, - uint64_t offset, +postgres_plugin_get_zero_anonymity (void *cls, uint64_t offset, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) { @@ -781,9 +731,9 @@ postgres_plugin_get_zero_anonymity (void *cls, btype = htonl ((uint32_t) type); boff = GNUNET_htonll (offset); - ret = PQexecPrepared (plugin->dbh, - "select_non_anonymous", - 2, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecPrepared (plugin->dbh, "select_non_anonymous", 2, paramValues, + paramLengths, paramFormats, 1); process_result (plugin, proc, proc_cls, ret, __LINE__); } @@ -833,14 +783,10 @@ struct ReplCtx * GNUNET_NO to delete the item and continue (if supported) */ static int -repl_proc (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +repl_proc (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct ReplCtx *rc = cls; struct Plugin *plugin = rc->plugin; @@ -848,8 +794,9 @@ repl_proc (void *cls, PGresult *qret; uint32_t boid; - ret = rc->proc (rc->proc_cls, - key, size, data, type, priority, anonymity, expiration, uid); + ret = + rc->proc (rc->proc_cls, key, size, data, type, priority, anonymity, + expiration, uid); if (NULL != key) { boid = htonl ((uint32_t) uid); @@ -860,13 +807,12 @@ repl_proc (void *cls, sizeof (boid), }; const int paramFormats[] = { 1 }; - qret = PQexecPrepared (plugin->dbh, - "decrepl", - 1, paramValues, paramLengths, paramFormats, 1); - if (GNUNET_OK != check_result (plugin, - qret, - PGRES_COMMAND_OK, - "PQexecPrepared", "decrepl", __LINE__)) + qret = + PQexecPrepared (plugin->dbh, "decrepl", 1, paramValues, paramLengths, + paramFormats, 1); + if (GNUNET_OK != + check_result (plugin, qret, PGRES_COMMAND_OK, "PQexecPrepared", + "decrepl", __LINE__)) return GNUNET_SYSERR; PQclear (qret); } @@ -885,8 +831,8 @@ repl_proc (void *cls, * @param proc_cls closure for proc */ static void -postgres_plugin_get_replication (void *cls, - PluginDatumProcessor proc, void *proc_cls) +postgres_plugin_get_replication (void *cls, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; struct ReplCtx rc; @@ -895,8 +841,9 @@ postgres_plugin_get_replication (void *cls, rc.plugin = plugin; rc.proc = proc; rc.proc_cls = proc_cls; - ret = PQexecPrepared (plugin->dbh, - "select_replication_order", 0, NULL, NULL, NULL, 1); + ret = + PQexecPrepared (plugin->dbh, "select_replication_order", 0, NULL, NULL, + NULL, 1); process_result (plugin, &repl_proc, &rc, ret, __LINE__); } @@ -910,8 +857,8 @@ postgres_plugin_get_replication (void *cls, * @param proc_cls closure for proc */ static void -postgres_plugin_get_expiration (void *cls, - PluginDatumProcessor proc, void *proc_cls) +postgres_plugin_get_expiration (void *cls, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; uint64_t btime; @@ -921,9 +868,9 @@ postgres_plugin_get_expiration (void *cls, PGresult *ret; btime = GNUNET_htonll (GNUNET_TIME_absolute_get ().abs_value); - ret = PQexecPrepared (plugin->dbh, - "select_expiration_order", - 1, paramValues, paramLengths, paramFormats, 1); + ret = + PQexecPrepared (plugin->dbh, "select_expiration_order", 1, paramValues, + paramLengths, paramFormats, 1); process_result (plugin, proc, proc_cls, ret, __LINE__); } @@ -952,10 +899,8 @@ postgres_plugin_get_expiration (void *cls, * @return GNUNET_OK on success */ static int -postgres_plugin_update (void *cls, - uint64_t uid, - int delta, struct GNUNET_TIME_Absolute expire, - char **msg) +postgres_plugin_update (void *cls, uint64_t uid, int delta, + struct GNUNET_TIME_Absolute expire, char **msg) { struct Plugin *plugin = cls; PGresult *ret; @@ -975,13 +920,12 @@ postgres_plugin_update (void *cls, }; const int paramFormats[] = { 1, 1, 1 }; - ret = PQexecPrepared (plugin->dbh, - "update", - 3, paramValues, paramLengths, paramFormats, 1); - if (GNUNET_OK != check_result (plugin, - ret, - PGRES_COMMAND_OK, - "PQexecPrepared", "update", __LINE__)) + ret = + PQexecPrepared (plugin->dbh, "update", 3, paramValues, paramLengths, + paramFormats, 1); + if (GNUNET_OK != + check_result (plugin, ret, PGRES_COMMAND_OK, "PQexecPrepared", "update", + __LINE__)) return GNUNET_SYSERR; PQclear (ret); return GNUNET_OK; @@ -1030,8 +974,8 @@ libgnunet_plugin_datastore_postgres_init (void *cls) api->get_expiration = &postgres_plugin_get_expiration; api->get_zero_anonymity = &postgres_plugin_get_zero_anonymity; api->drop = &postgres_plugin_drop; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "datastore-postgres", _("Postgres database running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "datastore-postgres", + _("Postgres database running\n")); return api; } diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 075d31623..46486d933 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -144,12 +144,12 @@ sq_prepare (sqlite3 * dbh, const char *zSql, sqlite3_stmt ** ppStmt) char *dummy; int result; - result = sqlite3_prepare_v2 (dbh, - zSql, - strlen (zSql), ppStmt, (const char **) &dummy); + result = + sqlite3_prepare_v2 (dbh, zSql, strlen (zSql), ppStmt, + (const char **) &dummy); #if DEBUG_SQLITE && 0 - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", + "Prepared `%s' / %p: %d\n", zSql, *ppStmt, result); #endif return result; } @@ -165,8 +165,7 @@ create_indices (sqlite3 * dbh) { /* create indices */ if ((SQLITE_OK != - sqlite3_exec (dbh, - "CREATE INDEX IF NOT EXISTS idx_hash ON gn090 (hash)", + sqlite3_exec (dbh, "CREATE INDEX IF NOT EXISTS idx_hash ON gn090 (hash)", NULL, NULL, NULL)) || (SQLITE_OK != sqlite3_exec (dbh, @@ -232,12 +231,10 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, #endif if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "datastore-sqlite", + GNUNET_CONFIGURATION_get_value_filename (cfg, "datastore-sqlite", "FILENAME", &afsdir)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "sqlite", _ ("Option `%s' in section `%s' missing in configuration!\n"), "FILENAME", "datastore-sqlite"); @@ -255,8 +252,8 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, plugin->env->duc (plugin->env->cls, 0); } #ifdef ENABLE_NLS - plugin->fn = GNUNET_STRINGS_to_utf8 (afsdir, strlen (afsdir), - nl_langinfo (CODESET)); + plugin->fn = + GNUNET_STRINGS_to_utf8 (afsdir, strlen (afsdir), nl_langinfo (CODESET)); #else plugin->fn = GNUNET_STRINGS_to_utf8 (afsdir, strlen (afsdir), "UTF-8"); /* good luck */ #endif @@ -265,33 +262,32 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, /* Open database and precompile statements */ if (sqlite3_open (plugin->fn, &plugin->dbh) != SQLITE_OK) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "sqlite", _("Unable to initialize SQLite: %s.\n"), sqlite3_errmsg (plugin->dbh)); return GNUNET_SYSERR; } CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA temp_store=MEMORY", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL, + ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA synchronous=OFF", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA synchronous=OFF", NULL, NULL, + ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA legacy_file_format=OFF", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA legacy_file_format=OFF", NULL, NULL, + ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA auto_vacuum=INCREMENTAL", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA auto_vacuum=INCREMENTAL", NULL, + NULL, ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA locking_mode=EXCLUSIVE", NULL, NULL, + ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA count_changes=OFF", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA count_changes=OFF", NULL, NULL, + ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA page_size=4092", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA page_size=4092", NULL, NULL, + ENULL)); CHECK (SQLITE_OK == sqlite3_busy_timeout (plugin->dbh, BUSY_TIMEOUT_MS)); @@ -302,18 +298,14 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, "SELECT 1 FROM sqlite_master WHERE tbl_name = 'gn090'", &stmt)); if ((sqlite3_step (stmt) == SQLITE_DONE) && - (sqlite3_exec (plugin->dbh, - "CREATE TABLE gn090 (" - " repl INT4 NOT NULL DEFAULT 0," - " type INT4 NOT NULL DEFAULT 0," - " prio INT4 NOT NULL DEFAULT 0," - " anonLevel INT4 NOT NULL DEFAULT 0," - " expire INT8 NOT NULL DEFAULT 0," - " rvalue INT8 NOT NULL," - " hash TEXT NOT NULL DEFAULT ''," - " vhash TEXT NOT NULL DEFAULT ''," - " value BLOB NOT NULL DEFAULT '')", NULL, NULL, - NULL) != SQLITE_OK)) + (sqlite3_exec + (plugin->dbh, + "CREATE TABLE gn090 (" " repl INT4 NOT NULL DEFAULT 0," + " type INT4 NOT NULL DEFAULT 0," " prio INT4 NOT NULL DEFAULT 0," + " anonLevel INT4 NOT NULL DEFAULT 0," + " expire INT8 NOT NULL DEFAULT 0," " rvalue INT8 NOT NULL," + " hash TEXT NOT NULL DEFAULT ''," " vhash TEXT NOT NULL DEFAULT ''," + " value BLOB NOT NULL DEFAULT '')", NULL, NULL, NULL) != SQLITE_OK)) { LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec"); sqlite3_finalize (stmt); @@ -322,47 +314,49 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, sqlite3_finalize (stmt); create_indices (plugin->dbh); - if ((sq_prepare (plugin->dbh, - "UPDATE gn090 " - "SET prio = prio + ?, expire = MAX(expire,?) WHERE _ROWID_ = ?", - &plugin->updPrio) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "UPDATE gn090 " - "SET repl = MAX (0, repl - 1) WHERE _ROWID_ = ?", - &plugin->updRepl) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " - "FROM gn090 INDEXED BY idx_repl_rvalue " - "WHERE repl=?2 AND" - " (rvalue>=?1 OR" - " NOT EXISTS (SELECT 1 FROM gn090 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND rvalue>=?1 LIMIT 1))" - " ORDER BY rvalue ASC" - " LIMIT 1", - &plugin->selRepl) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "SELECT MAX(repl) " - "FROM gn090 INDEXED BY idx_repl_rvalue", - &plugin->maxRepl) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " - "FROM gn090 INDEXED BY idx_expire" - " WHERE NOT EXISTS (SELECT 1 FROM gn090 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) " - " ORDER BY expire ASC LIMIT 1", - &plugin->selExpi) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " - "FROM gn090 INDEXED BY idx_anon_type_hash " - "WHERE (anonLevel = 0 AND type=?1) " - "ORDER BY hash DESC LIMIT 1 OFFSET ?2", - &plugin->selZeroAnon) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "INSERT INTO gn090 (repl, type, prio, " - "anonLevel, expire, rvalue, hash, vhash, value) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", - &plugin->insertContent) != SQLITE_OK) || - (sq_prepare (plugin->dbh, - "DELETE FROM gn090 WHERE _ROWID_ = ?", - &plugin->delRow) != SQLITE_OK)) + if ((sq_prepare + (plugin->dbh, + "UPDATE gn090 " + "SET prio = prio + ?, expire = MAX(expire,?) WHERE _ROWID_ = ?", + &plugin->updPrio) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, + "UPDATE gn090 " "SET repl = MAX (0, repl - 1) WHERE _ROWID_ = ?", + &plugin->updRepl) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, + "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " + "FROM gn090 INDEXED BY idx_repl_rvalue " "WHERE repl=?2 AND" + " (rvalue>=?1 OR" + " NOT EXISTS (SELECT 1 FROM gn090 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND rvalue>=?1 LIMIT 1))" + " ORDER BY rvalue ASC" " LIMIT 1", + &plugin->selRepl) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, + "SELECT MAX(repl) " "FROM gn090 INDEXED BY idx_repl_rvalue", + &plugin->maxRepl) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, + "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " + "FROM gn090 INDEXED BY idx_expire" + " WHERE NOT EXISTS (SELECT 1 FROM gn090 WHERE expire < ?1 LIMIT 1) OR (expire < ?1) " + " ORDER BY expire ASC LIMIT 1", &plugin->selExpi) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, + "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " + "FROM gn090 INDEXED BY idx_anon_type_hash " + "WHERE (anonLevel = 0 AND type=?1) " + "ORDER BY hash DESC LIMIT 1 OFFSET ?2", + &plugin->selZeroAnon) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, + "INSERT INTO gn090 (repl, type, prio, " + "anonLevel, expire, rvalue, hash, vhash, value) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", + &plugin->insertContent) != SQLITE_OK) || + (sq_prepare + (plugin->dbh, "DELETE FROM gn090 WHERE _ROWID_ = ?", + &plugin->delRow) != SQLITE_OK)) { LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR, "precompiling"); return GNUNET_SYSERR; @@ -406,22 +400,20 @@ database_shutdown (struct Plugin *plugin) #if SQLITE_VERSION_NUMBER >= 3007000 if (result == SQLITE_BUSY) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite", _ ("Tried to close sqlite without finalizing all prepared statements.\n")); stmt = sqlite3_next_stmt (plugin->dbh, NULL); while (stmt != NULL) { #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", "Closing statement %p\n", stmt); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", + "Closing statement %p\n", stmt); #endif result = sqlite3_finalize (stmt); #if DEBUG_SQLITE if (result != SQLITE_OK) - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Failed to close statement %p: %d\n", stmt, result); #endif stmt = sqlite3_next_stmt (plugin->dbh, NULL); @@ -448,8 +440,7 @@ delete_by_rowid (struct Plugin *plugin, unsigned long long rid) { if (SQLITE_OK != sqlite3_bind_int64 (plugin->delRow, 1, rid)) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (plugin->delRow)) LOG_SQLITE (plugin, NULL, @@ -459,19 +450,17 @@ delete_by_rowid (struct Plugin *plugin, unsigned long long rid) } if (SQLITE_DONE != sqlite3_step (plugin->delRow)) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_step"); if (SQLITE_OK != sqlite3_reset (plugin->delRow)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); return GNUNET_SYSERR; } if (SQLITE_OK != sqlite3_reset (plugin->delRow)) - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); return GNUNET_OK; } @@ -492,14 +481,9 @@ delete_by_rowid (struct Plugin *plugin, unsigned long long rid) * @return GNUNET_OK on success */ static int -sqlite_plugin_put (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - uint32_t replication, +sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, char **msg) { struct Plugin *plugin = cls; @@ -512,12 +496,9 @@ sqlite_plugin_put (void *cls, if (size > MAX_ITEM_SIZE) return GNUNET_SYSERR; #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Storing in database block with type %u/key `%s'/priority %u/expiration in %llu ms (%lld).\n", - type, - GNUNET_h2s (key), - priority, + type, GNUNET_h2s (key), priority, (unsigned long long) GNUNET_TIME_absolute_get_remaining (expiration).rel_value, (long long) expiration.abs_value); @@ -536,13 +517,10 @@ sqlite_plugin_put (void *cls, SQLITE_TRANSIENT)) || (SQLITE_OK != sqlite3_bind_blob (stmt, 8, &vhash, sizeof (GNUNET_HashCode), - SQLITE_TRANSIENT)) - || (SQLITE_OK != - sqlite3_bind_blob (stmt, 9, data, size, SQLITE_TRANSIENT))) + SQLITE_TRANSIENT)) || + (SQLITE_OK != sqlite3_bind_blob (stmt, 9, data, size, SQLITE_TRANSIENT))) { - LOG_SQLITE (plugin, - msg, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, @@ -556,8 +534,7 @@ sqlite_plugin_put (void *cls, case SQLITE_DONE: plugin->env->duc (plugin->env->cls, size + GNUNET_DATASTORE_ENTRY_OVERHEAD); #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Stored new entry (%u bytes)\n", size + GNUNET_DATASTORE_ENTRY_OVERHEAD); #endif @@ -565,27 +542,24 @@ sqlite_plugin_put (void *cls, break; case SQLITE_BUSY: GNUNET_break (0); - LOG_SQLITE (plugin, msg, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); ret = GNUNET_SYSERR; break; default: - LOG_SQLITE (plugin, msg, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); database_shutdown (plugin); database_setup (plugin->env->cfg, plugin); return GNUNET_SYSERR; } if (SQLITE_OK != sqlite3_reset (stmt)) - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); return ret; } @@ -614,21 +588,17 @@ sqlite_plugin_put (void *cls, * @return GNUNET_OK on success */ static int -sqlite_plugin_update (void *cls, - uint64_t uid, - int delta, struct GNUNET_TIME_Absolute expire, char **msg) +sqlite_plugin_update (void *cls, uint64_t uid, int delta, + struct GNUNET_TIME_Absolute expire, char **msg) { struct Plugin *plugin = cls; int n; - if ((SQLITE_OK != - sqlite3_bind_int (plugin->updPrio, 1, delta)) || - (SQLITE_OK != - sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value)) || - (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 3, uid))) + if ((SQLITE_OK != sqlite3_bind_int (plugin->updPrio, 1, delta)) || + (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 2, expire.abs_value)) + || (SQLITE_OK != sqlite3_bind_int64 (plugin->updPrio, 3, uid))) { - LOG_SQLITE (plugin, msg, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (plugin->updPrio)) LOG_SQLITE (plugin, NULL, @@ -639,8 +609,7 @@ sqlite_plugin_update (void *cls, } n = sqlite3_step (plugin->updPrio); if (SQLITE_OK != sqlite3_reset (plugin->updPrio)) - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); switch (n) { @@ -650,13 +619,11 @@ sqlite_plugin_update (void *cls, #endif return GNUNET_OK; case SQLITE_BUSY: - LOG_SQLITE (plugin, msg, - GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); return GNUNET_NO; default: - LOG_SQLITE (plugin, msg, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, msg, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); return GNUNET_SYSERR; } @@ -673,8 +640,8 @@ sqlite_plugin_update (void *cls, * @param proc_cls closure for 'proc' */ static void -execute_get (struct Plugin *plugin, - sqlite3_stmt * stmt, PluginDatumProcessor proc, void *proc_cls) +execute_get (struct Plugin *plugin, sqlite3_stmt * stmt, + PluginDatumProcessor proc, void *proc_cls) { int n; struct GNUNET_TIME_Absolute expiration; @@ -690,14 +657,13 @@ execute_get (struct Plugin *plugin, rowid = sqlite3_column_int64 (stmt, 6); if (sqlite3_column_bytes (stmt, 4) != sizeof (GNUNET_HashCode)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "sqlite", _ ("Invalid data in database. Trying to fix (by deletion).\n")); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); if (GNUNET_OK == delete_by_rowid (plugin, rowid)) plugin->env->duc (plugin->env->cls, -(size + GNUNET_DATASTORE_ENTRY_OVERHEAD)); @@ -705,8 +671,7 @@ execute_get (struct Plugin *plugin, } expiration.abs_value = sqlite3_column_int64 (stmt, 3); #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Found reply in database with expiration %llu\n", (unsigned long long) expiration.abs_value); #endif @@ -718,8 +683,8 @@ execute_get (struct Plugin *plugin, expiration, rowid); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); if ((GNUNET_NO == ret) && (GNUNET_OK == delete_by_rowid (plugin, rowid))) plugin->env->duc (plugin->env->cls, -(size + GNUNET_DATASTORE_ENTRY_OVERHEAD)); @@ -728,29 +693,27 @@ execute_get (struct Plugin *plugin, /* database must be empty */ if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); break; case SQLITE_BUSY: case SQLITE_ERROR: case SQLITE_MISUSE: default: - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); GNUNET_break (0); database_shutdown (plugin); database_setup (plugin->env->cfg, plugin); break; } if (SQLITE_OK != sqlite3_reset (stmt)) - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); } @@ -770,8 +733,7 @@ execute_get (struct Plugin *plugin, * @param proc_cls closure for proc */ static void -sqlite_plugin_get_zero_anonymity (void *cls, - uint64_t offset, +sqlite_plugin_get_zero_anonymity (void *cls, uint64_t offset, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) { @@ -783,13 +745,12 @@ sqlite_plugin_get_zero_anonymity (void *cls, if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) || (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, offset))) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } @@ -816,12 +777,10 @@ sqlite_plugin_get_zero_anonymity (void *cls, * @param proc_cls closure for proc */ static void -sqlite_plugin_get_key (void *cls, - uint64_t offset, - const GNUNET_HashCode * key, +sqlite_plugin_get_key (void *cls, uint64_t offset, const GNUNET_HashCode * key, const GNUNET_HashCode * vhash, - enum GNUNET_BLOCK_Type type, - PluginDatumProcessor proc, void *proc_cls) + enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; int ret; @@ -839,18 +798,19 @@ sqlite_plugin_get_key (void *cls, type == 0 ? "" : " AND type=?"); if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite_prepare"); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } sqoff = 1; - ret = sqlite3_bind_blob (stmt, sqoff++, - key, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT); + ret = + sqlite3_bind_blob (stmt, sqoff++, key, sizeof (GNUNET_HashCode), + SQLITE_TRANSIENT); if ((vhash != NULL) && (ret == SQLITE_OK)) - ret = sqlite3_bind_blob (stmt, sqoff++, - vhash, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT); + ret = + sqlite3_bind_blob (stmt, sqoff++, vhash, sizeof (GNUNET_HashCode), + SQLITE_TRANSIENT); if ((type != 0) && (ret == SQLITE_OK)) ret = sqlite3_bind_int (stmt, sqoff++, type); if (SQLITE_OK != ret) @@ -863,8 +823,7 @@ sqlite_plugin_get_key (void *cls, ret = sqlite3_step (stmt); if (ret != SQLITE_ROW) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite_step"); sqlite3_finalize (stmt); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); @@ -888,29 +847,27 @@ sqlite_plugin_get_key (void *cls, type == 0 ? "" : " AND type=?"); if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite_prepare"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite_prepare"); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } sqoff = 1; - ret = sqlite3_bind_blob (stmt, - sqoff++, - key, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT); + ret = + sqlite3_bind_blob (stmt, sqoff++, key, sizeof (GNUNET_HashCode), + SQLITE_TRANSIENT); if ((vhash != NULL) && (ret == SQLITE_OK)) - ret = sqlite3_bind_blob (stmt, - sqoff++, - vhash, sizeof (GNUNET_HashCode), SQLITE_TRANSIENT); + ret = + sqlite3_bind_blob (stmt, sqoff++, vhash, sizeof (GNUNET_HashCode), + SQLITE_TRANSIENT); if ((type != 0) && (ret == SQLITE_OK)) ret = sqlite3_bind_int (stmt, sqoff++, type); if (ret == SQLITE_OK) ret = sqlite3_bind_int64 (stmt, sqoff++, limit_off); if (ret != SQLITE_OK) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite_bind"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite_bind"); proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } @@ -968,20 +925,17 @@ struct ReplCtx * GNUNET_NO to delete the item */ static int -repl_proc (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +repl_proc (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct ReplCtx *rc = cls; int ret; - ret = rc->proc (rc->proc_cls, - key, size, data, type, priority, anonymity, expiration, uid); + ret = + rc->proc (rc->proc_cls, key, size, data, type, priority, anonymity, + expiration, uid); if (key != NULL) { rc->uid = uid; @@ -1002,8 +956,8 @@ repl_proc (void *cls, * @param proc_cls closure for proc */ static void -sqlite_plugin_get_replication (void *cls, - PluginDatumProcessor proc, void *proc_cls) +sqlite_plugin_get_replication (void *cls, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; struct ReplCtx rc; @@ -1012,8 +966,7 @@ sqlite_plugin_get_replication (void *cls, sqlite3_stmt *stmt; #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Getting random block based on replication order.\n"); #endif rc.have_uid = GNUNET_NO; @@ -1024,23 +977,21 @@ sqlite_plugin_get_replication (void *cls, { if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); /* DB empty */ proc (proc_cls, NULL, 0, NULL, 0, 0, 0, GNUNET_TIME_UNIT_ZERO_ABS, 0); return; } repl = sqlite3_column_int (stmt, 0); if (SQLITE_OK != sqlite3_reset (stmt)) - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); stmt = plugin->selRepl; rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, rvalue)) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, @@ -1051,8 +1002,7 @@ sqlite_plugin_get_replication (void *cls, } if (SQLITE_OK != sqlite3_bind_int (stmt, 2, repl)) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, @@ -1071,18 +1021,18 @@ sqlite_plugin_get_replication (void *cls, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (plugin->updRepl)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); return; } if (SQLITE_DONE != sqlite3_step (plugin->updRepl)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_step"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_step"); if (SQLITE_OK != sqlite3_reset (plugin->updRepl)) LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); + GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "sqlite3_reset"); } } @@ -1097,24 +1047,22 @@ sqlite_plugin_get_replication (void *cls, * @param proc_cls closure for proc */ static void -sqlite_plugin_get_expiration (void *cls, - PluginDatumProcessor proc, void *proc_cls) +sqlite_plugin_get_expiration (void *cls, PluginDatumProcessor proc, + void *proc_cls) { struct Plugin *plugin = cls; sqlite3_stmt *stmt; struct GNUNET_TIME_Absolute now; #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Getting random block based on expiration and priority order.\n"); #endif now = GNUNET_TIME_absolute_get (); stmt = plugin->selExpi; if (SQLITE_OK != sqlite3_bind_int64 (stmt, 1, now.abs_value)) { - LOG_SQLITE (plugin, NULL, - GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "sqlite3_bind_XXXX"); if (SQLITE_OK != sqlite3_reset (stmt)) LOG_SQLITE (plugin, NULL, @@ -1162,16 +1110,15 @@ sqlite_plugin_estimate_size (void *cls) if (SQLITE_VERSION_NUMBER < 3006000) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "datastore-sqlite", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "datastore-sqlite", _ ("sqlite version to old to determine size, assuming zero\n")); return 0; } CHECK (SQLITE_OK == sqlite3_exec (plugin->dbh, "VACUUM", NULL, NULL, ENULL)); CHECK (SQLITE_OK == - sqlite3_exec (plugin->dbh, - "PRAGMA auto_vacuum=INCREMENTAL", NULL, NULL, ENULL)); + sqlite3_exec (plugin->dbh, "PRAGMA auto_vacuum=INCREMENTAL", NULL, + NULL, ENULL)); CHECK (SQLITE_OK == sq_prepare (plugin->dbh, "PRAGMA page_count", &stmt)); if (SQLITE_ROW == sqlite3_step (stmt)) pages = sqlite3_column_int64 (stmt, 0); @@ -1222,8 +1169,8 @@ libgnunet_plugin_datastore_sqlite_init (void *cls) api->get_expiration = &sqlite_plugin_get_expiration; api->get_zero_anonymity = &sqlite_plugin_get_zero_anonymity; api->drop = &sqlite_plugin_drop; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "sqlite", _("Sqlite database running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "sqlite", + _("Sqlite database running\n")); return api; } @@ -1242,16 +1189,16 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) struct Plugin *plugin = api->cls; #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", "sqlite plugin is done\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", + "sqlite plugin is done\n"); #endif fn = NULL; if (plugin->drop_on_shutdown) fn = GNUNET_strdup (plugin->fn); #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", "Shutting down database\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", + "Shutting down database\n"); #endif database_shutdown (plugin); plugin->env = NULL; @@ -1263,8 +1210,8 @@ libgnunet_plugin_datastore_sqlite_done (void *cls) GNUNET_free (fn); } #if DEBUG_SQLITE - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "sqlite", "sqlite plugin is finished\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", + "sqlite plugin is finished\n"); #endif return NULL; } diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c index 7ab469140..566155fb5 100644 --- a/src/datastore/plugin_datastore_template.c +++ b/src/datastore/plugin_datastore_template.c @@ -71,13 +71,9 @@ template_plugin_estimate_size (void *cls) * @return GNUNET_OK on success */ static int -template_plugin_put (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +template_plugin_put (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, char **msg) { @@ -106,12 +102,11 @@ template_plugin_put (void *cls, * @param proc_cls closure for proc */ static void -template_plugin_get_key (void *cls, - uint64_t offset, +template_plugin_get_key (void *cls, uint64_t offset, const GNUNET_HashCode * key, const GNUNET_HashCode * vhash, - enum GNUNET_BLOCK_Type type, - PluginDatumProcessor proc, void *proc_cls) + enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, + void *proc_cls) { GNUNET_break (0); } @@ -130,8 +125,8 @@ template_plugin_get_key (void *cls, * @param proc_cls closure for proc */ static void -template_plugin_get_replication (void *cls, - PluginDatumProcessor proc, void *proc_cls) +template_plugin_get_replication (void *cls, PluginDatumProcessor proc, + void *proc_cls) { GNUNET_break (0); } @@ -146,8 +141,8 @@ template_plugin_get_replication (void *cls, * @param proc_cls closure for proc */ static void -template_plugin_get_expiration (void *cls, - PluginDatumProcessor proc, void *proc_cls) +template_plugin_get_expiration (void *cls, PluginDatumProcessor proc, + void *proc_cls) { GNUNET_break (0); } @@ -177,9 +172,7 @@ template_plugin_get_expiration (void *cls, * @return GNUNET_OK on success */ static int -template_plugin_update (void *cls, - uint64_t uid, - int delta, +template_plugin_update (void *cls, uint64_t uid, int delta, struct GNUNET_TIME_Absolute expire, char **msg) { GNUNET_break (0); @@ -201,8 +194,7 @@ template_plugin_update (void *cls, * @param proc_cls closure for proc */ static void -template_plugin_get_zero_anonymity (void *cls, - uint64_t offset, +template_plugin_get_zero_anonymity (void *cls, uint64_t offset, enum GNUNET_BLOCK_Type type, PluginDatumProcessor proc, void *proc_cls) { @@ -245,8 +237,8 @@ libgnunet_plugin_datastore_template_init (void *cls) api->get_expiration = &template_plugin_get_expiration; api->get_zero_anonymity = &template_plugin_get_zero_anonymity; api->drop = &template_plugin_drop; - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "template", _("Template database running\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "template", + _("Template database running\n")); return api; } diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 39b7a1ae2..3dff4a588 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -134,8 +134,8 @@ struct CpsRunContext }; -static void -run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void run_continuation (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); static void @@ -146,14 +146,14 @@ check_success (void *cls, int success, const char *msg) if (GNUNET_OK != success) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Operation %d/%d not successfull: `%s'\n", - crc->phase, crc->i, msg); + "Operation %d/%d not successfull: `%s'\n", crc->phase, crc->i, + msg); crc->phase = RP_ERROR; } GNUNET_free_non_null (crc->data); crc->data = NULL; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -163,40 +163,33 @@ get_reserved (void *cls, int success, const char *msg) struct CpsRunContext *crc = cls; if (0 >= success) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Error obtaining reservation: `%s'\n", msg); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error obtaining reservation: `%s'\n", + msg); GNUNET_assert (0 < success); crc->rid = success; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -check_value (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +check_value (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; int i; i = crc->i; #if 0 + fprintf (stderr, "Check value got `%s' of size %u, type %d, expire %llu\n", + GNUNET_h2s (key), (unsigned int) size, type, + (unsigned long long) expiration.abs_value); fprintf (stderr, - "Check value got `%s' of size %u, type %d, expire %llu\n", - GNUNET_h2s (key), - (unsigned int) size, - type, (unsigned long long) expiration.abs_value); - fprintf (stderr, - "Check value iteration %d wants size %u, type %d, expire %llu\n", - i, - (unsigned int) get_size (i), - get_type (i), (unsigned long long) get_expiration (i).abs_value); + "Check value iteration %d wants size %u, type %d, expire %llu\n", i, + (unsigned int) get_size (i), get_type (i), + (unsigned long long) get_expiration (i).abs_value); #endif GNUNET_assert (size == get_size (i)); GNUNET_assert (0 == memcmp (data, get_data (i), size)); @@ -210,20 +203,16 @@ check_value (void *cls, crc->phase = RP_DEL; crc->i = ITERATIONS; } - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -delete_value (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +delete_value (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; @@ -234,39 +223,31 @@ delete_value (void *cls, crc->data = GNUNET_malloc (size); memcpy (crc->data, data, size); crc->phase = RP_DO_DEL; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -check_nothing (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +check_nothing (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; GNUNET_assert (key == NULL); if (crc->i == 0) crc->phase = RP_RESERVE; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -check_multiple (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +check_multiple (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct CpsRunContext *crc = cls; @@ -290,34 +271,30 @@ check_multiple (void *cls, } if (priority == get_priority (42)) crc->uid = uid; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -check_update (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +check_update (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; GNUNET_assert (key != NULL); - if ((anonymity == get_anonymity (42)) && - (size == get_size (42)) && (priority == get_priority (42) + 100)) + if ((anonymity == get_anonymity (42)) && (size == get_size (42)) && + (priority == get_priority (42) + 100)) crc->phase = RP_DONE; else { GNUNET_assert (size == get_size (43)); crc->offset++; } - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -334,21 +311,15 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { case RP_PUT: #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "PUT", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", + crc->i); #endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_put (datastore, - 0, - &crc->key, - get_size (crc->i), - get_data (crc->i), - get_type (crc->i), - get_priority (crc->i), - get_anonymity (crc->i), - 0, - get_expiration (crc->i), - 1, 1, TIMEOUT, &check_success, crc); + GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), + get_data (crc->i), get_type (crc->i), + get_priority (crc->i), get_anonymity (crc->i), 0, + get_expiration (crc->i), 1, 1, TIMEOUT, + &check_success, crc); crc->i++; if (crc->i == ITERATIONS) crc->phase = RP_GET; @@ -356,36 +327,31 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) case RP_GET: crc->i--; #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "GET", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", + crc->i); #endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_get_key (datastore, - crc->offset, - &crc->key, - get_type (crc->i), - 1, 1, TIMEOUT, &check_value, crc); + GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, + get_type (crc->i), 1, 1, TIMEOUT, &check_value, + crc); break; case RP_DEL: crc->i--; #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "DEL", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL", + crc->i); #endif crc->data = NULL; GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_assert (NULL != - GNUNET_DATASTORE_get_key (datastore, - crc->offset, - &crc->key, - get_type (crc->i), - 1, 1, TIMEOUT, + GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, + get_type (crc->i), 1, 1, TIMEOUT, &delete_value, crc)); break; case RP_DO_DEL: #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "DO_DEL", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DO_DEL", + crc->i); #endif if (crc->i == 0) { @@ -397,95 +363,63 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) crc->phase = RP_DEL; } GNUNET_assert (NULL != - GNUNET_DATASTORE_remove (datastore, - &crc->key, - crc->size, - crc->data, - 1, 1, TIMEOUT, + GNUNET_DATASTORE_remove (datastore, &crc->key, crc->size, + crc->data, 1, 1, TIMEOUT, &check_success, crc)); break; case RP_DELVALIDATE: crc->i--; #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "DEL-VALIDATE", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", + "DEL-VALIDATE", crc->i); #endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); GNUNET_assert (NULL != - GNUNET_DATASTORE_get_key (datastore, - crc->offset, - &crc->key, - get_type (crc->i), - 1, 1, TIMEOUT, + GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, + get_type (crc->i), 1, 1, TIMEOUT, &check_nothing, crc)); break; case RP_RESERVE: crc->phase = RP_PUT_MULTIPLE; - GNUNET_DATASTORE_reserve (datastore, - 128 * 1024, 2, 1, 1, TIMEOUT, &get_reserved, crc); + GNUNET_DATASTORE_reserve (datastore, 128 * 1024, 2, 1, 1, TIMEOUT, + &get_reserved, crc); break; case RP_PUT_MULTIPLE: crc->phase = RP_PUT_MULTIPLE_NEXT; - GNUNET_DATASTORE_put (datastore, - crc->rid, - &crc->key, - get_size (42), - get_data (42), - get_type (42), - get_priority (42), - get_anonymity (42), - 0, - get_expiration (42), - 1, 1, TIMEOUT, &check_success, crc); + GNUNET_DATASTORE_put (datastore, crc->rid, &crc->key, get_size (42), + get_data (42), get_type (42), get_priority (42), + get_anonymity (42), 0, get_expiration (42), 1, 1, + TIMEOUT, &check_success, crc); break; case RP_PUT_MULTIPLE_NEXT: crc->phase = RP_GET_MULTIPLE; - GNUNET_DATASTORE_put (datastore, - crc->rid, - &crc->key, - get_size (43), - get_data (43), - get_type (42), - get_priority (43), - get_anonymity (43), - 0, - get_expiration (43), - 1, 1, TIMEOUT, &check_success, crc); + GNUNET_DATASTORE_put (datastore, crc->rid, &crc->key, get_size (43), + get_data (43), get_type (42), get_priority (43), + get_anonymity (43), 0, get_expiration (43), 1, 1, + TIMEOUT, &check_success, crc); break; case RP_GET_MULTIPLE: GNUNET_assert (NULL != - GNUNET_DATASTORE_get_key (datastore, - crc->offset, - &crc->key, - get_type (42), - 1, 1, TIMEOUT, + GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, + get_type (42), 1, 1, TIMEOUT, &check_multiple, crc)); break; case RP_GET_MULTIPLE_NEXT: GNUNET_assert (NULL != - GNUNET_DATASTORE_get_key (datastore, - crc->offset, - &crc->key, - get_type (42), - 1, 1, TIMEOUT, + GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, + get_type (42), 1, 1, TIMEOUT, &check_multiple, crc)); break; case RP_UPDATE: GNUNET_assert (crc->uid > 0); crc->phase = RP_UPDATE_VALIDATE; - GNUNET_DATASTORE_update (datastore, - crc->uid, - 100, - get_expiration (42), - 1, 1, TIMEOUT, &check_success, crc); + GNUNET_DATASTORE_update (datastore, crc->uid, 100, get_expiration (42), 1, + 1, TIMEOUT, &check_success, crc); break; case RP_UPDATE_VALIDATE: GNUNET_assert (NULL != - GNUNET_DATASTORE_get_key (datastore, - crc->offset, - &crc->key, - get_type (42), - 1, 1, TIMEOUT, + GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, + get_type (42), 1, 1, TIMEOUT, &check_update, crc)); break; case RP_DONE: @@ -513,8 +447,7 @@ run_tests (void *cls, int32_t success, const char *msg) switch (success) { case GNUNET_YES: - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; case GNUNET_NO: @@ -534,9 +467,8 @@ run_tests (void *cls, int32_t success, const char *msg) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; static GNUNET_HashCode zkey; @@ -547,10 +479,8 @@ run (void *cls, now = GNUNET_TIME_absolute_get (); datastore = GNUNET_DATASTORE_connect (cfg); if (NULL == - GNUNET_DATASTORE_put (datastore, 0, - &zkey, 4, "TEST", - GNUNET_BLOCK_TYPE_TEST, - 0, 0, 0, + GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", + GNUNET_BLOCK_TYPE_TEST, 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), 0, 1, GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) @@ -582,21 +512,20 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datastore_api_data_%s.conf", plugin_name); #if START_DATASTORE - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfg_name, NULL); + "-c", cfg_name, NULL); #endif GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-datastore-api", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-datastore-api", "nohelp", options, &run, NULL); #if START_DATASTORE sleep (1); /* give datastore chance to receive 'DROP' request */ if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) @@ -630,9 +559,8 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (dir_name, - sizeof (dir_name), - "/tmp/test-gnunet-datastore-%s", plugin_name); + GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", + plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("test-datastore-api", #if VERBOSE diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index b2146a915..230b7eb67 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -117,8 +117,8 @@ struct CpsRunContext }; -static void -run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void run_continuation (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); static void @@ -131,20 +131,16 @@ check_success (void *cls, int success, const char *msg) GNUNET_assert (GNUNET_OK == success); GNUNET_free_non_null (crc->data); crc->data = NULL; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -check_value (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +check_value (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; int i; @@ -152,8 +148,7 @@ check_value (void *cls, if (NULL == key) { crc->phase = RP_GET_FAIL; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } @@ -168,28 +163,24 @@ check_value (void *cls, crc->i--; if (crc->i == 0) crc->phase = RP_DONE; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -check_nothing (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute expiration, uint64_t uid) +check_nothing (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, + uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, + uint64_t uid) { struct CpsRunContext *crc = cls; GNUNET_assert (key == NULL); if (0 == --crc->i) crc->phase = RP_DONE; - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -203,21 +194,15 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { case RP_PUT: #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "PUT", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", + crc->i); #endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_put (datastore, - 0, - &crc->key, - get_size (crc->i), - get_data (crc->i), - get_type (crc->i), - get_priority (crc->i), - get_anonymity (crc->i), - 0, - get_expiration (crc->i), - 1, 1, TIMEOUT, &check_success, crc); + GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), + get_data (crc->i), get_type (crc->i), + get_priority (crc->i), get_anonymity (crc->i), 0, + get_expiration (crc->i), 1, 1, TIMEOUT, + &check_success, crc); crc->i++; if (crc->i == ITERATIONS) { @@ -230,27 +215,23 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case RP_GET: #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "GET", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", + crc->i); #endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_get_key (datastore, - crc->offset++, - &crc->key, - get_type (crc->i), - 1, 1, TIMEOUT, &check_value, crc); + GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, + get_type (crc->i), 1, 1, TIMEOUT, &check_value, + crc); break; case RP_GET_FAIL: #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing `%s' number %u\n", "GET(f)", crc->i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET(f)", + crc->i); #endif GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_get_key (datastore, - crc->offset++, - &crc->key, - get_type (crc->i), - 1, 1, TIMEOUT, &check_nothing, crc); + GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, + get_type (crc->i), 1, 1, TIMEOUT, &check_nothing, + crc); break; case RP_DONE: GNUNET_assert (0 == crc->i); @@ -277,15 +258,14 @@ run_tests (void *cls, int success, const char *msg) GNUNET_free (crc); return; } - GNUNET_SCHEDULER_add_continuation (&run_continuation, - crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct CpsRunContext *crc; static GNUNET_HashCode zkey; @@ -296,10 +276,8 @@ run (void *cls, now = GNUNET_TIME_absolute_get (); datastore = GNUNET_DATASTORE_connect (cfg); if (NULL == - GNUNET_DATASTORE_put (datastore, 0, - &zkey, 4, "TEST", - GNUNET_BLOCK_TYPE_TEST, - 0, 0, 0, + GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", + GNUNET_BLOCK_TYPE_TEST, 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), 0, 1, GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) @@ -330,19 +308,19 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_datastore_api_data_%s.conf", plugin_name); - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfg_name, NULL); + "-c", cfg_name, NULL); GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-datastore-api-management", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-datastore-api-management", "nohelp", options, &run, + NULL); sleep (1); /* give datastore chance to process 'DROP' request */ if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { @@ -375,9 +353,8 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (dir_name, - sizeof (dir_name), - "/tmp/test-gnunet-datastore-%s", plugin_name); + GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", + plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("test-datastore-api-management", #if VERBOSE diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 15cca61f1..a34c4e38a 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c @@ -118,9 +118,8 @@ put_value (struct GNUNET_DATASTORE_PluginFunctions *api, int i, int k) msg = NULL; prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); #if VERBOSE - fprintf (stderr, - "putting type %u, anon %u under key %s\n", - i + 1, i, GNUNET_h2s (&key)); + fprintf (stderr, "putting type %u, anon %u under key %s\n", i + 1, i, + GNUNET_h2s (&key)); #endif if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ , prio, i /* anonymity */ , @@ -149,13 +148,9 @@ static uint64_t guid; static int -iterate_one_shot (void *cls, - const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +iterate_one_shot (void *cls, const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct CpsRunContext *crc = cls; @@ -166,8 +161,8 @@ iterate_one_shot (void *cls, #if VERBOSE fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", - type, priority, size, - (unsigned long long) expiration.abs_value, GNUNET_h2s (key)); + type, priority, size, (unsigned long long) expiration.abs_value, + GNUNET_h2s (key)); #endif GNUNET_SCHEDULER_add_now (&test, crc); return GNUNET_OK; @@ -189,12 +184,12 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api, char *libname; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "DATASTORE", "DATABASE", &name)) + GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", + &name)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "DATABASE", "DATASTORE"); + _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", + "DATASTORE"); return; } GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); @@ -265,15 +260,13 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; } gen_key (5, &key); - crc->api->get_key (crc->api->cls, - crc->offset++, - &key, NULL, + crc->api->get_key (crc->api->cls, crc->offset++, &key, NULL, GNUNET_BLOCK_TYPE_ANY, &iterate_one_shot, crc); break; case RP_UPDATE: GNUNET_assert (GNUNET_OK == - crc->api->update (crc->api->cls, - guid, 1, GNUNET_TIME_UNIT_ZERO_ABS, NULL)); + crc->api->update (crc->api->cls, guid, 1, + GNUNET_TIME_UNIT_ZERO_ABS, NULL)); crc->phase++; GNUNET_SCHEDULER_add_now (&test, crc); break; @@ -314,19 +307,19 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) char *libname; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "DATASTORE", "DATABASE", &name)) + GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", + &name)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("No `%s' specified for `%s' in configuration!\n"), - "DATABASE", "DATASTORE"); + _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", + "DATASTORE"); return NULL; } env.cfg = cfg; env.duc = &disk_utilization_change_cb; env.cls = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' datastore plugin\n"), name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), + name); GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env))) { @@ -340,9 +333,8 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_DATASTORE_PluginFunctions *api; struct CpsRunContext *crc; @@ -380,12 +372,10 @@ check () GNUNET_GETOPT_OPTION_END }; - GNUNET_snprintf (cfg_name, - sizeof (cfg_name), + GNUNET_snprintf (cfg_name, sizeof (cfg_name), "test_plugin_datastore_data_%s.conf", plugin_name); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-plugin-datastore", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-plugin-datastore", "nohelp", options, &run, NULL); if (ok != 0) fprintf (stderr, "Missed some testcases: %u\n", ok); return ok; @@ -409,8 +399,7 @@ main (int argc, char *argv[]) else pos = (char *) plugin_name; - GNUNET_snprintf (dir_name, - sizeof (dir_name), + GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); GNUNET_DISK_directory_remove (dir_name); GNUNET_log_setup ("test-plugin-datastore", diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 101751487..eded50efc 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c @@ -211,8 +211,8 @@ static size_t transmit_pending (void *cls, size_t size, void *buf); * a demultiplexer which handles numerous message types * */ -static void -service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg); +static void service_message_handler (void *cls, + const struct GNUNET_MessageHeader *msg); @@ -238,9 +238,8 @@ try_connect (struct GNUNET_DHT_Handle *handle) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting to process replies from DHT\n"); #endif - GNUNET_CLIENT_receive (handle->client, - &service_message_handler, - handle, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle, + GNUNET_TIME_UNIT_FOREVER_REL); return GNUNET_YES; } @@ -262,8 +261,8 @@ add_request_to_pending (void *cls, const GNUNET_HashCode * key, void *value) if (GNUNET_NO == rh->message->in_pending_queue) { - GNUNET_CONTAINER_DLL_insert (handle->pending_head, - handle->pending_tail, rh->message); + GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + rh->message); rh->message->in_pending_queue = GNUNET_YES; } return GNUNET_YES; @@ -321,9 +320,8 @@ do_disconnect (struct GNUNET_DHT_Handle *handle) GNUNET_assert (handle->reconnect_task == GNUNET_SCHEDULER_NO_TASK); GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO); handle->client = NULL; - handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->retry_time, - &try_reconnect, - handle); + handle->reconnect_task = + GNUNET_SCHEDULER_add_delayed (handle->retry_time, &try_reconnect, handle); } @@ -344,11 +342,12 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle) return; if (NULL == (head = handle->pending_head)) return; - handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, - ntohs (head->msg->size), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, - &transmit_pending, handle); + handle->th = + GNUNET_CLIENT_notify_transmit_ready (handle->client, + ntohs (head->msg->size), + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_YES, &transmit_pending, + handle); if (NULL == handle->th) { do_disconnect (handle); @@ -385,8 +384,8 @@ transmit_pending (void *cls, size_t size, void *buf) return 0; } memcpy (buf, head->msg, tsize); - GNUNET_CONTAINER_DLL_remove (handle->pending_head, - handle->pending_tail, head); + GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, + head); if (head->timeout_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (head->timeout_task); @@ -394,8 +393,7 @@ transmit_pending (void *cls, size_t size, void *buf) } if (NULL != head->cont) { - GNUNET_SCHEDULER_add_continuation (head->cont, - head->cont_cls, + GNUNET_SCHEDULER_add_continuation (head->cont, head->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); head->cont = NULL; head->cont_cls = NULL; @@ -514,13 +512,12 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_h2s (&dht_msg->key), GNUNET_CONTAINER_multihashmap_size (handle->active_requests)); GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests, - &dht_msg->key, - &process_reply, (void *) dht_msg); + &dht_msg->key, &process_reply, + (void *) dht_msg); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Continuing to process replies from DHT\n"); - GNUNET_CLIENT_receive (handle->client, - &service_message_handler, - handle, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -574,14 +571,13 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) } while (NULL != (pm = handle->pending_head)) { - GNUNET_CONTAINER_DLL_remove (handle->pending_head, - handle->pending_tail, pm); + GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, + pm); GNUNET_assert (GNUNET_YES == pm->free_on_send); if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task) GNUNET_SCHEDULER_cancel (pm->timeout_task); if (NULL != pm->cont) - GNUNET_SCHEDULER_add_continuation (pm->cont, - pm->cont_cls, + GNUNET_SCHEDULER_add_continuation (pm->cont, pm->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); pm->in_pending_queue = GNUNET_NO; GNUNET_free (pm); @@ -622,8 +618,8 @@ timeout_route_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } handle = pending->handle; - GNUNET_CONTAINER_DLL_remove (handle->pending_head, - handle->pending_tail, pending); + GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, + pending); if (pending->cont != NULL) pending->cont (pending->cont_cls, tc); GNUNET_free (pending); @@ -658,8 +654,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, enum GNUNET_DHT_RouteOption options, const struct GNUNET_MessageHeader *enc, struct GNUNET_TIME_Relative timeout, - GNUNET_DHT_ReplyProcessor iter, - void *iter_cls, + GNUNET_DHT_ReplyProcessor iter, void *iter_cls, GNUNET_SCHEDULER_Task cont, void *cont_cls) { struct PendingMessage *pending; @@ -702,8 +697,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, route_handle->dht_handle = handle; route_handle->uid = handle->uid_gen; route_handle->message = pending; - GNUNET_CONTAINER_multihashmap_put (handle->active_requests, - key, + GNUNET_CONTAINER_multihashmap_put (handle->active_requests, key, route_handle, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } @@ -711,12 +705,11 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, { route_handle = NULL; pending->free_on_send = GNUNET_YES; - pending->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &timeout_route_request, - pending); + pending->timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &timeout_route_request, pending); } - GNUNET_CONTAINER_DLL_insert (handle->pending_head, - handle->pending_tail, pending); + GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + pending); pending->in_pending_queue = GNUNET_YES; process_pending_messages (handle); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -755,21 +748,23 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle) pending->handle = handle; pending->free_on_send = GNUNET_YES; pending->in_pending_queue = GNUNET_YES; - GNUNET_CONTAINER_DLL_insert (handle->pending_head, - handle->pending_tail, pending); + GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + pending); process_pending_messages (handle); } else { /* simply remove pending request from message queue before * transmission, no need to transmit STOP request! */ - GNUNET_CONTAINER_DLL_remove (handle->pending_head, - handle->pending_tail, route_handle->message); + GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, + route_handle->message); } GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove - (route_handle->dht_handle->active_requests, &route_handle->key, - route_handle)); + GNUNET_CONTAINER_multihashmap_remove (route_handle-> + dht_handle-> + active_requests, + &route_handle->key, + route_handle)); GNUNET_free (route_handle->message); GNUNET_free (route_handle); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DHT route stop request processed\n"); @@ -790,16 +785,16 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle) * @param cont_cls closure for cont */ static void -send_control_message (struct GNUNET_DHT_Handle *handle, - uint16_t command, - uint16_t variable, - GNUNET_SCHEDULER_Task cont, void *cont_cls) +send_control_message (struct GNUNET_DHT_Handle *handle, uint16_t command, + uint16_t variable, GNUNET_SCHEDULER_Task cont, + void *cont_cls) { struct GNUNET_DHT_ControlMessage *msg; struct PendingMessage *pending; - pending = GNUNET_malloc (sizeof (struct PendingMessage) + - sizeof (struct GNUNET_DHT_ControlMessage)); + pending = + GNUNET_malloc (sizeof (struct PendingMessage) + + sizeof (struct GNUNET_DHT_ControlMessage)); msg = (struct GNUNET_DHT_ControlMessage *) &pending[1]; pending->msg = &msg->header; msg->header.size = htons (sizeof (struct GNUNET_DHT_ControlMessage)); @@ -810,8 +805,8 @@ send_control_message (struct GNUNET_DHT_Handle *handle, pending->cont = cont; pending->cont_cls = cont_cls; pending->in_pending_queue = GNUNET_YES; - GNUNET_CONTAINER_DLL_insert (handle->pending_head, - handle->pending_tail, pending); + GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + pending); process_pending_messages (handle); } @@ -831,8 +826,8 @@ void GNUNET_DHT_find_peers (struct GNUNET_DHT_Handle *handle, GNUNET_SCHEDULER_Task cont, void *cont_cls) { - send_control_message (handle, - GNUNET_MESSAGE_TYPE_DHT_FIND_PEER, 0, cont, cont_cls); + send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_FIND_PEER, 0, cont, + cont_cls); } @@ -858,8 +853,7 @@ GNUNET_DHT_set_malicious_getter (struct GNUNET_DHT_Handle *handle, GNUNET_break (0); return; } - send_control_message (handle, - GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET, + send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET, frequency.rel_value, cont, cont_cls); } @@ -883,8 +877,7 @@ GNUNET_DHT_set_malicious_putter (struct GNUNET_DHT_Handle *handle, return; } - send_control_message (handle, - GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT, + send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT, frequency.rel_value, cont, cont_cls); } @@ -902,9 +895,8 @@ void GNUNET_DHT_set_malicious_dropper (struct GNUNET_DHT_Handle *handle, GNUNET_SCHEDULER_Task cont, void *cont_cls) { - send_control_message (handle, - GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP, 0, - cont, cont_cls); + send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP, 0, cont, + cont_cls); } #endif diff --git a/src/dht/dht_api_find_peer.c b/src/dht/dht_api_find_peer.c index bcf1b50b7..a9ecc7b59 100644 --- a/src/dht/dht_api_find_peer.c +++ b/src/dht/dht_api_find_peer.c @@ -71,8 +71,7 @@ struct GNUNET_DHT_FindPeerHandle * @param reply response */ static void -find_peer_reply_iterator (void *cls, - const GNUNET_HashCode * key, +find_peer_reply_iterator (void *cls, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *outgoing_path, const struct GNUNET_MessageHeader *reply) @@ -127,12 +126,9 @@ GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *handle, htons (sizeof (struct GNUNET_DHT_FindPeerMessage)); find_peer_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER); find_peer_handle->route_handle = - GNUNET_DHT_route_start (handle, key, - 0, options, - &find_peer_msg.header, - timeout, - &find_peer_reply_iterator, find_peer_handle, - NULL, NULL); + GNUNET_DHT_route_start (handle, key, 0, options, &find_peer_msg.header, + timeout, &find_peer_reply_iterator, + find_peer_handle, NULL, NULL); GNUNET_break (find_peer_handle->route_handle != NULL); return find_peer_handle; } diff --git a/src/dht/dht_api_get_put.c b/src/dht/dht_api_get_put.c index 30b73e1f1..6b0bf1e26 100644 --- a/src/dht/dht_api_get_put.c +++ b/src/dht/dht_api_get_put.c @@ -52,16 +52,13 @@ * @return GNUNET_YES if put message is queued for transmission */ void -GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, - const GNUNET_HashCode * key, +GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, - enum GNUNET_BLOCK_Type type, - size_t size, - const char *data, + enum GNUNET_BLOCK_Type type, size_t size, const char *data, struct GNUNET_TIME_Absolute exp, - struct GNUNET_TIME_Relative timeout, - GNUNET_SCHEDULER_Task cont, void *cont_cls) + struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task cont, + void *cont_cls) { char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; struct GNUNET_DHT_PutMessage *put_msg; @@ -82,11 +79,9 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, (unsigned int) (sizeof (struct GNUNET_DHT_PutMessage) + size), "PUT", type); GNUNET_break (NULL == - GNUNET_DHT_route_start (handle, - key, - desired_replication_level, options, - &put_msg->header, - timeout, NULL, NULL, cont, cont_cls)); + GNUNET_DHT_route_start (handle, key, desired_replication_level, + options, &put_msg->header, timeout, + NULL, NULL, cont, cont_cls)); } @@ -126,8 +121,7 @@ struct GNUNET_DHT_GetHandle * @param reply response */ static void -get_reply_iterator (void *cls, - const GNUNET_HashCode * key, +get_reply_iterator (void *cls, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *outgoing_path, const struct GNUNET_MessageHeader *reply) { @@ -177,10 +171,9 @@ get_reply_iterator (void *cls, payload = ntohs (reply->size) - sizeof (struct GNUNET_DHT_GetResultMessage); get_handle->iter (get_handle->iter_cls, - GNUNET_TIME_absolute_ntoh (result->expiration), - key, - outgoing_path, - put_path, ntohs (result->type), payload, &result[1]); + GNUNET_TIME_absolute_ntoh (result->expiration), key, + outgoing_path, put_path, ntohs (result->type), payload, + &result[1]); GNUNET_free_non_null (put_path); } @@ -209,15 +202,13 @@ get_reply_iterator (void *cls, struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, struct GNUNET_TIME_Relative timeout, - enum GNUNET_BLOCK_Type type, - const GNUNET_HashCode * key, + enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const struct GNUNET_CONTAINER_BloomFilter *bf, - int32_t bf_mutator, - const void *xquery, - size_t xquery_size, - GNUNET_DHT_GetIterator iter, void *iter_cls) + int32_t bf_mutator, const void *xquery, + size_t xquery_size, GNUNET_DHT_GetIterator iter, + void *iter_cls) { struct GNUNET_DHT_GetHandle *get_handle; char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; @@ -237,8 +228,8 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, get_handle->iter_cls = iter_cls; get_msg = (struct GNUNET_DHT_GetMessage *) buf; get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET); - get_msg->header.size = htons (sizeof (struct GNUNET_DHT_GetMessage) + - xquery_size + bf_size); + get_msg->header.size = + htons (sizeof (struct GNUNET_DHT_GetMessage) + xquery_size + bf_size); get_msg->type = htonl ((uint32_t) type); get_msg->bf_mutator = bf_mutator; get_msg->xquery_size = htons ((uint16_t) xquery_size); diff --git a/src/dht/dhtlog.c b/src/dht/dhtlog.c index 7b9c05268..d56ba6469 100644 --- a/src/dht/dhtlog.c +++ b/src/dht/dhtlog.c @@ -50,11 +50,11 @@ GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c) plugin = GNUNET_malloc (sizeof (struct GNUNET_DHTLOG_Plugin)); plugin->cfg = c; if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (c, - "DHTLOG", "PLUGIN", &plugin_name)) + GNUNET_CONFIGURATION_get_value_string (c, "DHTLOG", "PLUGIN", + &plugin_name)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' dhtlog plugin\n"), plugin_name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' dhtlog plugin\n"), + plugin_name); GNUNET_asprintf (&libname, "libgnunet_plugin_dhtlog_%s", plugin_name); GNUNET_PLUGIN_load (libname, plugin); } diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index a5158fba5..d58e49e3b 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -850,8 +850,8 @@ update_meter (struct ProgressMeter *meter) fprintf (stdout, "%sProgress: [0%%", meter->startup_string); } else - fprintf (stdout, "%d%%", (int) (((float) meter->completed - / meter->total) * 100)); + fprintf (stdout, "%d%%", + (int) (((float) meter->completed / meter->total) * 100)); } else if (meter->completed % meter->dotnum == 0) fprintf (stdout, "."); @@ -922,10 +922,10 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_DHT_disconnect (test_put->dht_handle); test_put->dht_handle = NULL; if (replicate_same == GNUNET_NO) - test_put->daemon - = GNUNET_TESTING_daemon_get (pg, - GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); + test_put->daemon = + GNUNET_TESTING_daemon_get (pg, + GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); } /** @@ -1010,11 +1010,10 @@ log_topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, if ((first != NULL) && (second != NULL)) { - if ((topo_ctx->peers_seen != NULL) && (GNUNET_NO - == - GNUNET_CONTAINER_multihashmap_contains - (topo_ctx->peers_seen, - &first->hashPubKey))) + if ((topo_ctx->peers_seen != NULL) && + (GNUNET_NO == + GNUNET_CONTAINER_multihashmap_contains (topo_ctx->peers_seen, + &first->hashPubKey))) { GNUNET_CONTAINER_multihashmap_put (topo_ctx->peers_seen, &first->hashPubKey, NULL, @@ -1109,15 +1108,14 @@ stats_handle (void *cls, const struct GNUNET_PeerIdentity *peer, dhtlog_handle->add_generic_stat (peer, name, subsystem, value); if (GNUNET_CONTAINER_multihashmap_contains (stats_map, &peer->hashPubKey)) { - stats_ctx = GNUNET_CONTAINER_multihashmap_get (stats_map, - &peer->hashPubKey); + stats_ctx = + GNUNET_CONTAINER_multihashmap_get (stats_map, &peer->hashPubKey); } else { stats_ctx = GNUNET_malloc (sizeof (struct StatisticsIteratorContext)); stats_ctx->peer = peer; - GNUNET_CONTAINER_multihashmap_put (stats_map, &peer->hashPubKey, - stats_ctx, + GNUNET_CONTAINER_multihashmap_put (stats_map, &peer->hashPubKey, stats_ctx, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } GNUNET_assert (stats_ctx != NULL); @@ -1329,8 +1327,8 @@ send_find_peer_request (void *cls, { struct TestFindPeer *test_find_peer = cls; - if (test_find_peer->find_peer_context->outstanding - > max_outstanding_find_peers) + if (test_find_peer->find_peer_context->outstanding > + max_outstanding_find_peers) { GNUNET_SCHEDULER_add_delayed (find_peer_offset, &send_find_peer_request, test_find_peer); @@ -1345,8 +1343,8 @@ send_find_peer_request (void *cls, return; } - test_find_peer->dht_handle = GNUNET_DHT_connect (test_find_peer->daemon->cfg, - 1); + test_find_peer->dht_handle = + GNUNET_DHT_connect (test_find_peer->daemon->cfg, 1); GNUNET_assert (test_find_peer->dht_handle != NULL); GNUNET_DHT_find_peers (test_find_peer->dht_handle, &handle_find_peer_sent, test_find_peer); @@ -1365,12 +1363,12 @@ add_new_connection (struct FindPeerContext *find_peer_context, struct PeerCount *first_count; struct PeerCount *second_count; - if (GNUNET_CONTAINER_multihashmap_contains (find_peer_context->peer_hash, - &first->hashPubKey)) + if (GNUNET_CONTAINER_multihashmap_contains + (find_peer_context->peer_hash, &first->hashPubKey)) { - first_count - = GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, - &first->hashPubKey); + first_count = + GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, + &first->hashPubKey); GNUNET_assert (first_count != NULL); first_count->count++; GNUNET_CONTAINER_heap_update_cost (find_peer_context->peer_min_heap, @@ -1382,20 +1380,20 @@ add_new_connection (struct FindPeerContext *find_peer_context, first_count = GNUNET_malloc (sizeof (struct PeerCount)); first_count->count = 1; memcpy (&first_count->peer_id, first, sizeof (struct GNUNET_PeerIdentity)); - first_count->heap_node - = GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, - first_count, first_count->count); + first_count->heap_node = + GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, + first_count, first_count->count); GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, &first->hashPubKey, first_count, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } - if (GNUNET_CONTAINER_multihashmap_contains (find_peer_context->peer_hash, - &second->hashPubKey)) + if (GNUNET_CONTAINER_multihashmap_contains + (find_peer_context->peer_hash, &second->hashPubKey)) { - second_count - = GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, - &second->hashPubKey); + second_count = + GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, + &second->hashPubKey); GNUNET_assert (second_count != NULL); second_count->count++; GNUNET_CONTAINER_heap_update_cost (find_peer_context->peer_min_heap, @@ -1408,9 +1406,9 @@ add_new_connection (struct FindPeerContext *find_peer_context, second_count->count = 1; memcpy (&second_count->peer_id, second, sizeof (struct GNUNET_PeerIdentity)); - second_count->heap_node - = GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, - second_count, second_count->count); + second_count->heap_node = + GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, + second_count, second_count->count); GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, &second->hashPubKey, second_count, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); @@ -1456,19 +1454,19 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peer %s has 0 connections. Trying to connect to %s...\n", GNUNET_i2s (&peer_count->peer_id), d2->shortname); - timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - DEFAULT_CONNECT_TIMEOUT); - if (GNUNET_TIME_relative_to_absolute (timeout).abs_value - > find_peer_context->endtime.abs_value) + timeout = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + DEFAULT_CONNECT_TIMEOUT); + if (GNUNET_TIME_relative_to_absolute (timeout).abs_value > + find_peer_context->endtime.abs_value) { timeout = GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime); } - GNUNET_TESTING_daemons_connect (d1, d2, timeout, - DEFAULT_RECONNECT_ATTEMPTS, GNUNET_YES, - NULL, NULL); + GNUNET_TESTING_daemons_connect (d1, d2, timeout, DEFAULT_RECONNECT_ATTEMPTS, + GNUNET_YES, NULL, NULL); } - if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime).rel_value - > 0) + if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). + rel_value > 0) return GNUNET_YES; else return GNUNET_NO; @@ -1477,10 +1475,10 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, /** * Forward declaration. */ -static void -schedule_churn_find_peer_requests (void *cls, - const struct GNUNET_SCHEDULER_TaskContext - *tc); +static void schedule_churn_find_peer_requests (void *cls, + const struct + GNUNET_SCHEDULER_TaskContext + *tc); /** * Callback for iterating over all the peer connections of a peer group. @@ -1557,11 +1555,12 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Out of %u peers, fewest connections is %d\n", - GNUNET_CONTAINER_heap_get_size - (find_peer_context->peer_min_heap), peer_count->count); + GNUNET_CONTAINER_heap_get_size (find_peer_context-> + peer_min_heap), + peer_count->count); if ((peer_count->count == 0) && - (GNUNET_TIME_absolute_get_remaining - (find_peer_context->endtime).rel_value > 0)) + (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). + rel_value > 0)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); @@ -1571,9 +1570,8 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, find_peer_context); } - else if ((GNUNET_TIME_absolute_get_remaining - (find_peer_context->endtime).rel_value > 0) && - (find_peer_context->last_sent != 0)) + else if ((GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). + rel_value > 0) && (find_peer_context->last_sent != 0)) { GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, find_peer_context); @@ -1596,8 +1594,7 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, topo_ctx->cls = all_gets; topo_ctx->timeout = DEFAULT_GET_TIMEOUT; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, @@ -1609,8 +1606,7 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, } else { - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, @@ -1641,12 +1637,12 @@ schedule_churn_find_peer_requests (void *cls, if (find_peer_ctx->previous_peers == 0) /* First time, go slowly */ find_peer_ctx->total = 1; - else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers - < MIN_FIND_PEER_CUTOFF) + else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers < + MIN_FIND_PEER_CUTOFF) find_peer_ctx->total = find_peer_ctx->total / 2; else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers > MAX_FIND_PEER_CUTOFF) /* Found LOTS of peers, still go slowly */ - find_peer_ctx->total = find_peer_ctx->last_sent - (find_peer_ctx->last_sent - / 4); + find_peer_ctx->total = + find_peer_ctx->last_sent - (find_peer_ctx->last_sent / 4); else find_peer_ctx->total = find_peer_ctx->last_sent * 4; @@ -1659,8 +1655,8 @@ schedule_churn_find_peer_requests (void *cls, find_peer_ctx->total); if (find_peer_ctx->total > 0) - find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, - find_peer_ctx->total); + find_peer_offset = + GNUNET_TIME_relative_divide (find_peer_delay, find_peer_ctx->total); else { find_peer_ctx->previous_peers = find_peer_ctx->current_peers; @@ -1672,8 +1668,8 @@ schedule_churn_find_peer_requests (void *cls, { test_find_peer = GNUNET_malloc (sizeof (struct TestFindPeer)); /* If we have sent requests, choose peers with a low number of connections to send requests from */ - peer_count - = GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); + peer_count = + GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); GNUNET_assert (peer_count != NULL); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Sending find peer request from peer with %u connections\n", @@ -1681,8 +1677,8 @@ schedule_churn_find_peer_requests (void *cls, GNUNET_CONTAINER_multihashmap_remove (find_peer_ctx->peer_hash, &peer_count->peer_id.hashPubKey, peer_count); - test_find_peer->daemon - = GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); + test_find_peer->daemon = + GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); GNUNET_assert (test_find_peer->daemon != NULL); test_find_peer->find_peer_context = find_peer_ctx; GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply @@ -1690,12 +1686,12 @@ schedule_churn_find_peer_requests (void *cls, &send_find_peer_request, test_find_peer); } - if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap - == NULL)) + if ((find_peer_ctx->peer_hash == NULL) && + (find_peer_ctx->peer_min_heap == NULL)) { find_peer_ctx->peer_hash = GNUNET_CONTAINER_multihashmap_create (num_peers); - find_peer_ctx->peer_min_heap - = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); + find_peer_ctx->peer_min_heap = + GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); } else { @@ -1764,9 +1760,9 @@ churn_complete (void *cls, const char *emsg) memcpy (&peer_count->peer_id, &temp_daemon->id, sizeof (struct GNUNET_PeerIdentity)); GNUNET_assert (peer_count->count == 0); - peer_count->heap_node - = GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, - peer_count, peer_count->count); + peer_count->heap_node = + GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, + peer_count, peer_count->count); GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, &temp_daemon->id.hashPubKey, peer_count, @@ -1775,10 +1771,9 @@ churn_complete (void *cls, const char *emsg) } } GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Added %d peers to heap, total size %d\n", - count_added, - GNUNET_CONTAINER_heap_get_size - (find_peer_context->peer_min_heap)); + "Added %d peers to heap, total size %d\n", count_added, + GNUNET_CONTAINER_heap_get_size (find_peer_context-> + peer_min_heap)); GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); @@ -1794,33 +1789,33 @@ churn_complete (void *cls, const char *emsg) topo_ctx->cls = all_gets; topo_ctx->timeout = DEFAULT_GET_TIMEOUT; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); - calc_timeout = GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, - all_get_timeout); - calc_timeout - = GNUNET_TIME_relative_add (calc_timeout, - DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); - calc_timeout - = GNUNET_TIME_relative_add (calc_timeout, - DEFAULT_PEER_DISCONNECT_TIMEOUT); - die_task - = GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, - "from do gets (churn_complete)"); + calc_timeout = + GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, all_get_timeout); + calc_timeout = + GNUNET_TIME_relative_add (calc_timeout, + DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); + calc_timeout = + GNUNET_TIME_relative_add (calc_timeout, + DEFAULT_PEER_DISCONNECT_TIMEOUT); + die_task = + GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, + "from do gets (churn_complete)"); GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); dhtlog_handle->insert_round (DHT_ROUND_GET, rounds_finished); } else { - calc_timeout = GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, - all_get_timeout); - calc_timeout - = GNUNET_TIME_relative_add (calc_timeout, - DEFAULT_PEER_DISCONNECT_TIMEOUT); - die_task - = GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, - "from do gets (churn_complete)"); - GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, - &do_get, all_gets); + calc_timeout = + GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, all_get_timeout); + calc_timeout = + GNUNET_TIME_relative_add (calc_timeout, + DEFAULT_PEER_DISCONNECT_TIMEOUT); + die_task = + GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, + "from do gets (churn_complete)"); + GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, + all_gets); } } } @@ -1880,10 +1875,10 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) find_peer_context->previous_peers = 0; find_peer_context->current_peers = 0; find_peer_context->endtime = GNUNET_TIME_relative_to_absolute (timeout); - find_peer_context->peer_hash - = GNUNET_CONTAINER_multihashmap_create (num_peers); - find_peer_context->peer_min_heap - = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); + find_peer_context->peer_hash = + GNUNET_CONTAINER_multihashmap_create (num_peers); + find_peer_context->peer_min_heap = + GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); } GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "churn_peers: want %u total, %u running, starting %u, stopping %u\n", @@ -1914,12 +1909,12 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Reset the uid (which item to search for) and the daemon (which peer to search from) for later get request iterations */ if (get_from_same == GNUNET_NO) { - test_get->uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - num_puts); - test_get->daemon - = GNUNET_TESTING_daemon_get (pg, - GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); + test_get->uid = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_puts); + test_get->daemon = + GNUNET_TESTING_daemon_get (pg, + GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); } #if VERBOSE > 1 @@ -1986,8 +1981,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (dhtlog_handle != NULL) dhtlog_handle->insert_round (DHT_ROUND_GET, rounds_finished); - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_relative_add (GNUNET_TIME_relative_multiply @@ -2004,8 +1998,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (dhtlog_handle != NULL) dhtlog_handle->insert_round (DHT_ROUND_NORMAL, rounds_finished); - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, @@ -2133,21 +2126,18 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cumulative_num_gets++; /* Insert the data at the first peer */ - test_get->get_handle = GNUNET_DHT_get_start (test_get->dht_handle, get_delay, - GNUNET_BLOCK_TYPE_TEST, - &known_keys[test_get->uid], - get_replication, - GNUNET_DHT_RO_NONE, NULL, 0, - NULL, 0, &get_result_iterator, - test_get); + test_get->get_handle = + GNUNET_DHT_get_start (test_get->dht_handle, get_delay, + GNUNET_BLOCK_TYPE_TEST, &known_keys[test_get->uid], + get_replication, GNUNET_DHT_RO_NONE, NULL, 0, NULL, + 0, &get_result_iterator, test_get); #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", test_get->uid, test_get->daemon->shortname); #endif - test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed (get_timeout, - &get_stop_task, - test_get); + test_get->disconnect_task = + GNUNET_SCHEDULER_add_delayed (get_timeout, &get_stop_task, test_get); /* Schedule the next request in the linked list of get requests */ GNUNET_SCHEDULER_add_now (&do_get, test_get->next); @@ -2171,14 +2161,14 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Reset the daemon (which peer to insert at) for later put request iterations */ if (replicate_same == GNUNET_NO) - test_put->daemon - = GNUNET_TESTING_daemon_get (pg, - GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); + test_put->daemon = + GNUNET_TESTING_daemon_get (pg, + GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); GNUNET_SCHEDULER_cancel (test_put->disconnect_task); - test_put->disconnect_task = GNUNET_SCHEDULER_add_now (&put_disconnect_task, - test_put); + test_put->disconnect_task = + GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put); if (GNUNET_YES == update_meter (put_meter)) { GNUNET_assert (outstanding_puts == 0); @@ -2190,8 +2180,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) topo_ctx->cls = all_gets; topo_ctx->timeout = DEFAULT_GET_TIMEOUT; topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, all_get_timeout), @@ -2203,8 +2192,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { fprintf (stderr, "Scheduling die task (put finished)\n"); - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, all_get_timeout), &end_badly, @@ -2240,8 +2228,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) for (i = 0; i < sizeof (data); i++) { - memset (&data[i], GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX), 1); + memset (&data[i], + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX), + 1); } if (outstanding_puts > max_outstanding_puts) @@ -2264,23 +2253,23 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) put_replication, GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS, put_delay, &put_finished, test_put); - test_put->disconnect_task - = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), - &put_disconnect_task, test_put); + test_put->disconnect_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + &put_disconnect_task, test_put); rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, rand), &do_put, test_put->next); } -static void -schedule_find_peer_requests (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void schedule_find_peer_requests (void *cls, + const struct + GNUNET_SCHEDULER_TaskContext *tc); #if HAVE_MALICIOUS -static void -setup_malicious_peers (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void setup_malicious_peers (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); #endif /** @@ -2325,18 +2314,17 @@ count_peers_cb (void *cls, const struct GNUNET_PeerIdentity *first, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (target %u)\n", find_peer_context->current_peers, - find_peer_context->current_peers - - find_peer_context->previous_peers, + find_peer_context->current_peers - + find_peer_context->previous_peers, connection_estimate (num_peers, DEFAULT_BUCKET_SIZE), target_total_connections); - if ((find_peer_context->last_sent < 8) - || ((find_peer_context->current_peers < 2 - * connection_estimate (num_peers, DEFAULT_BUCKET_SIZE)) - && - (GNUNET_TIME_absolute_get_remaining - (find_peer_context->endtime).rel_value > 0) && - (find_peer_context->current_peers < target_total_connections))) + if ((find_peer_context->last_sent < 8) || + ((find_peer_context->current_peers < + 2 * connection_estimate (num_peers, DEFAULT_BUCKET_SIZE)) && + (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). + rel_value > 0) && + (find_peer_context->current_peers < target_total_connections))) { GNUNET_SCHEDULER_add_now (&schedule_find_peer_requests, find_peer_context); @@ -2381,8 +2369,8 @@ schedule_find_peer_requests (void *cls, if (find_peer_ctx->previous_peers == 0) /* First time, go slowly */ find_peer_ctx->total = 1; else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers > MAX_FIND_PEER_CUTOFF) /* Found LOTS of peers, still go slowly */ - find_peer_ctx->total = find_peer_ctx->last_sent - (find_peer_ctx->last_sent - / 8); + find_peer_ctx->total = + find_peer_ctx->last_sent - (find_peer_ctx->last_sent / 8); else find_peer_ctx->total = find_peer_ctx->last_sent * 2; @@ -2397,8 +2385,8 @@ schedule_find_peer_requests (void *cls, "Sending %u find peer messages (goal at least %u connections)\n", find_peer_ctx->total, target_total_connections); - find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, - find_peer_ctx->total); + find_peer_offset = + GNUNET_TIME_relative_divide (find_peer_delay, find_peer_ctx->total); for (i = 0; i < find_peer_ctx->total; i++) { test_find_peer = GNUNET_malloc (sizeof (struct TestFindPeer)); @@ -2418,9 +2406,10 @@ schedule_find_peer_requests (void *cls, * will be between 0 - 10, second between 10 - 20, etc. */ random = (num_peers / find_peer_ctx->total) * i; - random = random - + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - (num_peers / find_peer_ctx->total)); + random = + random + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + (num_peers / + find_peer_ctx->total)); if (random >= num_peers) { random = random - num_peers; @@ -2432,12 +2421,14 @@ schedule_find_peer_requests (void *cls, } else /* If we have sent requests, choose peers with a low number of connections to send requests from */ { - peer_count - = GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); + peer_count = + GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove - (find_peer_ctx->peer_hash, &peer_count->peer_id.hashPubKey, - peer_count)); + GNUNET_CONTAINER_multihashmap_remove (find_peer_ctx-> + peer_hash, + &peer_count->peer_id. + hashPubKey, + peer_count)); test_find_peer->daemon = GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); GNUNET_assert (test_find_peer->daemon != NULL); @@ -2449,12 +2440,12 @@ schedule_find_peer_requests (void *cls, &send_find_peer_request, test_find_peer); } - if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap - == NULL)) + if ((find_peer_ctx->peer_hash == NULL) && + (find_peer_ctx->peer_min_heap == NULL)) { find_peer_ctx->peer_hash = GNUNET_CONTAINER_multihashmap_create (num_peers); - find_peer_ctx->peer_min_heap - = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); + find_peer_ctx->peer_min_heap = + GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); } else { @@ -2521,20 +2512,20 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CRYPTO_hash_matching_bits (&known_keys[i], &sybil_target)); } - temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - num_peers); + temp_peer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); /* Don't start PUTs at malicious peers! */ if (malicious_bloom != NULL) { count = 0; hash_from_uid (temp_peer, &uid_hash); - while ((GNUNET_YES - == GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) - && (count < num_peers)) + while ((GNUNET_YES == + GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) && + (count < num_peers)) { - temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - num_peers); + temp_peer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); hash_from_uid (temp_peer, &uid_hash); test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); count++; @@ -2551,28 +2542,28 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) for (i = 0; i < num_gets; i++) { test_get = GNUNET_malloc (sizeof (struct TestGetContext)); - test_get->uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - num_puts); + test_get->uid = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_puts); #if REMEMBER while (remember[test_get->uid][temp_daemon] == 1) temp_daemon = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); remember[test_get->uid][temp_daemon] = 1; #endif - temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - num_peers); + temp_peer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); /* Don't start GETs at malicious peers! */ if (malicious_bloom != NULL) { hash_from_uid (temp_peer, &uid_hash); count = 0; - while ((GNUNET_YES - == GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) - && (count < num_peers)) + while ((GNUNET_YES == + GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) && + (count < num_peers)) { - temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - num_peers); + temp_peer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); hash_from_uid (temp_peer, &uid_hash); test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); count++; @@ -2586,8 +2577,7 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } /*GNUNET_SCHEDULER_cancel (die_task); */ - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, num_puts * 2), &end_badly, "from do puts"); @@ -2660,8 +2650,7 @@ continue_puts_and_gets (void *cls, "Scheduling find peer requests during \"settle\" time.\n"); find_peer_context = GNUNET_malloc (sizeof (struct FindPeerContext)); find_peer_context->count_peers_cb = &count_peers_cb; - find_peer_context->endtime - = + find_peer_context->endtime = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, settle_time)); @@ -2690,8 +2679,8 @@ malicious_disconnect_task (void *cls, ctx->dht_handle = NULL; GNUNET_free (ctx); - if (malicious_completed == malicious_getters + malicious_putters - + malicious_droppers) + if (malicious_completed == + malicious_getters + malicious_putters + malicious_droppers) { fprintf (stderr, "Finished setting all malicious peers up!\n"); } @@ -2757,9 +2746,9 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; } - ctx->disconnect_task - = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &malicious_disconnect_task, ctx); + ctx->disconnect_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &malicious_disconnect_task, ctx); } /** @@ -2890,16 +2879,17 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if ONLY_TESTING /* Forward declaration */ -static void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, - const struct GNUNET_CONFIGURATION_Handle *first_cfg, - const struct GNUNET_CONFIGURATION_Handle *second_cfg, - struct GNUNET_TESTING_Daemon *first_daemon, - struct GNUNET_TESTING_Daemon *second_daemon, - const char *emsg); +static void topology_callback (void *cls, + const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, + uint32_t distance, + const struct GNUNET_CONFIGURATION_Handle + *first_cfg, + const struct GNUNET_CONFIGURATION_Handle + *second_cfg, + struct GNUNET_TESTING_Daemon *first_daemon, + struct GNUNET_TESTING_Daemon *second_daemon, + const char *emsg); /** * Retry connecting two specific peers until they connect, @@ -2920,8 +2910,7 @@ repeat_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) repeat_connect_peer2->cfgfile); repeat_connect_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_TESTING_daemons_connect (repeat_connect_peer1, - repeat_connect_peer2, + GNUNET_TESTING_daemons_connect (repeat_connect_peer1, repeat_connect_peer2, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60), 2, &topology_callback, NULL); @@ -2989,9 +2978,9 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, } #endif - if (GNUNET_TIME_absolute_get_difference (connect_last_time, - GNUNET_TIME_absolute_get - ()).rel_value > + if (GNUNET_TIME_absolute_get_difference + (connect_last_time, + GNUNET_TIME_absolute_get ()).rel_value > GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, CONN_UPDATE_DURATION).rel_value) { @@ -3002,19 +2991,19 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, new_failed_connections = failed_connections - previous_failed_connections; /* Get duration in seconds */ - duration - = GNUNET_TIME_absolute_get_difference (connect_last_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; + duration = + GNUNET_TIME_absolute_get_difference (connect_last_time, + GNUNET_TIME_absolute_get ()). + rel_value / 1000; total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; + GNUNET_TIME_absolute_get ()). + rel_value / 1000; - failed_conns_per_sec_recent = (double) new_failed_connections - / (double) duration; - failed_conns_per_sec_total = (double) failed_connections - / (double) total_duration; + failed_conns_per_sec_recent = + (double) new_failed_connections / (double) duration; + failed_conns_per_sec_total = + (double) failed_connections / (double) total_duration; conns_per_sec_recent = (double) new_connections / (double) duration; conns_per_sec_total = (double) total_connections / (double) total_duration; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -3025,14 +3014,13 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, previous_connections = total_connections; previous_failed_connections = failed_connections; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "have %llu total_connections, %llu failed\n", - total_connections, failed_connections); + "have %llu total_connections, %llu failed\n", total_connections, + failed_connections); #if ONLY_TESTING /* These conditions likely mean we've entered the death spiral of doom */ - if ((total_connections > 20000) && - (conns_per_sec_recent < 5.0) && - (conns_per_sec_total > 10.0) && - (emsg != NULL) && (repeat_connect_mode == GNUNET_NO)) + if ((total_connections > 20000) && (conns_per_sec_recent < 5.0) && + (conns_per_sec_total > 10.0) && (emsg != NULL) && + (repeat_connect_mode == GNUNET_NO)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering repeat connection attempt mode!\n"); @@ -3096,10 +3084,10 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, dhtlog_handle->insert_topology (expected_connections); } - total_duration - = GNUNET_TIME_absolute_get_difference (connect_start_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; + total_duration = + GNUNET_TIME_absolute_get_difference (connect_start_time, + GNUNET_TIME_absolute_get ()). + rel_value / 1000; failed_conns_per_sec_total = (long double) failed_connections / total_duration; conns_per_sec_total = (long double) total_connections / total_duration; @@ -3162,9 +3150,9 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, else if (total_connections + failed_connections == expected_connections) { GNUNET_SCHEDULER_cancel (die_task); - die_task - = GNUNET_SCHEDULER_add_now (&end_badly, - "from topology_callback (too many failed connections)"); + die_task = + GNUNET_SCHEDULER_add_now (&end_badly, + "from topology_callback (too many failed connections)"); } } @@ -3200,8 +3188,7 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_asprintf (&revision_str, "%llu", revision); if (GNUNET_YES == insert_gauger_data) - GAUGER_ID ("DHT_TESTING", - "peer_startup_time", + GAUGER_ID ("DHT_TESTING", "peer_startup_time", GNUNET_TIME_absolute_get_duration (peer_start_time).rel_value / (double) num_peers, "ms/peer", revision_str); GNUNET_free (revision_str); @@ -3210,28 +3197,26 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, if ((pg != NULL) && (peers_left == 0)) { connect_start_time = GNUNET_TIME_absolute_get (); - expected_connections - = GNUNET_TESTING_connect_topology (pg, - connect_topology, - connect_topology_option, - connect_topology_option_modifier, - connect_timeout, - connect_attempts, NULL, NULL); - - peer_connect_meter = create_meter (expected_connections, - "Peer connection ", GNUNET_YES); + expected_connections = + GNUNET_TESTING_connect_topology (pg, connect_topology, + connect_topology_option, + connect_topology_option_modifier, + connect_timeout, connect_attempts, + NULL, NULL); + + peer_connect_meter = + create_meter (expected_connections, "Peer connection ", GNUNET_YES); fprintf (stderr, "Have %d expected connections\n", expected_connections); } if (expected_connections == 0) { - die_task - = GNUNET_SCHEDULER_add_now (&end_badly, - "from connect topology (bad return)"); + die_task = + GNUNET_SCHEDULER_add_now (&end_badly, + "from connect topology (bad return)"); } - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, DEFAULT_CONNECT_TIMEOUT * @@ -3248,9 +3233,9 @@ create_topology () unsigned int create_expected_connections; peers_left = num_peers; /* Reset counter */ - create_expected_connections - = GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, - blacklist_transports); + create_expected_connections = + GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, + blacklist_transports); if (create_expected_connections > 0) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -3262,13 +3247,13 @@ create_topology () else { GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_now (&end_badly, - "from create topology (bad return)"); + die_task = + GNUNET_SCHEDULER_add_now (&end_badly, + "from create topology (bad return)"); } GNUNET_free_non_null (blacklist_transports); GNUNET_SCHEDULER_cancel (die_task); - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (seconds_per_peer_start, num_peers), &end_badly, @@ -3297,8 +3282,8 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey (%d/%d) created for peer `%s'\n", - num_peers - peers_left, num_peers, GNUNET_i2s (id)); + "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, + num_peers, GNUNET_i2s (id)); #endif peers_left--; @@ -3310,22 +3295,18 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_asprintf (&revision_str, "%llu", revision); if (GNUNET_YES == insert_gauger_data) { - if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (config, "TESTING", - "HOSTKEYSFILE")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_have_value (config, "TESTING", "HOSTKEYSFILE")) { - GAUGER_ID ("DHT_TESTING", - "HOSTKEY_GENERATION", - GNUNET_TIME_absolute_get_duration - (hostkey_start_time).rel_value / (double) num_peers, - "ms/hostkey", revision_str); + GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION", + GNUNET_TIME_absolute_get_duration (hostkey_start_time). + rel_value / (double) num_peers, "ms/hostkey", revision_str); } else { - GAUGER_ID ("DHT_TESTING", - "HOSTKEY_GENERATION_REAL", - GNUNET_TIME_absolute_get_duration - (hostkey_start_time).rel_value / (double) num_peers, - "ms/hostkey", revision_str); + GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION_REAL", + GNUNET_TIME_absolute_get_duration (hostkey_start_time). + rel_value / (double) num_peers, "ms/hostkey", revision_str); } } @@ -3334,9 +3315,9 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT, - &end_badly, - "from create_topology"); + die_task = + GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT, &end_badly, + "from create_topology"); GNUNET_SCHEDULER_add_now (&create_topology, NULL); ok = 0; } @@ -3379,18 +3360,18 @@ run (void *cls, char *const *args, const char *cfgfile, rounds_finished = 0; memset (&trial_info, 0, sizeof (struct GNUNET_DHTLOG_TrialInfo)); /* Get path from configuration file */ - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "paths", - "servicehome", - &test_directory)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", + &test_directory)) { ok = 404; return; } /* Get number of peers to start from configuration */ - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "num_peers", - &num_peers)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", + &num_peers)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Number of peers must be specified in section %s option %s\n", @@ -3398,11 +3379,12 @@ run (void *cls, char *const *args, const char *cfgfile, } GNUNET_assert (num_peers > 0 && num_peers < ULONG_MAX); - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "connect_timeout", - &temp_config_number)) - connect_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout", + &temp_config_number)) + connect_timeout = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", @@ -3410,28 +3392,29 @@ run (void *cls, char *const *args, const char *cfgfile, return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "connect_attempts", - &connect_attempts)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts", + &connect_attempts)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts"); return; } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "max_outstanding_connections", - &max_outstanding_connections)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", + "max_outstanding_connections", + &max_outstanding_connections)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "max_concurrent_ssh", - &max_concurrent_ssh)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", + "max_concurrent_ssh", + &max_concurrent_ssh)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_concurrent_ssh"); @@ -3441,18 +3424,19 @@ run (void *cls, char *const *args, const char *cfgfile, /** * Get DHT specific testing options. */ - if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", - "mysql_logging")) - || (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", - "mysql_logging_extended")) - || (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", - "mysql_logging_minimal"))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", + "mysql_logging")) || + (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", + "mysql_logging_extended")) || + (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", + "mysql_logging_minimal"))) { - if (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", - "mysql_logging_minimal")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", + "mysql_logging_minimal")) dhtlog_minimal = GNUNET_YES; dhtlog_handle = GNUNET_DHTLOG_connect (cfg); @@ -3465,8 +3449,8 @@ run (void *cls, char *const *args, const char *cfgfile, } } - stop_closest = GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", - "stop_on_closest"); + stop_closest = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "stop_on_closest"); if (stop_closest == GNUNET_SYSERR) stop_closest = GNUNET_NO; @@ -3474,21 +3458,21 @@ run (void *cls, char *const *args, const char *cfgfile, if (stop_found == GNUNET_SYSERR) stop_found = GNUNET_NO; - strict_kademlia = GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", - "strict_kademlia"); + strict_kademlia = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "strict_kademlia"); if (strict_kademlia == GNUNET_SYSERR) strict_kademlia = GNUNET_NO; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", - "comment", - &trialmessage)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "comment", + &trialmessage)) trialmessage = NULL; churn_data = NULL; /** Check for a churn file to do churny simulation */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", - "churn_file", - &churn_filename)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "churn_file", + &churn_filename)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Reading churn data from %s\n", churn_filename); @@ -3511,8 +3495,8 @@ run (void *cls, char *const *args, const char *cfgfile, churn_data = GNUNET_malloc_large (frstat.st_size); GNUNET_assert (churn_data != NULL); - if (frstat.st_size != GNUNET_DISK_fn_read (churn_filename, churn_data, - frstat.st_size)) + if (frstat.st_size != + GNUNET_DISK_fn_read (churn_filename, churn_data, frstat.st_size)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not read file %s specified for churn, ending test!", @@ -3551,10 +3535,10 @@ run (void *cls, char *const *args, const char *cfgfile, } } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "churns_per_round", - &churns_per_round)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "churns_per_round", + &churns_per_round)) { churns_per_round = (unsigned long long) churn_rounds; } @@ -3570,8 +3554,7 @@ run (void *cls, char *const *args, const char *cfgfile, ret = sscanf (buf, "%u", &churn_array[line_number]); if (1 == ret) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Read %u peers in round %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Read %u peers in round %u\n", churn_array[line_number], line_number); line_number++; } @@ -3591,9 +3574,9 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_free_non_null (churn_data); /* Check for a hostfile containing user@host:port triples */ - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", - &hostfile)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", + &hostfile)) hostfile = NULL; hosts = NULL; @@ -3602,8 +3585,9 @@ run (void *cls, char *const *args, const char *cfgfile, if (hostfile != NULL) { if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) - GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_fn_write (hostfile, NULL, 0, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -3638,9 +3622,9 @@ run (void *cls, char *const *args, const char *cfgfile, { data[count] = '\0'; temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); - ret = sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", - &temphost->username, &temphost->hostname, - &temphost->port); + ret = + sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", + &temphost->username, &temphost->hostname, &temphost->port); if (3 == ret) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -3664,124 +3648,134 @@ run (void *cls, char *const *args, const char *cfgfile, } } GNUNET_free_non_null (data); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "malicious_getters", - &malicious_getters)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "malicious_getters", + &malicious_getters)) malicious_getters = 0; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "malicious_putters", - &malicious_putters)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "malicious_putters", + &malicious_putters)) malicious_putters = 0; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "malicious_droppers", - &malicious_droppers)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "malicious_droppers", + &malicious_droppers)) malicious_droppers = 0; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "settle_time", - &settle_time)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "settle_time", + &settle_time)) settle_time = 0; - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, - "dht_testing", - "num_puts", - &num_puts)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_puts", + &num_puts)) num_puts = num_peers; - if (GNUNET_SYSERR - == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "put_replication", - &put_replication)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "put_replication", + &put_replication)) put_replication = DEFAULT_PUT_REPLICATION; - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, - "dht_testing", - "num_gets", - &num_gets)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_gets", + &num_gets)) num_gets = num_peers; - if (GNUNET_SYSERR - == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "get_replication", - &get_replication)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "get_replication", + &get_replication)) get_replication = DEFAULT_GET_REPLICATION; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "find_peer_delay", - &temp_config_number)) - find_peer_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "find_peer_delay", + &temp_config_number)) + find_peer_delay = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else find_peer_delay = DEFAULT_FIND_PEER_DELAY; - if (GNUNET_OK - == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "concurrent_find_peers", - &temp_config_number)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "concurrent_find_peers", + &temp_config_number)) max_outstanding_find_peers = temp_config_number; else max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "get_timeout", - &temp_config_number)) - get_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "get_timeout", + &temp_config_number)) + get_timeout = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else get_timeout = DEFAULT_GET_TIMEOUT; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "concurrent_puts", - &temp_config_number)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "concurrent_puts", + &temp_config_number)) max_outstanding_puts = temp_config_number; else max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "concurrent_gets", - &temp_config_number)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "concurrent_gets", + &temp_config_number)) max_outstanding_gets = temp_config_number; else max_outstanding_gets = DEFAULT_MAX_OUTSTANDING_GETS; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "timeout", - &temp_config_number)) - all_get_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "timeout", + &temp_config_number)) + all_get_timeout = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else all_get_timeout.rel_value = get_timeout.rel_value * num_gets; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "get_delay", - &temp_config_number)) - get_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "get_delay", + &temp_config_number)) + get_delay = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else get_delay = DEFAULT_GET_DELAY; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "put_delay", - &temp_config_number)) - put_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "put_delay", + &temp_config_number)) + put_delay = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else put_delay = DEFAULT_PUT_DELAY; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "peer_start_timeout", - &temp_config_number)) - seconds_per_peer_start - = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "peer_start_timeout", + &temp_config_number)) + seconds_per_peer_start = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else seconds_per_peer_start = DEFAULT_SECONDS_PER_PEER_START; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "data_size", - &temp_config_number)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "data_size", + &temp_config_number)) test_data_size = temp_config_number; else test_data_size = DEFAULT_TEST_DATA_SIZE; @@ -3789,39 +3783,42 @@ run (void *cls, char *const *args, const char *cfgfile, /** * Get DHT testing related options. */ - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", - "REPLICATE_SAME")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", + "REPLICATE_SAME")) replicate_same = GNUNET_YES; - if (GNUNET_SYSERR - == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "target_completions", - &target_completions)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "target_completions", + &target_completions)) target_completions = 0; /* Not required, on stack */ - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", - "GET_FROM_SAME")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", + "GET_FROM_SAME")) get_from_same = GNUNET_YES; - if (GNUNET_NO - == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", - "MALICIOUS_GET_FREQUENCY", - &malicious_get_frequency)) + if (GNUNET_NO == + GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", + "MALICIOUS_GET_FREQUENCY", + &malicious_get_frequency)) malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; - if (GNUNET_NO - == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", - "MALICIOUS_PUT_FREQUENCY", - &malicious_put_frequency)) + if (GNUNET_NO == + GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", + "MALICIOUS_PUT_FREQUENCY", + &malicious_put_frequency)) malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; - if (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", - "MALICIOUS_AFTER_SETTLE")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", + "MALICIOUS_AFTER_SETTLE")) malicious_after_settle = GNUNET_YES; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", - "MALICIOUS_SYBIL")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", + "MALICIOUS_SYBIL")) { /* Set up the malicious target at random for this round */ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, @@ -3836,81 +3833,83 @@ run (void *cls, char *const *args, const char *cfgfile, while (1 << k < malicious_droppers) k++; if (malicious_droppers > 0) - malicious_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, 1 << k, - DHT_BLOOM_K); + malicious_bloom = + GNUNET_CONTAINER_bloomfilter_init (NULL, 1 << k, DHT_BLOOM_K); /* The normal behavior of the DHT is to do find peer requests * on its own. Only if this is explicitly turned off should * the testing driver issue find peer requests (even though * this is likely the default when testing). */ - if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", - "do_find_peer")) + if (GNUNET_NO == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "do_find_peer")) do_find_peer = GNUNET_YES; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", - "insert_gauger_data")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", + "insert_gauger_data")) insert_gauger_data = GNUNET_YES; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", - "republish")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "republish")) in_dht_replication = GNUNET_YES; - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", - "TRIAL_TO_RUN", - &trial_to_run)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", "TRIAL_TO_RUN", + &trial_to_run)) trial_to_run = 0; - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", - "REVISION", - &revision)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", "REVISION", + &revision)) revision = 0; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", - "FIND_PEER_DELAY", - &temp_config_number)) - find_peer_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - temp_config_number); + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", + "FIND_PEER_DELAY", + &temp_config_number)) + find_peer_delay = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + temp_config_number); else find_peer_delay = DEFAULT_FIND_PEER_DELAY; - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", - "ROUND_DELAY", - &round_delay)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", "ROUND_DELAY", + &round_delay)) round_delay = 0; - if (GNUNET_NO - == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", - "OUTSTANDING_FIND_PEERS", - &max_outstanding_find_peers)) + if (GNUNET_NO == + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", + "OUTSTANDING_FIND_PEERS", + &max_outstanding_find_peers)) max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", - "strict_kademlia")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "strict_kademlia")) max_outstanding_find_peers = max_outstanding_find_peers * 1; - find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, - max_outstanding_find_peers); + find_peer_offset = + GNUNET_TIME_relative_divide (find_peer_delay, max_outstanding_find_peers); - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, - "dht_testing", - "num_rounds", - &total_rounds)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_rounds", + &total_rounds)) total_rounds = 1; - if ((GNUNET_SYSERR - == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", - "target_total_connections", - &target_total_connections)) - || (target_total_connections == 0)) - target_total_connections = connection_estimate (num_peers, - DEFAULT_BUCKET_SIZE); + if ((GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", + "target_total_connections", + &target_total_connections)) || + (target_total_connections == 0)) + target_total_connections = + connection_estimate (num_peers, DEFAULT_BUCKET_SIZE); topology_str = NULL; - if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "topology", - &topology_str)) - && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", + &topology_str)) && + (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -3918,9 +3917,9 @@ run (void *cls, char *const *args, const char *cfgfile, topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", - &topology_percentage_str)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", + &topology_percentage_str)) topology_percentage = 0.5; else { @@ -3928,9 +3927,9 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_free (topology_percentage_str); } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", - &topology_probability_str)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", + &topology_probability_str)) topology_probability = 0.5; else { @@ -3938,12 +3937,12 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_free (topology_probability_str); } - if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "connect_topology", - &connect_topology_str)) - && (GNUNET_NO == GNUNET_TESTING_topology_get (&connect_topology, - connect_topology_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "connect_topology", + &connect_topology_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&connect_topology, connect_topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology `%s' given for section %s option %s\n", @@ -3951,13 +3950,13 @@ run (void *cls, char *const *args, const char *cfgfile, } GNUNET_free_non_null (connect_topology_str); - if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "connect_topology_option", - &connect_topology_option_str)) - && (GNUNET_NO - == GNUNET_TESTING_topology_option_get (&connect_topology_option, - connect_topology_option_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "connect_topology_option", + &connect_topology_option_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_option_get (&connect_topology_option, + connect_topology_option_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology option `%s' given for section %s option %s\n", @@ -3967,14 +3966,14 @@ run (void *cls, char *const *args, const char *cfgfile, } GNUNET_free_non_null (connect_topology_option_str); - if (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, - "testing", - "connect_topology_option_modifier", - &connect_topology_option_modifier_string)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "connect_topology_option_modifier", + &connect_topology_option_modifier_string)) { - if (sscanf (connect_topology_option_modifier_string, "%lf", - &connect_topology_option_modifier) != 1) + if (sscanf + (connect_topology_option_modifier_string, "%lf", + &connect_topology_option_modifier) != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -3985,18 +3984,19 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_free (connect_topology_option_modifier_string); } - if (GNUNET_YES - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "blacklist_transports", - &blacklist_transports)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "blacklist_transports", + &blacklist_transports)) blacklist_transports = NULL; - if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "blacklist_topology", - &blacklist_topology_str)) - && (GNUNET_NO == GNUNET_TESTING_topology_get (&blacklist_topology, - blacklist_topology_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "blacklist_topology", + &blacklist_topology_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&blacklist_topology, + blacklist_topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -4009,8 +4009,7 @@ run (void *cls, char *const *args, const char *cfgfile, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task - = + die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (seconds_per_peer_start, num_peers), &end_badly, @@ -4025,8 +4024,8 @@ run (void *cls, char *const *args, const char *cfgfile, trial_info.blacklist_topology = blacklist_topology; trial_info.connect_topology = connect_topology; trial_info.connect_topology_option = connect_topology_option; - trial_info.connect_topology_option_modifier - = connect_topology_option_modifier; + trial_info.connect_topology_option_modifier = + connect_topology_option_modifier; trial_info.topology_percentage = topology_percentage; trial_info.topology_probability = topology_probability; trial_info.puts = num_puts; @@ -4059,8 +4058,7 @@ run (void *cls, char *const *args, const char *cfgfile, put_meter = create_meter (num_puts, "Puts completed ", GNUNET_YES); get_meter = create_meter (num_gets, "Gets completed ", GNUNET_YES); hostkey_start_time = GNUNET_TIME_absolute_get (); - pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, max_outstanding_connections, max_concurrent_ssh, GNUNET_TIME_relative_multiply @@ -4088,8 +4086,9 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-driver", "nohelp", options, - &run, &ok); + ret = + GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-driver", "nohelp", options, + &run, &ok); if (malicious_bloom != NULL) GNUNET_CONTAINER_bloomfilter_free (malicious_bloom); diff --git a/src/dht/gnunet-dht-get-peer.c b/src/dht/gnunet-dht-get-peer.c index 6ca88d232..2de7e93be 100644 --- a/src/dht/gnunet-dht-get-peer.c +++ b/src/dht/gnunet-dht-get-peer.c @@ -126,9 +126,8 @@ find_peer_processor (void *cls, const struct GNUNET_HELLO_Message *hello) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative timeout; GNUNET_HashCode key; @@ -164,11 +163,9 @@ run (void *cls, if (verbose) fprintf (stderr, "Issuing FIND PEER request for %s!\n", query_key); - find_peer_handle = GNUNET_DHT_find_peer_start (dht_handle, - timeout, - &key, - GNUNET_DHT_RO_NONE, - &find_peer_processor, NULL); + find_peer_handle = + GNUNET_DHT_find_peer_start (dht_handle, timeout, &key, GNUNET_DHT_RO_NONE, + &find_peer_processor, NULL); if (NULL == find_peer_handle) { GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); @@ -207,9 +204,7 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-dht-get-peer", + GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get-peer", gettext_noop ("Issue a GET PEER request to the GNUnet DHT, print results."), options, &run, NULL)) ? ret : 1; diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index b807a798f..161f0f41b 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c @@ -117,15 +117,14 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param data pointer to the result data */ void -get_result_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, +get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, enum GNUNET_BLOCK_Type type, size_t size, const void *data) { - fprintf (stdout, "Result %d, type %d:\n%.*s\n", - result_count, type, (unsigned int) size, (char *) data); + fprintf (stdout, "Result %d, type %d:\n%.*s\n", result_count, type, + (unsigned int) size, (char *) data); result_count++; } @@ -139,9 +138,8 @@ get_result_iterator (void *cls, * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative timeout; GNUNET_HashCode key; @@ -181,14 +179,10 @@ run (void *cls, fprintf (stderr, "Issuing GET request for %s!\n", query_key); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (absolute_timeout), &cleanup_task, NULL); - get_handle = GNUNET_DHT_get_start (dht_handle, - timeout, - query_type, - &key, - DEFAULT_GET_REPLICATION, - GNUNET_DHT_RO_NONE, - NULL, 0, - NULL, 0, &get_result_iterator, NULL); + get_handle = + GNUNET_DHT_get_start (dht_handle, timeout, query_type, &key, + DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, + 0, NULL, 0, &get_result_iterator, NULL); } @@ -224,9 +218,7 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-dht-get", + GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get", gettext_noop ("Issue a GET request to the GNUnet DHT, prints results."), options, &run, NULL)) ? ret : 1; diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index b76b92c2b..4a752ea24 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c @@ -105,9 +105,8 @@ message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative timeout; struct GNUNET_TIME_Absolute expiration; @@ -147,9 +146,9 @@ run (void *cls, if (verbose) fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"), query_key, data); - GNUNET_DHT_put (dht_handle, &key, DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_NONE, query_type, strlen (data), data, - expiration, timeout, &message_sent_cont, NULL); + GNUNET_DHT_put (dht_handle, &key, DEFAULT_PUT_REPLICATION, GNUNET_DHT_RO_NONE, + query_type, strlen (data), data, expiration, timeout, + &message_sent_cont, NULL); } @@ -191,9 +190,7 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-dht-put", + GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-put", gettext_noop ("Issue a PUT request to the GNUnet DHT insert DATA under KEY."), options, &run, NULL)) ? ret : 1; diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 19250d07b..1721e73af 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -984,9 +984,8 @@ get_average_send_delay () } average_time = GNUNET_TIME_relative_divide (average_time, divisor); - fprintf (stderr, - "Avg send delay: %u sends is %llu\n", - divisor, (unsigned long long) average_time.abs_value); + fprintf (stderr, "Avg send delay: %u sends is %llu\n", divisor, + (unsigned long long) average_time.abs_value); return average_time; } #endif @@ -1088,8 +1087,7 @@ try_core_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (reply_counter >= MAX_REPLY_TIMES) reply_counter = 0; peer->th = - GNUNET_CORE_notify_transmit_ready (coreAPI, - GNUNET_YES, + GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES, pending->importance, pending->timeout, &peer->id, ssize, &core_transmit_notify, peer); @@ -1162,8 +1160,7 @@ forward_result_message (const struct GNUNET_MessageHeader *msg, result_message->hop_count = htonl (msg_ctx->hop_count + 1); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom, - result_message-> - bloomfilter, + result_message->bloomfilter, DHT_BLOOM_SIZE)); result_message->unique_id = GNUNET_htonll (msg_ctx->unique_id); memcpy (&result_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); @@ -1177,8 +1174,8 @@ forward_result_message (const struct GNUNET_MessageHeader *msg, msg_ctx->path_history_len * (sizeof (struct GNUNET_PeerIdentity))); #if DEBUG_DHT > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Adding pending message size %d for peer %s\n", - my_short_id, "DHT", msize, GNUNET_i2s (&peer->id)); + "%s:%s Adding pending message size %d for peer %s\n", my_short_id, + "DHT", msize, GNUNET_i2s (&peer->id)); #endif peer->pending_count++; increment_stats ("# pending messages scheduled"); @@ -1477,9 +1474,9 @@ find_peer_by_id (const struct GNUNET_PeerIdentity *peer) } /* Forward declaration */ -static void -update_core_preference (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void update_core_preference (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** * Function called with statistics about the given peer. * @@ -1532,14 +1529,12 @@ update_core_preference (void *cls, matching = 63; } preference = 1LL << matching; - peer->info_ctx = GNUNET_CORE_peer_change_preference (coreAPI, - &peer->id, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BANDWIDTH_VALUE_MAX, - 0, - preference, - &update_core_preference_finish, - peer); + peer->info_ctx = + GNUNET_CORE_peer_change_preference (coreAPI, &peer->id, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BANDWIDTH_VALUE_MAX, 0, + preference, + &update_core_preference_finish, peer); } @@ -1557,12 +1552,12 @@ static void remove_peer (struct PeerInfo *peer, unsigned int bucket) { GNUNET_assert (k_buckets[bucket].peers_size > 0); - GNUNET_CONTAINER_DLL_remove (k_buckets[bucket].head, - k_buckets[bucket].tail, peer); + GNUNET_CONTAINER_DLL_remove (k_buckets[bucket].head, k_buckets[bucket].tail, + peer); k_buckets[bucket].peers_size--; #if CHANGE_LOWEST - if ((bucket == lowest_bucket) && (k_buckets[lowest_bucket].peers_size == 0) - && (lowest_bucket < MAX_BUCKETS - 1)) + if ((bucket == lowest_bucket) && (k_buckets[lowest_bucket].peers_size == 0) && + (lowest_bucket < MAX_BUCKETS - 1)) lowest_bucket++; #endif } @@ -1589,8 +1584,8 @@ delete_peer (struct PeerInfo *peer, unsigned int bucket) if (peer_pos == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%s:%s: Expected peer `%s' in bucket %d\n", my_short_id, - "DHT", GNUNET_i2s (&peer->id), bucket); + "%s:%s: Expected peer `%s' in bucket %d\n", my_short_id, "DHT", + GNUNET_i2s (&peer->id), bucket); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s:%s: Lowest bucket: %d, find_current_bucket: %d, peer resides in bucket: %d\n", my_short_id, "DHT", lowest_bucket, @@ -1677,8 +1672,7 @@ enable_next_bucket () while (pos != NULL) { if (find_bucket (&pos->id.hashPubKey) < lowest_bucket) - GNUNET_CONTAINER_multihashmap_put (to_remove, &pos->id.hashPubKey, - pos, + GNUNET_CONTAINER_multihashmap_put (to_remove, &pos->id.hashPubKey, pos, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); pos = pos->next; } @@ -1747,8 +1741,8 @@ find_closest_peer (const GNUNET_HashCode * hc) * @param msg_ctx the context of the message (hop count, bloom, etc.) */ static void -forward_message (const struct GNUNET_MessageHeader *msg, - struct PeerInfo *peer, struct DHT_MessageContext *msg_ctx) +forward_message (const struct GNUNET_MessageHeader *msg, struct PeerInfo *peer, + struct DHT_MessageContext *msg_ctx) { struct GNUNET_DHT_P2PRouteMessage *route_message; struct P2PPendingMessage *pending; @@ -1758,8 +1752,8 @@ forward_message (const struct GNUNET_MessageHeader *msg, increment_stats (STAT_ROUTE_FORWARDS); GNUNET_assert (peer != NULL); - if ((msg_ctx->closest != GNUNET_YES) - && (peer == find_closest_peer (&msg_ctx->key))) + if ((msg_ctx->closest != GNUNET_YES) && + (peer == find_closest_peer (&msg_ctx->key))) increment_stats (STAT_ROUTE_FORWARDS_CLOSEST); msize = @@ -1782,8 +1776,7 @@ forward_message (const struct GNUNET_MessageHeader *msg, if (msg_ctx->bloom != NULL) GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom, - route_message-> - bloomfilter, + route_message->bloomfilter, DHT_BLOOM_SIZE)); memcpy (&route_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); memcpy (&route_message[1], msg, ntohs (msg->size)); @@ -1801,8 +1794,8 @@ forward_message (const struct GNUNET_MessageHeader *msg, } #if DEBUG_DHT > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Adding pending message size %d for peer %s\n", - my_short_id, "DHT", msize, GNUNET_i2s (&peer->id)); + "%s:%s Adding pending message size %d for peer %s\n", my_short_id, + "DHT", msize, GNUNET_i2s (&peer->id)); #endif peer->pending_count++; increment_stats ("# pending messages scheduled"); @@ -1835,9 +1828,8 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); #if DEBUG_PING - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", - GNUNET_i2s (&peer->id)); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", + my_short_id, "DHT", GNUNET_i2s (&peer->id)); #endif forward_message (&ping_message, peer, &msg_ctx); peer->ping_task = @@ -1864,8 +1856,8 @@ schedule_ping_messages () { if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) GNUNET_SCHEDULER_add_now (&periodic_ping_task, pos); - else if ((count >= bucket_size) - && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) + else if ((count >= bucket_size) && + (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) { GNUNET_SCHEDULER_cancel (pos->ping_task); pos->ping_task = GNUNET_SCHEDULER_NO_TASK; @@ -1893,8 +1885,8 @@ process_pending_messages (struct ClientList *client) client->transmit_handle = GNUNET_SERVER_notify_transmit_ready (client->client_handle, - ntohs (client->pending_head-> - msg->size), + ntohs (client->pending_head->msg-> + size), GNUNET_TIME_UNIT_FOREVER_REL, &send_generic_reply, client); } @@ -1930,8 +1922,8 @@ send_generic_reply (void *cls, size_t size, void *buf) while ((NULL != (reply = client->pending_head)) && (size >= off + (msize = ntohs (reply->msg->size)))) { - GNUNET_CONTAINER_DLL_remove (client->pending_head, - client->pending_tail, reply); + GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail, + reply); memcpy (&cbuf[off], reply->msg, msize); GNUNET_free (reply); off += msize; @@ -1956,8 +1948,7 @@ static void add_pending_message (struct ClientList *client, struct PendingMessage *pending_message) { - GNUNET_CONTAINER_DLL_insert_after (client->pending_head, - client->pending_tail, + GNUNET_CONTAINER_DLL_insert_after (client->pending_head, client->pending_tail, client->pending_tail, pending_message); process_pending_messages (client); } @@ -1987,8 +1978,8 @@ send_reply_to_client (struct ClientList *client, unsigned int i; #endif #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s:%s': Sending reply to client.\n", my_short_id, "DHT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Sending reply to client.\n", + my_short_id, "DHT"); #endif msize = ntohs (message->size); tsize = @@ -2049,14 +2040,13 @@ consider_peer (struct GNUNET_PeerIdentity *peer) if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (all_known_peers, - &peer->hashPubKey)) - || (0 == - memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))) + &peer->hashPubKey)) || + (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))) return GNUNET_NO; /* We already know this peer (are connected even!) */ bucket = find_current_bucket (&peer->hashPubKey); - if ((k_buckets[bucket].peers_size < bucket_size) - || ((bucket == lowest_bucket) && (lowest_bucket > 0))) + if ((k_buckets[bucket].peers_size < bucket_size) || + ((bucket == lowest_bucket) && (lowest_bucket > 0))) return GNUNET_YES; return GNUNET_NO; @@ -2083,8 +2073,8 @@ remove_forward_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (record->head == NULL) /* No more entries in DLL */ { GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove - (forward_list.hashmap, &record->key, record)); + GNUNET_CONTAINER_multihashmap_remove (forward_list.hashmap, + &record->key, record)); GNUNET_free (record); } if (source_info->find_peers_responded != NULL) @@ -2127,10 +2117,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, GNUNET_break_op (0); hello_msg = &msg[1]; - if ((ntohs (hello_msg->type) != GNUNET_MESSAGE_TYPE_HELLO) - || (GNUNET_SYSERR == - GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) - hello_msg, &new_peer))) + if ((ntohs (hello_msg->type) != GNUNET_MESSAGE_TYPE_HELLO) || + (GNUNET_SYSERR == + GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello_msg, + &new_peer))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s:%s Received non-HELLO message type in find peer result message!\n", @@ -2168,13 +2158,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, #if DEBUG_DHT_ROUTING if ((debug_routes_extended) && (dhtlog_handle != NULL)) { - dhtlog_handle->insert_route (NULL, - msg_ctx->unique_id, - DHTLOG_RESULT, - msg_ctx->hop_count, - GNUNET_SYSERR, - &my_identity, - &msg_ctx->key, msg_ctx->peer, NULL); + dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, + msg_ctx->hop_count, GNUNET_SYSERR, + &my_identity, &msg_ctx->key, msg_ctx->peer, + NULL); } #endif if (msg_ctx->bloom != NULL) @@ -2216,10 +2203,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, #if DEBUG_DHT_ROUTING if ((debug_routes_extended) && (dhtlog_handle != NULL)) { - dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, - DHTLOG_RESULT, msg_ctx->hop_count, - GNUNET_YES, &my_identity, - &msg_ctx->key, msg_ctx->peer, NULL); + dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, + msg_ctx->hop_count, GNUNET_YES, + &my_identity, &msg_ctx->key, msg_ctx->peer, + NULL); } #endif increment_stats (STAT_RESULTS_TO_CLIENT); @@ -2268,12 +2255,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, #if DEBUG_DHT_ROUTING if ((debug_routes_extended) && (dhtlog_handle != NULL)) { - dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, - DHTLOG_RESULT, - msg_ctx->hop_count, - GNUNET_NO, &my_identity, - &msg_ctx->key, msg_ctx->peer, - &pos->source); + dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, + msg_ctx->hop_count, GNUNET_NO, + &my_identity, &msg_ctx->key, + msg_ctx->peer, &pos->source); } #endif forward_result_message (msg, peer_info, msg_ctx); @@ -2320,11 +2305,9 @@ route_result_message (struct GNUNET_MessageHeader *msg, * to stop iteration. */ static int -datacache_get_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, - const GNUNET_HashCode * key, - size_t size, const char *data, - enum GNUNET_BLOCK_Type type) +datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, + const GNUNET_HashCode * key, size_t size, + const char *data, enum GNUNET_BLOCK_Type type) { struct DHT_MessageContext *msg_ctx = cls; struct DHT_MessageContext *new_msg_ctx; @@ -2346,29 +2329,25 @@ datacache_get_iterator (void *cls, put_entry = (const struct DHTPutEntry *) data; - if (size != sizeof (struct DHTPutEntry) + - put_entry->data_size + + if (size != + sizeof (struct DHTPutEntry) + put_entry->data_size + (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Path + data size doesn't add up for data inserted into datacache!\nData size %d, path length %d, expected %d, got %d\n", put_entry->data_size, put_entry->path_length, - sizeof (struct DHTPutEntry) + put_entry->data_size - + + sizeof (struct DHTPutEntry) + put_entry->data_size + (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity)), size); msg_ctx->do_forward = GNUNET_NO; return GNUNET_OK; } - eval = GNUNET_BLOCK_evaluate (block_context, - type, - key, - &msg_ctx->reply_bf, - msg_ctx->reply_bf_mutator, - msg_ctx->xquery, - msg_ctx->xquery_size, &put_entry[1], - put_entry->data_size); + eval = + GNUNET_BLOCK_evaluate (block_context, type, key, &msg_ctx->reply_bf, + msg_ctx->reply_bf_mutator, msg_ctx->xquery, + msg_ctx->xquery_size, &put_entry[1], + put_entry->data_size); switch (eval) { @@ -2437,14 +2416,14 @@ datacache_get_iterator (void *cls, break; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s:%s': Duplicate block error\n", my_short_id, "DHT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Duplicate block error\n", + my_short_id, "DHT"); #endif break; case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "`%s:%s': Invalid request error\n", my_short_id, "DHT"); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "`%s:%s': Invalid request error\n", + my_short_id, "DHT"); #endif break; case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: @@ -2478,9 +2457,8 @@ datacache_get_iterator (void *cls, * @param msg the message to be routed * @param msg_ctx the context containing all pertinent information about the message */ -static void -route_message (const struct GNUNET_MessageHeader *msg, - struct DHT_MessageContext *msg_ctx); +static void route_message (const struct GNUNET_MessageHeader *msg, + struct DHT_MessageContext *msg_ctx); /** @@ -2535,17 +2513,16 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, } else { - msg_ctx->reply_bf = GNUNET_CONTAINER_bloomfilter_init (end, - bf_size, - GNUNET_DHT_GET_BLOOMFILTER_K); + msg_ctx->reply_bf = + GNUNET_CONTAINER_bloomfilter_init (end, bf_size, + GNUNET_DHT_GET_BLOOMFILTER_K); } type = (enum GNUNET_BLOCK_Type) ntohl (get_msg->type); #if DEBUG_DHT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Received `%s' request, message type %u, key %s, uid %llu\n", - my_short_id, - "DHT", "GET", - type, GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id); + my_short_id, "DHT", "GET", type, GNUNET_h2s (&msg_ctx->key), + msg_ctx->unique_id); #endif increment_stats (STAT_GETS); results = 0; @@ -2558,10 +2535,9 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, #endif msg_ctx->do_forward = GNUNET_YES; if (datacache != NULL) - results - = GNUNET_DATACACHE_get (datacache, - &msg_ctx->key, type, - &datacache_get_iterator, msg_ctx); + results = + GNUNET_DATACACHE_get (datacache, &msg_ctx->key, type, + &datacache_get_iterator, msg_ctx); #if DEBUG_DHT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Found %d results for `%s' request uid %llu\n", @@ -2573,30 +2549,25 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, if ((debug_routes) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, - msg_ctx->hop_count, GNUNET_YES, - &my_identity, &msg_ctx->key); + msg_ctx->hop_count, GNUNET_YES, &my_identity, + &msg_ctx->key); } if ((debug_routes_extended) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, - msg_ctx->hop_count, GNUNET_YES, - &my_identity, &msg_ctx->key, - msg_ctx->peer, NULL); + msg_ctx->hop_count, GNUNET_YES, &my_identity, + &msg_ctx->key, msg_ctx->peer, NULL); } #endif } else { /* check query valid */ - if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID - == GNUNET_BLOCK_evaluate (block_context, - type, - &msg_ctx->key, - &msg_ctx->reply_bf, - msg_ctx->reply_bf_mutator, - msg_ctx->xquery, - msg_ctx->xquery_size, NULL, 0)) + if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID == + GNUNET_BLOCK_evaluate (block_context, type, &msg_ctx->key, + &msg_ctx->reply_bf, msg_ctx->reply_bf_mutator, + msg_ctx->xquery, msg_ctx->xquery_size, NULL, 0)) { GNUNET_break_op (0); msg_ctx->do_forward = GNUNET_NO; @@ -2609,8 +2580,8 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, if ((debug_routes) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, - msg_ctx->hop_count, GNUNET_NO, - &my_identity, &msg_ctx->key); + msg_ctx->hop_count, GNUNET_NO, &my_identity, + &msg_ctx->key); } #endif } @@ -2667,11 +2638,10 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, ntohs (find_msg->size) - sizeof (struct GNUNET_DHT_FindPeerMessage); other_hello = GNUNET_malloc (other_hello_size); memcpy (other_hello, &find_peer_message[1], other_hello_size); - if ((GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) other_hello) == - 0) + if ((GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) other_hello) == 0) || (GNUNET_OK != - GNUNET_HELLO_get_id ((struct GNUNET_HELLO_Message *) - other_hello, &peer_id))) + GNUNET_HELLO_get_id ((struct GNUNET_HELLO_Message *) other_hello, + &peer_id))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Received invalid HELLO message in find peer request!\n"); @@ -2802,8 +2772,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, memcpy (&find_peer_result[1], my_hello, hello_size); #if DEBUG_DHT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s': Sending hello size %d to requesting peer.\n", - "DHT", hello_size); + "`%s': Sending hello size %d to requesting peer.\n", "DHT", + hello_size); #endif new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext)); @@ -2829,8 +2799,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, if ((debug_routes) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, - msg_ctx->hop_count, GNUNET_YES, - &my_identity, &msg_ctx->key); + msg_ctx->hop_count, GNUNET_YES, &my_identity, + &msg_ctx->key); } #endif GNUNET_free_non_null (other_hello); @@ -2845,8 +2815,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, * @param cls closure (a struct RepublishContext) * @param tc runtime context for this task */ -static void -republish_content (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void republish_content (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** * Server handler for initiating local dht put requests @@ -2881,8 +2851,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, /** Log routes that die due to high load! */ dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, msg_ctx->hop_count, GNUNET_SYSERR, - &my_identity, &msg_ctx->key, - msg_ctx->peer, NULL); + &my_identity, &msg_ctx->key, msg_ctx->peer, + NULL); } #endif return; @@ -2900,8 +2870,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, { dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, msg_ctx->hop_count, GNUNET_SYSERR, - &my_identity, &msg_ctx->key, - msg_ctx->peer, NULL); + &my_identity, &msg_ctx->key, msg_ctx->peer, + NULL); } #endif /* invalid reply */ @@ -2916,8 +2886,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, { dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, msg_ctx->hop_count, GNUNET_SYSERR, - &my_identity, &msg_ctx->key, - msg_ctx->peer, NULL); + &my_identity, &msg_ctx->key, msg_ctx->peer, + NULL); } #endif /* invalid wrapper: key mismatch! */ @@ -2938,8 +2908,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, if ((debug_routes) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, - msg_ctx->hop_count, GNUNET_NO, - &my_identity, &msg_ctx->key); + msg_ctx->hop_count, GNUNET_NO, &my_identity, + &msg_ctx->key); } } #endif @@ -2961,16 +2931,15 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, if ((debug_routes_extended) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, - msg_ctx->hop_count, GNUNET_YES, - &my_identity, &msg_ctx->key, msg_ctx->peer, - NULL); + msg_ctx->hop_count, GNUNET_YES, &my_identity, + &msg_ctx->key, msg_ctx->peer, NULL); } if ((debug_routes) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, - msg_ctx->hop_count, GNUNET_YES, - &my_identity, &msg_ctx->key); + msg_ctx->hop_count, GNUNET_YES, &my_identity, + &msg_ctx->key); } #endif @@ -2995,10 +2964,10 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, msg_ctx->path_history_len * sizeof (struct GNUNET_PeerIdentity)); } - ret = GNUNET_DATACACHE_put (datacache, &msg_ctx->key, put_size, - (const char *) put_entry, put_type, - GNUNET_TIME_absolute_ntoh - (put_msg->expiration)); + ret = + GNUNET_DATACACHE_put (datacache, &msg_ctx->key, put_size, + (const char *) put_entry, put_type, + GNUNET_TIME_absolute_ntoh (put_msg->expiration)); GNUNET_free (put_entry); if ((ret == GNUNET_YES) && (do_republish == GNUNET_YES)) @@ -3006,8 +2975,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, put_context = GNUNET_malloc (sizeof (struct RepublishContext)); memcpy (&put_context->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); put_context->type = put_type; - GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, - &republish_content, put_context); + GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, + put_context); } } else @@ -3102,17 +3071,16 @@ get_forward_count (unsigned int hop_count, size_t target_replication) if (GNUNET_YES == paper_forwarding) { /* FIXME: re-run replication trials with this formula */ - target_value = 1 + (target_replication - 1.0) / (diameter - + - ((float) - (target_replication - - 1.0) * hop_count)); + target_value = + 1 + (target_replication - 1.0) / (diameter + + ((float) (target_replication - 1.0) * + hop_count)); /* Set forward count to floor of target_value */ forward_count = (unsigned int) target_value; /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */ target_value = target_value - forward_count; - random_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, - UINT32_MAX); + random_value = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); if (random_value < (target_value * UINT32_MAX)) forward_count += 1; @@ -3121,10 +3089,9 @@ get_forward_count (unsigned int hop_count, size_t target_replication) { random_value = 0; forward_count = 1; - target_value = target_replication / (diameter - + - ((float) target_replication * - hop_count)); + target_value = + target_replication / (diameter + + ((float) target_replication * hop_count)); if (target_value > 1) { /* Set forward count to floor of target_value */ @@ -3133,8 +3100,8 @@ get_forward_count (unsigned int hop_count, size_t target_replication) target_value = target_value - forward_count; } else - random_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, - UINT32_MAX); + random_value = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); if (random_value < (target_value * UINT32_MAX)) forward_count += 1; @@ -3176,9 +3143,9 @@ am_closest_peer (const GNUNET_HashCode * target, count = 0; while ((pos != NULL) && (count < bucket_size)) { - if ((bloom != NULL) - && (GNUNET_YES == - GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))) + if ((bloom != NULL) && + (GNUNET_YES == + GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))) { pos = pos->next; continue; /* Skip already checked entries */ @@ -3216,8 +3183,8 @@ am_closest_peer (const GNUNET_HashCode * target, * */ static unsigned long long -converge_distance (const GNUNET_HashCode * target, - struct PeerInfo *peer, unsigned int hops) +converge_distance (const GNUNET_HashCode * target, struct PeerInfo *peer, + unsigned int hops) { unsigned long long ret; unsigned int other_matching_bits; @@ -3298,8 +3265,8 @@ converge_distance (const GNUNET_HashCode * target, errno = 0; feclearexcept (FE_ALL_EXCEPT); ret = (unsigned long long) pow (other_matching_bits, calc_value); - if ((errno != 0) || fetestexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | - FE_UNDERFLOW)) + if ((errno != 0) || + fetestexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)) { if (0 != fetestexcept (FE_OVERFLOW)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "FE_OVERFLOW\n"); @@ -3542,10 +3509,10 @@ select_peer (const GNUNET_HashCode * target, break; /* overflow case */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Choose %d matching bits (%d bits match me) (%.2f percent) converge ret %llu\n", - GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]->id. - hashPubKey, target), - GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]->id. - hashPubKey, + GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]-> + id.hashPubKey, target), + GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]-> + id.hashPubKey, &my_identity.hashPubKey), (temp_converge_distance / (double) total_distance) * 100, temp_converge_distance); @@ -3576,8 +3543,8 @@ select_peer (const GNUNET_HashCode * target, target), GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, &my_identity.hashPubKey), - (temp_converge_distance / (double) total_distance) * - 100, temp_converge_distance); + (temp_converge_distance / (double) total_distance) * 100, + temp_converge_distance); pos = pos->next; count++; } @@ -3608,8 +3575,8 @@ select_peer (const GNUNET_HashCode * target, target), GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, &my_identity.hashPubKey), - (temp_converge_distance / (double) total_distance) * - 100, temp_converge_distance); + (temp_converge_distance / (double) total_distance) * 100, + temp_converge_distance); pos = pos->next; count++; } @@ -3750,8 +3717,9 @@ cache_response (struct DHT_MessageContext *msg_ctx) if (record->head == NULL) /* No more entries in DLL */ { GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove - (forward_list.hashmap, &record->key, record)); + GNUNET_CONTAINER_multihashmap_remove (forward_list.hashmap, + &record->key, + record)); GNUNET_free (record); } if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) @@ -3864,8 +3832,8 @@ route_message (const struct GNUNET_MessageHeader *msg, { dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, msg_ctx->hop_count, GNUNET_SYSERR, - &my_identity, &msg_ctx->key, - msg_ctx->peer, NULL); + &my_identity, &msg_ctx->key, msg_ctx->peer, + NULL); } #endif if (msg_ctx->bloom != NULL) @@ -3887,8 +3855,8 @@ route_message (const struct GNUNET_MessageHeader *msg, msg_ctx->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); - if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) - && (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) + if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) && + (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) target_forward_count = 0; /** @@ -3906,9 +3874,9 @@ route_message (const struct GNUNET_MessageHeader *msg, * testing driver) we will ignore this restriction for FIND_PEER messages so that * routing tables still get constructed. */ - if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) - && (msg_ctx->hop_count > 0) - && (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) + if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) && + (msg_ctx->hop_count > 0) && + (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) target_forward_count = 0; @@ -3942,8 +3910,7 @@ route_message (const struct GNUNET_MessageHeader *msg, GNUNET_TIME_absolute_get ().abs_value); recent_req->bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); - GNUNET_CONTAINER_multihashmap_put (recent.hashmap, &unique_hash, - recent_req, + GNUNET_CONTAINER_multihashmap_put (recent.hashmap, &unique_hash, recent_req, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } @@ -3988,8 +3955,7 @@ route_message (const struct GNUNET_MessageHeader *msg, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key), - msg_ctx->unique_id, GNUNET_i2s (&selected->id), - nearest_buf, + msg_ctx->unique_id, GNUNET_i2s (&selected->id), nearest_buf, GNUNET_CRYPTO_hash_matching_bits (&nearest->id.hashPubKey, msg_ctx->key), distance (&nearest->id.hashPubKey, msg_ctx->key)); @@ -3998,10 +3964,9 @@ route_message (const struct GNUNET_MessageHeader *msg, #if DEBUG_DHT_ROUTING if ((debug_routes_extended) && (dhtlog_handle != NULL)) { - dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, - DHTLOG_ROUTE, msg_ctx->hop_count, - GNUNET_NO, &my_identity, - &msg_ctx->key, msg_ctx->peer, + dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, + msg_ctx->hop_count, GNUNET_NO, + &my_identity, &msg_ctx->key, msg_ctx->peer, &selected->id); } #endif @@ -4026,9 +3991,8 @@ route_message (const struct GNUNET_MessageHeader *msg, if ((debug_routes_extended) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, - msg_ctx->hop_count, ret, - &my_identity, &msg_ctx->key, msg_ctx->peer, - NULL); + msg_ctx->hop_count, ret, &my_identity, + &msg_ctx->key, msg_ctx->peer, NULL); } #endif } @@ -4061,15 +4025,15 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, break; case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */ increment_stats (STAT_FIND_PEER); - if (((msg_ctx->hop_count > 0) - && (0 != - memcmp (msg_ctx->peer, &my_identity, - sizeof (struct GNUNET_PeerIdentity)))) - || (msg_ctx->client != NULL)) + if (((msg_ctx->hop_count > 0) && + (0 != + memcmp (msg_ctx->peer, &my_identity, + sizeof (struct GNUNET_PeerIdentity)))) || + (msg_ctx->client != NULL)) { cache_response (msg_ctx); - if ((msg_ctx->closest == GNUNET_YES) - || (msg_ctx->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) + if ((msg_ctx->closest == GNUNET_YES) || + (msg_ctx->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) handle_dht_find_peer (msg, msg_ctx); } else @@ -4080,8 +4044,7 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, if ((debug_routes) && (dhtlog_handle != NULL)) { dhtlog_handle->insert_dhtkey (NULL, &msg_ctx->key); - dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, - DHTLOG_FIND_PEER, + dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, msg_ctx->hop_count, GNUNET_NO, &my_identity, &msg_ctx->key); } @@ -4113,10 +4076,9 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, * to stop iteration. */ static int -republish_content_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, - const GNUNET_HashCode * key, - size_t size, const char *data, uint32_t type) +republish_content_iterator (void *cls, struct GNUNET_TIME_Absolute exp, + const GNUNET_HashCode * key, size_t size, + const char *data, uint32_t type) { struct DHT_MessageContext *new_msg_ctx; @@ -4227,8 +4189,8 @@ find_client_records (void *cls, const GNUNET_HashCode * key, void *value) if (record->head == NULL) /* No more entries in DLL */ { GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove - (forward_list.hashmap, &record->key, record)); + GNUNET_CONTAINER_multihashmap_remove (forward_list.hashmap, + &record->key, record)); GNUNET_free (record); } return GNUNET_YES; @@ -4274,8 +4236,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) while (NULL != (reply = found->pending_head)) { - GNUNET_CONTAINER_DLL_remove (found->pending_head, - found->pending_tail, reply); + GNUNET_CONTAINER_DLL_remove (found->pending_head, found->pending_tail, + reply); GNUNET_free (reply); } GNUNET_CONTAINER_multihashmap_iterate (forward_list.hashmap, @@ -4354,13 +4316,13 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif increment_stats (STAT_PUT_START); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Sending malicious PUT message with hash %s\n", - my_short_id, "DHT", GNUNET_h2s (&key)); + "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, + "DHT", GNUNET_h2s (&key)); demultiplex_message (&put_message.header, &msg_ctx); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - malicious_put_frequency), - &malicious_put_task, NULL); + malicious_put_frequency), &malicious_put_task, + NULL); } @@ -4404,13 +4366,13 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif increment_stats (STAT_GET_START); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Sending malicious GET message with hash %s\n", - my_short_id, "DHT", GNUNET_h2s (&key)); + "%s:%s Sending malicious GET message with hash %s\n", my_short_id, + "DHT", GNUNET_h2s (&key)); demultiplex_message (&get_message.header, &msg_ctx); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - malicious_get_frequency), - &malicious_get_task, NULL); + malicious_get_frequency), &malicious_get_task, + NULL); } #endif @@ -4511,8 +4473,7 @@ send_find_peer_message (void *cls, temp_bloom); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data (temp_bloom, - find_peer_msg-> - bloomfilter, + find_peer_msg->bloomfilter, DHT_BLOOM_SIZE)); GNUNET_CONTAINER_bloomfilter_free (temp_bloom); memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); @@ -4541,7 +4502,8 @@ send_find_peer_message (void *cls, } else { - next_send_time.rel_value = DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + + next_send_time.rel_value = + DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); @@ -4553,8 +4515,8 @@ send_find_peer_message (void *cls, find_peer_context.start = GNUNET_TIME_absolute_get (); if (GNUNET_YES == do_find_peer) { - GNUNET_SCHEDULER_add_delayed (next_send_time, - &send_find_peer_message, NULL); + GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, + NULL); } } @@ -4568,8 +4530,7 @@ send_find_peer_message (void *cls, * @param message the actual message received */ static void -handle_dht_local_route_request (void *cls, - struct GNUNET_SERVER_Client *client, +handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct GNUNET_DHT_RouteMessage *dht_msg = @@ -4581,10 +4542,7 @@ handle_dht_local_route_request (void *cls, #if DEBUG_DHT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Received `%s' request from client, message type %d, key %s, uid %llu\n", - my_short_id, - "DHT", - "GENERIC", - ntohs (message->type), + my_short_id, "DHT", "GENERIC", ntohs (message->type), GNUNET_h2s (&dht_msg->key), GNUNET_ntohll (dht_msg->unique_id)); #endif #if DEBUG_DHT_ROUTING @@ -4625,9 +4583,9 @@ handle_dht_local_route_request (void *cls, #if DEBUG_DHT_ROUTING if ((debug_routes) && (dhtlog_handle != NULL)) { - dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, - DHTLOG_GET, msg_ctx.hop_count, - GNUNET_NO, &my_identity, &msg_ctx.key); + dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, DHTLOG_GET, + msg_ctx.hop_count, GNUNET_NO, &my_identity, + &msg_ctx.key); } #endif } @@ -4636,9 +4594,9 @@ handle_dht_local_route_request (void *cls, #if DEBUG_DHT_ROUTING if ((debug_routes) && (dhtlog_handle != NULL)) { - dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, - DHTLOG_PUT, msg_ctx.hop_count, - GNUNET_NO, &my_identity, &msg_ctx.key); + dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, DHTLOG_PUT, + msg_ctx.hop_count, GNUNET_NO, &my_identity, + &msg_ctx.key); } #endif } @@ -4719,8 +4677,8 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, #endif default: GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%s:%s Unknown control command type `%d'!\n", - my_short_id, "DHT", ntohs (dht_control_msg->command)); + "%s:%s Unknown control command type `%d'!\n", my_short_id, + "DHT", ntohs (dht_control_msg->command)); break; } @@ -4787,8 +4745,7 @@ handle_dht_local_route_stop (void *cls, struct GNUNET_SERVER_Client *client, * */ static int -handle_dht_p2p_route_request (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_dht_p2p_route_request (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) @@ -4809,8 +4766,8 @@ handle_dht_p2p_route_request (void *cls, if (ntohs (enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_P2P_PING) /* Throw these away. FIXME: Don't throw these away? (reply) */ { #if DEBUG_PING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Received P2P Ping message.\n", my_short_id, "DHT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Received P2P Ping message.\n", + my_short_id, "DHT"); #endif return GNUNET_YES; } @@ -4827,12 +4784,10 @@ handle_dht_p2p_route_request (void *cls, if ((debug_routes_extended) && (dhtlog_handle != NULL)) { /** Log routes that die due to high load! */ - dhtlog_handle->insert_route (NULL, - GNUNET_ntohll (incoming->unique_id), - DHTLOG_ROUTE, - ntohl (incoming->hop_count), - GNUNET_SYSERR, &my_identity, - &incoming->key, peer, NULL); + dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id), + DHTLOG_ROUTE, ntohl (incoming->hop_count), + GNUNET_SYSERR, &my_identity, &incoming->key, + peer, NULL); } #endif return GNUNET_YES; @@ -4848,12 +4803,10 @@ handle_dht_p2p_route_request (void *cls, if ((debug_routes_extended) && (dhtlog_handle != NULL)) { /** Log routes that die due to high load! */ - dhtlog_handle->insert_route (NULL, - GNUNET_ntohll (incoming->unique_id), - DHTLOG_ROUTE, - ntohl (incoming->hop_count), - GNUNET_SYSERR, &my_identity, - &incoming->key, peer, NULL); + dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id), + DHTLOG_ROUTE, ntohl (incoming->hop_count), + GNUNET_SYSERR, &my_identity, &incoming->key, + peer, NULL); } #endif return GNUNET_YES; @@ -4911,8 +4864,7 @@ handle_dht_p2p_route_request (void *cls, * */ static int -handle_dht_p2p_route_result (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_dht_p2p_route_result (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) @@ -4944,12 +4896,10 @@ handle_dht_p2p_route_result (void *cls, if ((debug_routes_extended) && (dhtlog_handle != NULL)) { /** Log routes that die due to high load! */ - dhtlog_handle->insert_route (NULL, - GNUNET_ntohll (incoming->unique_id), - DHTLOG_ROUTE, - ntohl (incoming->hop_count), - GNUNET_SYSERR, &my_identity, - &incoming->key, peer, NULL); + dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id), + DHTLOG_ROUTE, ntohl (incoming->hop_count), + GNUNET_SYSERR, &my_identity, &incoming->key, + peer, NULL); } #endif return GNUNET_YES; @@ -4977,8 +4927,7 @@ handle_dht_p2p_route_result (void *cls, #if DEBUG_DHT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Return message indicated a path was included, but sizes are wrong: Total size %d, enc size %d, left %d, expected %d\n", - ntohs (message->size), - ntohs (enc_msg->size), + ntohs (message->size), ntohs (enc_msg->size), ntohs (message->size) - sizeof (struct GNUNET_DHT_P2PRouteResultMessage) - ntohs (enc_msg->size), @@ -5055,8 +5004,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (coreAPI != NULL) { #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Disconnecting core!\n", my_short_id, "DHT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Disconnecting core!\n", + my_short_id, "DHT"); #endif GNUNET_CORE_disconnect (coreAPI); coreAPI = NULL; @@ -5077,8 +5026,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (datacache != NULL) { #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s:%s Destroying datacache!\n", my_short_id, "DHT"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Destroying datacache!\n", + my_short_id, "DHT"); #endif GNUNET_DATACACHE_destroy (datacache); datacache = NULL; @@ -5112,8 +5061,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param publicKey the public key of this peer */ void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -5121,9 +5069,8 @@ core_init (void *cls, if (server == NULL) { #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s: Connection to core FAILED!\n", "dht", - GNUNET_i2s (identity)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Connection to core FAILED!\n", + "dht", GNUNET_i2s (identity)); #endif GNUNET_SCHEDULER_cancel (cleanup_task); GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); @@ -5175,8 +5122,7 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = { * @param atsi performance data */ static void -handle_core_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct PeerInfo *ret; @@ -5242,8 +5188,8 @@ handle_core_connect (void *cls, if ((GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, &peer->hashPubKey) > 0) && (k_buckets[peer_bucket].peers_size <= bucket_size)) - ret->preference_task = GNUNET_SCHEDULER_add_now (&update_core_preference, - ret); + ret->preference_task = + GNUNET_SCHEDULER_add_now (&update_core_preference, ret); #endif if ((k_buckets[lowest_bucket].peers_size) >= bucket_size) enable_next_bucket (); @@ -5251,8 +5197,7 @@ handle_core_connect (void *cls, schedule_ping_messages (); #endif newly_found_peers++; - GNUNET_CONTAINER_multihashmap_put (all_known_peers, &peer->hashPubKey, - ret, + GNUNET_CONTAINER_multihashmap_put (all_known_peers, &peer->hashPubKey, ret, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); increment_stats (STAT_PEERS_KNOWN); @@ -5324,8 +5269,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_TIME_Relative next_send_time; @@ -5351,8 +5295,8 @@ run (void *cls, if (coreAPI == NULL) return; - transport_handle = GNUNET_TRANSPORT_connect (cfg, - NULL, NULL, NULL, NULL, NULL); + transport_handle = + GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); if (transport_handle != NULL) GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); else @@ -5397,21 +5341,21 @@ run (void *cls, GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_getter")) { malicious_getter = GNUNET_YES; - if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", - "MALICIOUS_GET_FREQUENCY", - &malicious_get_frequency)) + if (GNUNET_NO == + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", + "MALICIOUS_GET_FREQUENCY", + &malicious_get_frequency)) malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; } - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", - "MAX_HOPS", - &max_hops)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", "MAX_HOPS", &max_hops)) { max_hops = DEFAULT_MAX_HOPS; } - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", - "USE_MAX_HOPS")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "USE_MAX_HOPS")) { use_max_hops = GNUNET_YES; } @@ -5420,9 +5364,10 @@ run (void *cls, GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_putter")) { malicious_putter = GNUNET_YES; - if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", - "MALICIOUS_PUT_FREQUENCY", - &malicious_put_frequency)) + if (GNUNET_NO == + GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", + "MALICIOUS_PUT_FREQUENCY", + &malicious_put_frequency)) malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; } @@ -5570,19 +5515,21 @@ run (void *cls, GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); if (GNUNET_YES == do_find_peer) { - next_send_time.rel_value = DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + + next_send_time.rel_value = + DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / 2) - DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); find_peer_context.start = GNUNET_TIME_absolute_get (); - GNUNET_SCHEDULER_add_delayed (next_send_time, - &send_find_peer_message, &find_peer_context); + GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, + &find_peer_context); } /* Scheduled the task to clean up when shutdown is called */ - cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + cleanup_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &shutdown_task, NULL); } /** @@ -5597,11 +5544,10 @@ main (int argc, char *const *argv) { int ret; - ret = (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "dht", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, + NULL)) ? 0 : 1; if (NULL != recent.hashmap) { GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent.hashmap)); diff --git a/src/dht/plugin_dhtlog_dummy.c b/src/dht/plugin_dhtlog_dummy.c index 2250c0330..a411c5934 100644 --- a/src/dht/plugin_dhtlog_dummy.c +++ b/src/dht/plugin_dhtlog_dummy.c @@ -135,8 +135,8 @@ update_trials (unsigned int gets_succeeded) * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -add_generic_stat (const struct GNUNET_PeerIdentity *peer, - const char *name, const char *section, uint64_t value) +add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, + const char *section, uint64_t value) { return GNUNET_OK; } @@ -193,9 +193,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, */ int add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, - unsigned int type, unsigned int hops, - int succeeded, const struct GNUNET_PeerIdentity *node, - const GNUNET_HashCode * key, + unsigned int type, unsigned int hops, int succeeded, + const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *from_node, const struct GNUNET_PeerIdentity *to_node) { @@ -282,16 +281,18 @@ set_malicious (struct GNUNET_PeerIdentity *peer) * * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int insert_stat - (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, - unsigned int route_forwards, unsigned int result_requests, - unsigned int client_requests, unsigned int result_forwards, - unsigned int gets, unsigned int puts, - unsigned int data_inserts, unsigned int find_peer_requests, - unsigned int find_peers_started, unsigned int gets_started, - unsigned int puts_started, unsigned int find_peer_responses_received, - unsigned int get_responses_received, unsigned int find_peer_responses_sent, - unsigned int get_responses_sent) +int insert_stat (const struct GNUNET_PeerIdentity *peer, + unsigned int route_requests, unsigned int route_forwards, + unsigned int result_requests, unsigned int client_requests, + unsigned int result_forwards, unsigned int gets, + unsigned int puts, unsigned int data_inserts, + unsigned int find_peer_requests, + unsigned int find_peers_started, unsigned int gets_started, + unsigned int puts_started, + unsigned int find_peer_responses_received, + unsigned int get_responses_received, + unsigned int find_peer_responses_sent, + unsigned int get_responses_sent) { return GNUNET_OK; } diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c index c653f912a..33028fb09 100644 --- a/src/dht/plugin_dhtlog_mysql.c +++ b/src/dht/plugin_dhtlog_mysql.c @@ -73,8 +73,7 @@ struct StatementHandle * @param values values returned by MySQL * @return GNUNET_OK to continue iterating, GNUNET_SYSERR to abort */ -typedef int (*GNUNET_MysqlDataProcessor) (void *cls, - unsigned int num_values, +typedef int (*GNUNET_MysqlDataProcessor) (void *cls, unsigned int num_values, MYSQL_BIND * values); static unsigned long max_varchar_len; @@ -203,128 +202,121 @@ itable () { #define MRUNS(a) (GNUNET_OK != run_statement (a) ) - if (MRUNS ("CREATE TABLE IF NOT EXISTS `dhtkeys` (" - "dhtkeyuid int(10) unsigned NOT NULL auto_increment COMMENT 'Unique Key given to each query'," - "`dhtkey` varchar(255) NOT NULL COMMENT 'The ASCII value of the key being searched for'," - "trialuid int(10) unsigned NOT NULL," - "keybits blob NOT NULL," - "UNIQUE KEY `dhtkeyuid` (`dhtkeyuid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `dhtkeys` (" + "dhtkeyuid int(10) unsigned NOT NULL auto_increment COMMENT 'Unique Key given to each query'," + "`dhtkey` varchar(255) NOT NULL COMMENT 'The ASCII value of the key being searched for'," + "trialuid int(10) unsigned NOT NULL," "keybits blob NOT NULL," + "UNIQUE KEY `dhtkeyuid` (`dhtkeyuid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `nodes` (" - "`nodeuid` int(10) unsigned NOT NULL auto_increment," - "`trialuid` int(10) unsigned NOT NULL," - "`nodeid` varchar(255) NOT NULL," - "`nodebits` blob NOT NULL," - "PRIMARY KEY (`nodeuid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `nodes` (" + "`nodeuid` int(10) unsigned NOT NULL auto_increment," + "`trialuid` int(10) unsigned NOT NULL," "`nodeid` varchar(255) NOT NULL," + "`nodebits` blob NOT NULL," "PRIMARY KEY (`nodeuid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `queries` (" - "`trialuid` int(10) unsigned NOT NULL," - "`queryuid` int(10) unsigned NOT NULL auto_increment," - "`dhtqueryid` bigint(20) NOT NULL," - "`querytype` enum('1','2','3','4','5') NOT NULL," - "`hops` int(10) unsigned NOT NULL," - "`succeeded` tinyint NOT NULL," - "`nodeuid` int(10) unsigned NOT NULL," - "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," - "`dhtkeyuid` int(10) unsigned NOT NULL," - "PRIMARY KEY (`queryuid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `queries` (" + "`trialuid` int(10) unsigned NOT NULL," + "`queryuid` int(10) unsigned NOT NULL auto_increment," + "`dhtqueryid` bigint(20) NOT NULL," + "`querytype` enum('1','2','3','4','5') NOT NULL," + "`hops` int(10) unsigned NOT NULL," "`succeeded` tinyint NOT NULL," + "`nodeuid` int(10) unsigned NOT NULL," + "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," + "`dhtkeyuid` int(10) unsigned NOT NULL," "PRIMARY KEY (`queryuid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `routes` (" - "`trialuid` int(10) unsigned NOT NULL," - "`queryuid` int(10) unsigned NOT NULL auto_increment," - "`dhtqueryid` bigint(20) NOT NULL," - "`querytype` enum('1','2','3','4','5') NOT NULL," - "`hops` int(10) unsigned NOT NULL," - "`succeeded` tinyint NOT NULL," - "`nodeuid` int(10) unsigned NOT NULL," - "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," - "`dhtkeyuid` int(10) unsigned NOT NULL," - "`from_node` int(10) unsigned NOT NULL," - "`to_node` int(10) unsigned NOT NULL," - "PRIMARY KEY (`queryuid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `routes` (" + "`trialuid` int(10) unsigned NOT NULL," + "`queryuid` int(10) unsigned NOT NULL auto_increment," + "`dhtqueryid` bigint(20) NOT NULL," + "`querytype` enum('1','2','3','4','5') NOT NULL," + "`hops` int(10) unsigned NOT NULL," "`succeeded` tinyint NOT NULL," + "`nodeuid` int(10) unsigned NOT NULL," + "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," + "`dhtkeyuid` int(10) unsigned NOT NULL," + "`from_node` int(10) unsigned NOT NULL," + "`to_node` int(10) unsigned NOT NULL," "PRIMARY KEY (`queryuid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `trials` (" - "`trialuid` int(10) unsigned NOT NULL auto_increment," - "`other_trial_identifier` int(10) unsigned NOT NULL default '0'," - "`numnodes` int(10) unsigned NOT NULL," - "`topology` int(10) NOT NULL," - "`blacklist_topology` int(11) NOT NULL," - "`connect_topology` int(11) NOT NULL," - "`connect_topology_option` int(11) NOT NULL," - "`topology_percentage` float NOT NULL," - "`topology_probability` float NOT NULL," - "`connect_topology_option_modifier` float NOT NULL," - "`starttime` datetime NOT NULL," - "`endtime` datetime NOT NULL," - "`puts` int(10) unsigned NOT NULL," - "`gets` int(10) unsigned NOT NULL," - "`concurrent` int(10) unsigned NOT NULL," - "`settle_time` int(10) unsigned NOT NULL," - "`totalConnections` int(10) unsigned NOT NULL," - "`message` text NOT NULL," - "`num_rounds` int(10) unsigned NOT NULL," - "`malicious_getters` int(10) unsigned NOT NULL," - "`malicious_putters` int(10) unsigned NOT NULL," - "`malicious_droppers` int(10) unsigned NOT NULL," - "`topology_modifier` double NOT NULL," - "`malicious_get_frequency` int(10) unsigned NOT NULL," - "`malicious_put_frequency` int(10) unsigned NOT NULL," - "`stop_closest` int(10) unsigned NOT NULL," - "`stop_found` int(10) unsigned NOT NULL," - "`strict_kademlia` int(10) unsigned NOT NULL," - "`gets_succeeded` int(10) unsigned NOT NULL," - "PRIMARY KEY (`trialuid`)," - "UNIQUE KEY `trialuid` (`trialuid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `trials` (" + "`trialuid` int(10) unsigned NOT NULL auto_increment," + "`other_trial_identifier` int(10) unsigned NOT NULL default '0'," + "`numnodes` int(10) unsigned NOT NULL," "`topology` int(10) NOT NULL," + "`blacklist_topology` int(11) NOT NULL," + "`connect_topology` int(11) NOT NULL," + "`connect_topology_option` int(11) NOT NULL," + "`topology_percentage` float NOT NULL," + "`topology_probability` float NOT NULL," + "`connect_topology_option_modifier` float NOT NULL," + "`starttime` datetime NOT NULL," "`endtime` datetime NOT NULL," + "`puts` int(10) unsigned NOT NULL," "`gets` int(10) unsigned NOT NULL," + "`concurrent` int(10) unsigned NOT NULL," + "`settle_time` int(10) unsigned NOT NULL," + "`totalConnections` int(10) unsigned NOT NULL," + "`message` text NOT NULL," "`num_rounds` int(10) unsigned NOT NULL," + "`malicious_getters` int(10) unsigned NOT NULL," + "`malicious_putters` int(10) unsigned NOT NULL," + "`malicious_droppers` int(10) unsigned NOT NULL," + "`topology_modifier` double NOT NULL," + "`malicious_get_frequency` int(10) unsigned NOT NULL," + "`malicious_put_frequency` int(10) unsigned NOT NULL," + "`stop_closest` int(10) unsigned NOT NULL," + "`stop_found` int(10) unsigned NOT NULL," + "`strict_kademlia` int(10) unsigned NOT NULL," + "`gets_succeeded` int(10) unsigned NOT NULL," + "PRIMARY KEY (`trialuid`)," "UNIQUE KEY `trialuid` (`trialuid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `topology` (" - "`topology_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," - "`trialuid` int(10) unsigned NOT NULL," - "`date` datetime NOT NULL," - "`connections` int(10) unsigned NOT NULL," - "PRIMARY KEY (`topology_uid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `topology` (" + "`topology_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," + "`trialuid` int(10) unsigned NOT NULL," "`date` datetime NOT NULL," + "`connections` int(10) unsigned NOT NULL," + "PRIMARY KEY (`topology_uid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `extended_topology` (" - "`extended_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," - "`topology_uid` int(10) unsigned NOT NULL," - "`uid_first` int(10) unsigned NOT NULL," - "`uid_second` int(10) unsigned NOT NULL," - "PRIMARY KEY (`extended_uid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `extended_topology` (" + "`extended_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," + "`topology_uid` int(10) unsigned NOT NULL," + "`uid_first` int(10) unsigned NOT NULL," + "`uid_second` int(10) unsigned NOT NULL," "PRIMARY KEY (`extended_uid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; - if (MRUNS ("CREATE TABLE IF NOT EXISTS `node_statistics` (" - "`stat_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," - "`trialuid` int(10) unsigned NOT NULL," - "`nodeuid` int(10) unsigned NOT NULL," - "`route_requests` int(10) unsigned NOT NULL," - "`route_forwards` int(10) unsigned NOT NULL," - "`result_requests` int(10) unsigned NOT NULL," - "`client_results` int(10) unsigned NOT NULL," - "`result_forwards` int(10) unsigned NOT NULL," - "`gets` int(10) unsigned NOT NULL," - "`puts` int(10) unsigned NOT NULL," - "`data_inserts` int(10) unsigned NOT NULL," - "`find_peer_requests` int(10) unsigned NOT NULL," - "`find_peers_started` int(10) unsigned NOT NULL," - "`gets_started` int(10) unsigned NOT NULL," - "`puts_started` int(10) unsigned NOT NULL," - "`find_peer_responses_received` int(10) unsigned NOT NULL," - "`get_responses_received` int(10) unsigned NOT NULL," - "`find_peer_responses_sent` int(10) unsigned NOT NULL," - "`get_responses_sent` int(10) unsigned NOT NULL," - "PRIMARY KEY (`stat_uid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")) + if (MRUNS + ("CREATE TABLE IF NOT EXISTS `node_statistics` (" + "`stat_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," + "`trialuid` int(10) unsigned NOT NULL," + "`nodeuid` int(10) unsigned NOT NULL," + "`route_requests` int(10) unsigned NOT NULL," + "`route_forwards` int(10) unsigned NOT NULL," + "`result_requests` int(10) unsigned NOT NULL," + "`client_results` int(10) unsigned NOT NULL," + "`result_forwards` int(10) unsigned NOT NULL," + "`gets` int(10) unsigned NOT NULL," "`puts` int(10) unsigned NOT NULL," + "`data_inserts` int(10) unsigned NOT NULL," + "`find_peer_requests` int(10) unsigned NOT NULL," + "`find_peers_started` int(10) unsigned NOT NULL," + "`gets_started` int(10) unsigned NOT NULL," + "`puts_started` int(10) unsigned NOT NULL," + "`find_peer_responses_received` int(10) unsigned NOT NULL," + "`get_responses_received` int(10) unsigned NOT NULL," + "`find_peer_responses_sent` int(10) unsigned NOT NULL," + "`get_responses_sent` int(10) unsigned NOT NULL," + "PRIMARY KEY (`stat_uid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")) return GNUNET_SYSERR; if (MRUNS ("SET AUTOCOMMIT = 1")) @@ -388,37 +380,37 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin) if (conn == NULL) return GNUNET_SYSERR; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, - "MYSQL", "DATABASE", - &database)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "DATABASE", + &database)) { database = GNUNET_strdup ("gnunet"); } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, - "MYSQL", "USER", - &user)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "USER", + &user)) { user = GNUNET_strdup ("dht"); } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, - "MYSQL", "PASSWORD", - &password)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "PASSWORD", + &password)) { password = GNUNET_strdup ("dhttest**"); } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, - "MYSQL", "SERVER", - &server)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "SERVER", + &server)) { server = GNUNET_strdup ("localhost"); } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (plugin->cfg, - "MYSQL", "MYSQL_PORT", - &port)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (plugin->cfg, "MYSQL", "MYSQL_PORT", + &port)) { port = 0; } @@ -434,9 +426,8 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin) mysql_options (conn, MYSQL_SET_CHARSET_NAME, "UTF8"); mysql_options (conn, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout); mysql_options (conn, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout); - mysql_real_connect (conn, server, user, password, - database, (unsigned int) port, NULL, - CLIENT_IGNORE_SIGPIPE); + mysql_real_connect (conn, server, user, password, database, + (unsigned int) port, NULL, CLIENT_IGNORE_SIGPIPE); GNUNET_free_non_null (server); GNUNET_free_non_null (password); @@ -508,8 +499,8 @@ prepare_statement (struct StatementHandle *ret) if (mysql_stmt_prepare (ret->statement, ret->query, strlen (ret->query))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "mysql_stmt_prepare `%s', %s", ret->query, mysql_error (conn)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "mysql_stmt_prepare `%s', %s", + ret->query, mysql_error (conn)); mysql_stmt_close (ret->statement); ret->statement = NULL; return GNUNET_SYSERR; @@ -588,8 +579,8 @@ init_params (struct StatementHandle *s, va_list ap) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_param", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_bind_param", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); return GNUNET_SYSERR; } @@ -597,8 +588,8 @@ init_params (struct StatementHandle *s, va_list ap) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_execute", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_execute", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); return GNUNET_SYSERR; } @@ -623,10 +614,9 @@ init_params (struct StatementHandle *s, va_list ap) */ int prepared_statement_run_select (struct StatementHandle *s, - unsigned int result_size, - MYSQL_BIND * results, - GNUNET_MysqlDataProcessor - processor, void *processor_cls, ...) + unsigned int result_size, MYSQL_BIND * results, + GNUNET_MysqlDataProcessor processor, + void *processor_cls, ...) { va_list ap; int ret; @@ -656,8 +646,8 @@ prepared_statement_run_select (struct StatementHandle *s, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_bind_result", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_bind_result", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); return GNUNET_SYSERR; } @@ -671,8 +661,8 @@ prepared_statement_run_select (struct StatementHandle *s, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), - "mysql_stmt_fetch", - __FILE__, __LINE__, mysql_stmt_error (s->statement)); + "mysql_stmt_fetch", __FILE__, __LINE__, + mysql_stmt_error (s->statement)); return GNUNET_SYSERR; } if (processor != NULL) @@ -700,17 +690,11 @@ get_node_uid (unsigned long long *nodeuid, const GNUNET_HashCode * peerHash) GNUNET_CRYPTO_hash_to_enc (peerHash, &encPeer); p_len = strlen ((char *) &encPeer); - if (1 != prepared_statement_run_select (get_nodeuid, - 1, - rbind, - return_ok, - NULL, - MYSQL_TYPE_LONGLONG, - ¤t_trial, - GNUNET_YES, - MYSQL_TYPE_VAR_STRING, - &encPeer, - max_varchar_len, &p_len, -1)) + if (1 != + prepared_statement_run_select (get_nodeuid, 1, rbind, return_ok, NULL, + MYSQL_TYPE_LONGLONG, ¤t_trial, + GNUNET_YES, MYSQL_TYPE_VAR_STRING, + &encPeer, max_varchar_len, &p_len, -1)) { #if DEBUG_DHTLOG fprintf (stderr, "FAILED\n"); @@ -731,8 +715,8 @@ get_current_trial (unsigned long long *trialuid) rbind[0].buffer = trialuid; if ((GNUNET_OK != - prepared_statement_run_select (get_trial, - 1, rbind, return_ok, NULL, -1))) + prepared_statement_run_select (get_trial, 1, rbind, return_ok, NULL, + -1))) { return GNUNET_SYSERR; } @@ -751,8 +735,8 @@ get_current_topology (unsigned long long *topologyuid) rbind[0].buffer = topologyuid; if ((GNUNET_OK != - prepared_statement_run_select (get_topology, - 1, rbind, return_ok, NULL, -1))) + prepared_statement_run_select (get_topology, 1, rbind, return_ok, NULL, + -1))) { return GNUNET_SYSERR; } @@ -779,16 +763,11 @@ get_dhtkey_uid (unsigned long long *dhtkeyuid, const GNUNET_HashCode * key) current_trial); #endif if ((GNUNET_OK != - prepared_statement_run_select (get_dhtkeyuid, - 1, - rbind, - return_ok, NULL, - MYSQL_TYPE_VAR_STRING, - &encKey, - max_varchar_len, - &k_len, - MYSQL_TYPE_LONGLONG, - ¤t_trial, GNUNET_YES, -1))) + prepared_statement_run_select (get_dhtkeyuid, 1, rbind, return_ok, NULL, + MYSQL_TYPE_VAR_STRING, &encKey, + max_varchar_len, &k_len, + MYSQL_TYPE_LONGLONG, ¤t_trial, + GNUNET_YES, -1))) { return GNUNET_SYSERR; } @@ -860,51 +839,46 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) stmt = mysql_stmt_init (conn); if (GNUNET_OK != - (ret = prepared_statement_run (insert_trial, ¤t_trial, - MYSQL_TYPE_LONG, - &trial_info->other_identifier, GNUNET_YES, - MYSQL_TYPE_LONG, &trial_info->num_nodes, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->topology, GNUNET_YES, - MYSQL_TYPE_FLOAT, - &trial_info->topology_percentage, - MYSQL_TYPE_FLOAT, - &trial_info->topology_probability, - MYSQL_TYPE_LONG, - &trial_info->blacklist_topology, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->connect_topology, GNUNET_YES, - MYSQL_TYPE_LONG, - &trial_info->connect_topology_option, - GNUNET_YES, MYSQL_TYPE_FLOAT, - &trial_info->connect_topology_option_modifier, - MYSQL_TYPE_LONG, &trial_info->puts, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->gets, GNUNET_YES, - MYSQL_TYPE_LONG, &trial_info->concurrent, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->settle_time, GNUNET_YES, - MYSQL_TYPE_LONG, &trial_info->num_rounds, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->malicious_getters, GNUNET_YES, - MYSQL_TYPE_LONG, - &trial_info->malicious_putters, GNUNET_YES, - MYSQL_TYPE_LONG, - &trial_info->malicious_droppers, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->malicious_get_frequency, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->malicious_put_frequency, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->stop_closest, GNUNET_YES, - MYSQL_TYPE_LONG, &trial_info->stop_found, - GNUNET_YES, MYSQL_TYPE_LONG, - &trial_info->strict_kademlia, GNUNET_YES, - MYSQL_TYPE_LONG, - &trial_info->gets_succeeded, GNUNET_YES, - MYSQL_TYPE_BLOB, trial_info->message, - max_varchar_len + max_varchar_len, &m_len, - -1))) + (ret = + prepared_statement_run (insert_trial, ¤t_trial, MYSQL_TYPE_LONG, + &trial_info->other_identifier, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->num_nodes, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->topology, GNUNET_YES, + MYSQL_TYPE_FLOAT, + &trial_info->topology_percentage, + MYSQL_TYPE_FLOAT, + &trial_info->topology_probability, + MYSQL_TYPE_LONG, &trial_info->blacklist_topology, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->connect_topology, GNUNET_YES, + MYSQL_TYPE_LONG, + &trial_info->connect_topology_option, GNUNET_YES, + MYSQL_TYPE_FLOAT, + &trial_info->connect_topology_option_modifier, + MYSQL_TYPE_LONG, &trial_info->puts, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->gets, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->concurrent, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->settle_time, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->num_rounds, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->malicious_getters, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->malicious_putters, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->malicious_droppers, GNUNET_YES, + MYSQL_TYPE_LONG, + &trial_info->malicious_get_frequency, GNUNET_YES, + MYSQL_TYPE_LONG, + &trial_info->malicious_put_frequency, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->stop_closest, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->stop_found, GNUNET_YES, + MYSQL_TYPE_LONG, &trial_info->strict_kademlia, + GNUNET_YES, MYSQL_TYPE_LONG, + &trial_info->gets_succeeded, GNUNET_YES, + MYSQL_TYPE_BLOB, trial_info->message, + max_varchar_len + max_varchar_len, &m_len, -1))) { if (ret == GNUNET_SYSERR) { @@ -935,11 +909,11 @@ add_round (unsigned int round_type, unsigned int round_count) int ret; stmt = mysql_stmt_init (conn); - ret = prepared_statement_run (insert_round, - NULL, - MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, - MYSQL_TYPE_LONG, &round_type, GNUNET_YES, - MYSQL_TYPE_LONG, &round_count, GNUNET_YES, -1); + ret = + prepared_statement_run (insert_round, NULL, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, + &round_type, GNUNET_YES, MYSQL_TYPE_LONG, + &round_count, GNUNET_YES, -1); mysql_stmt_close (stmt); if (ret != GNUNET_OK) return GNUNET_SYSERR; @@ -966,14 +940,13 @@ add_round_details (unsigned int round_type, unsigned int round_count, int ret; stmt = mysql_stmt_init (conn); - ret = prepared_statement_run (insert_round_details, - NULL, - MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, - MYSQL_TYPE_LONG, &round_type, GNUNET_YES, - MYSQL_TYPE_LONG, &round_count, GNUNET_YES, - MYSQL_TYPE_LONG, &num_messages, GNUNET_YES, - MYSQL_TYPE_LONG, &num_messages_succeeded, - GNUNET_YES, -1); + ret = + prepared_statement_run (insert_round_details, NULL, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, + &round_type, GNUNET_YES, MYSQL_TYPE_LONG, + &round_count, GNUNET_YES, MYSQL_TYPE_LONG, + &num_messages, GNUNET_YES, MYSQL_TYPE_LONG, + &num_messages_succeeded, GNUNET_YES, -1); mysql_stmt_close (stmt); if (ret != GNUNET_OK) return GNUNET_SYSERR; @@ -1007,10 +980,10 @@ int add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, unsigned int route_forwards, unsigned int result_requests, unsigned int client_requests, unsigned int result_forwards, - unsigned int gets, unsigned int puts, - unsigned int data_inserts, unsigned int find_peer_requests, - unsigned int find_peers_started, unsigned int gets_started, - unsigned int puts_started, unsigned int find_peer_responses_received, + unsigned int gets, unsigned int puts, unsigned int data_inserts, + unsigned int find_peer_requests, unsigned int find_peers_started, + unsigned int gets_started, unsigned int puts_started, + unsigned int find_peer_responses_received, unsigned int get_responses_received, unsigned int find_peer_responses_sent, unsigned int get_responses_sent) @@ -1030,33 +1003,28 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, stmt = mysql_stmt_init (conn); if (GNUNET_OK != - (ret = prepared_statement_run (insert_stat, - &return_uid, - MYSQL_TYPE_LONGLONG, ¤t_trial, - GNUNET_YES, MYSQL_TYPE_LONGLONG, &peer_uid, - GNUNET_YES, MYSQL_TYPE_LONG, - &route_requests, GNUNET_YES, - MYSQL_TYPE_LONG, &route_forwards, - GNUNET_YES, MYSQL_TYPE_LONG, - &result_requests, GNUNET_YES, - MYSQL_TYPE_LONG, &client_requests, - GNUNET_YES, MYSQL_TYPE_LONG, - &result_forwards, GNUNET_YES, - MYSQL_TYPE_LONG, &gets, GNUNET_YES, - MYSQL_TYPE_LONG, &puts, GNUNET_YES, - MYSQL_TYPE_LONG, &data_inserts, GNUNET_YES, - MYSQL_TYPE_LONG, &find_peer_requests, - GNUNET_YES, MYSQL_TYPE_LONG, - &find_peers_started, GNUNET_YES, - MYSQL_TYPE_LONG, &gets_started, GNUNET_YES, - MYSQL_TYPE_LONG, &puts_started, GNUNET_YES, - MYSQL_TYPE_LONG, - &find_peer_responses_received, GNUNET_YES, - MYSQL_TYPE_LONG, &get_responses_received, - GNUNET_YES, MYSQL_TYPE_LONG, - &find_peer_responses_sent, GNUNET_YES, - MYSQL_TYPE_LONG, &get_responses_sent, - GNUNET_YES, -1))) + (ret = + prepared_statement_run (insert_stat, &return_uid, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &peer_uid, GNUNET_YES, MYSQL_TYPE_LONG, + &route_requests, GNUNET_YES, MYSQL_TYPE_LONG, + &route_forwards, GNUNET_YES, MYSQL_TYPE_LONG, + &result_requests, GNUNET_YES, MYSQL_TYPE_LONG, + &client_requests, GNUNET_YES, MYSQL_TYPE_LONG, + &result_forwards, GNUNET_YES, MYSQL_TYPE_LONG, + &gets, GNUNET_YES, MYSQL_TYPE_LONG, &puts, + GNUNET_YES, MYSQL_TYPE_LONG, &data_inserts, + GNUNET_YES, MYSQL_TYPE_LONG, &find_peer_requests, + GNUNET_YES, MYSQL_TYPE_LONG, &find_peers_started, + GNUNET_YES, MYSQL_TYPE_LONG, &gets_started, + GNUNET_YES, MYSQL_TYPE_LONG, &puts_started, + GNUNET_YES, MYSQL_TYPE_LONG, + &find_peer_responses_received, GNUNET_YES, + MYSQL_TYPE_LONG, &get_responses_received, + GNUNET_YES, MYSQL_TYPE_LONG, + &find_peer_responses_sent, GNUNET_YES, + MYSQL_TYPE_LONG, &get_responses_sent, GNUNET_YES, + -1))) { if (ret == GNUNET_SYSERR) { @@ -1080,8 +1048,8 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -add_generic_stat (const struct GNUNET_PeerIdentity *peer, - const char *name, const char *section, uint64_t value) +add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, + const char *section, uint64_t value) { unsigned long long peer_uid; unsigned long long section_len; @@ -1100,16 +1068,14 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer, name_len = strlen (name); if (GNUNET_OK != - (ret = prepared_statement_run (insert_generic_stat, - NULL, - MYSQL_TYPE_LONGLONG, ¤t_trial, - GNUNET_YES, MYSQL_TYPE_LONGLONG, &peer_uid, - GNUNET_YES, MYSQL_TYPE_VAR_STRING, - §ion, max_varchar_len, §ion_len, - MYSQL_TYPE_VAR_STRING, &name, - max_varchar_len, &name_len, - MYSQL_TYPE_LONGLONG, &value, GNUNET_YES, - -1))) + (ret = + prepared_statement_run (insert_generic_stat, NULL, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &peer_uid, GNUNET_YES, MYSQL_TYPE_VAR_STRING, + §ion, max_varchar_len, §ion_len, + MYSQL_TYPE_VAR_STRING, &name, max_varchar_len, + &name_len, MYSQL_TYPE_LONGLONG, &value, + GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { @@ -1157,18 +1123,12 @@ add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) } if (GNUNET_OK != - (ret = prepared_statement_run (insert_dhtkey, - dhtkeyuid, - MYSQL_TYPE_VAR_STRING, - &encKey, - max_varchar_len, - &k_len, - MYSQL_TYPE_LONG, - ¤t_trial, - GNUNET_YES, - MYSQL_TYPE_BLOB, - dhtkey, - sizeof (GNUNET_HashCode), &h_len, -1))) + (ret = + prepared_statement_run (insert_dhtkey, dhtkeyuid, MYSQL_TYPE_VAR_STRING, + &encKey, max_varchar_len, &k_len, + MYSQL_TYPE_LONG, ¤t_trial, GNUNET_YES, + MYSQL_TYPE_BLOB, dhtkey, + sizeof (GNUNET_HashCode), &h_len, -1))) { if (ret == GNUNET_SYSERR) { @@ -1204,13 +1164,12 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity *node) p_len = (unsigned long) strlen ((char *) &encPeer); h_len = sizeof (GNUNET_HashCode); if (GNUNET_OK != - (ret = prepared_statement_run (insert_node, - nodeuid, - MYSQL_TYPE_LONGLONG, ¤t_trial, - GNUNET_YES, MYSQL_TYPE_VAR_STRING, - &encPeer, max_varchar_len, &p_len, - MYSQL_TYPE_BLOB, &node->hashPubKey, - sizeof (GNUNET_HashCode), &h_len, -1))) + (ret = + prepared_statement_run (insert_node, nodeuid, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, + MYSQL_TYPE_VAR_STRING, &encPeer, max_varchar_len, + &p_len, MYSQL_TYPE_BLOB, &node->hashPubKey, + sizeof (GNUNET_HashCode), &h_len, -1))) { if (ret == GNUNET_SYSERR) { @@ -1233,11 +1192,10 @@ update_trials (unsigned int gets_succeeded) int ret; if (GNUNET_OK != - (ret = prepared_statement_run (update_trial, - NULL, - MYSQL_TYPE_LONG, &gets_succeeded, - GNUNET_YES, MYSQL_TYPE_LONGLONG, - ¤t_trial, GNUNET_YES, -1))) + (ret = + prepared_statement_run (update_trial, NULL, MYSQL_TYPE_LONG, + &gets_succeeded, GNUNET_YES, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { @@ -1270,11 +1228,11 @@ set_malicious (struct GNUNET_PeerIdentity *peer) p_len = strlen (temp_str); if (GNUNET_OK != - (ret = prepared_statement_run (update_node_malicious, - NULL, - MYSQL_TYPE_LONGLONG, ¤t_trial, - GNUNET_YES, MYSQL_TYPE_VAR_STRING, - temp_str, max_varchar_len, &p_len, -1))) + (ret = + prepared_statement_run (update_node_malicious, NULL, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, + MYSQL_TYPE_VAR_STRING, temp_str, max_varchar_len, + &p_len, -1))) { if (ret == GNUNET_SYSERR) { @@ -1298,13 +1256,11 @@ add_connections (unsigned int totalConnections) int ret; if (GNUNET_OK != - (ret = prepared_statement_run (update_connection, - NULL, - MYSQL_TYPE_LONG, - &totalConnections, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - ¤t_trial, GNUNET_YES, -1))) + (ret = + prepared_statement_run (update_connection, NULL, MYSQL_TYPE_LONG, + &totalConnections, GNUNET_YES, + MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, + -1))) { if (ret == GNUNET_SYSERR) { @@ -1341,8 +1297,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, peer_uid = 0; key_uid = 0; - if ((node != NULL) - && (GNUNET_OK == get_node_uid (&peer_uid, &node->hashPubKey))) + if ((node != NULL) && + (GNUNET_OK == get_node_uid (&peer_uid, &node->hashPubKey))) { } @@ -1365,28 +1321,15 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, } if (GNUNET_OK != - (ret = prepared_statement_run (insert_query, - sqlqueryuid, - MYSQL_TYPE_LONGLONG, - ¤t_trial, - GNUNET_YES, - MYSQL_TYPE_LONG, - &type, - GNUNET_NO, - MYSQL_TYPE_LONG, - &hops, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &key_uid, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &queryid, - GNUNET_YES, - MYSQL_TYPE_LONG, - &succeeded, - GNUNET_NO, - MYSQL_TYPE_LONGLONG, - &peer_uid, GNUNET_YES, -1))) + (ret = + prepared_statement_run (insert_query, sqlqueryuid, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, + &type, GNUNET_NO, MYSQL_TYPE_LONG, &hops, + GNUNET_YES, MYSQL_TYPE_LONGLONG, &key_uid, + GNUNET_YES, MYSQL_TYPE_LONGLONG, &queryid, + GNUNET_YES, MYSQL_TYPE_LONG, &succeeded, + GNUNET_NO, MYSQL_TYPE_LONGLONG, &peer_uid, + GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { @@ -1416,9 +1359,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, */ int add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, - unsigned int type, unsigned int hops, - int succeeded, const struct GNUNET_PeerIdentity *node, - const GNUNET_HashCode * key, + unsigned int type, unsigned int hops, int succeeded, + const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *from_node, const struct GNUNET_PeerIdentity *to_node) { @@ -1457,34 +1399,17 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, return GNUNET_SYSERR; if (GNUNET_OK != - (ret = prepared_statement_run (insert_route, - sqlqueryuid, - MYSQL_TYPE_LONGLONG, - ¤t_trial, - GNUNET_YES, - MYSQL_TYPE_LONG, - &type, - GNUNET_NO, - MYSQL_TYPE_LONG, - &hops, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &key_uid, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &queryid, - GNUNET_YES, - MYSQL_TYPE_LONG, - &succeeded, - GNUNET_NO, - MYSQL_TYPE_LONGLONG, - &peer_uid, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &from_uid, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &to_uid, GNUNET_YES, -1))) + (ret = + prepared_statement_run (insert_route, sqlqueryuid, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, + &type, GNUNET_NO, MYSQL_TYPE_LONG, &hops, + GNUNET_YES, MYSQL_TYPE_LONGLONG, &key_uid, + GNUNET_YES, MYSQL_TYPE_LONGLONG, &queryid, + GNUNET_YES, MYSQL_TYPE_LONG, &succeeded, + GNUNET_NO, MYSQL_TYPE_LONGLONG, &peer_uid, + GNUNET_YES, MYSQL_TYPE_LONGLONG, &from_uid, + GNUNET_YES, MYSQL_TYPE_LONGLONG, &to_uid, + GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { @@ -1513,13 +1438,10 @@ update_current_topology (unsigned int connections) get_current_topology (&topologyuid); if (GNUNET_OK != - (ret = prepared_statement_run (update_topology, - NULL, - MYSQL_TYPE_LONG, - &connections, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &topologyuid, GNUNET_YES, -1))) + (ret = + prepared_statement_run (update_topology, NULL, MYSQL_TYPE_LONG, + &connections, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &topologyuid, GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { @@ -1545,11 +1467,10 @@ add_topology (int num_connections) int ret; if (GNUNET_OK != - (ret = prepared_statement_run (insert_topology, - NULL, - MYSQL_TYPE_LONGLONG, ¤t_trial, - GNUNET_YES, MYSQL_TYPE_LONG, - &num_connections, GNUNET_YES, -1))) + (ret = + prepared_statement_run (insert_topology, NULL, MYSQL_TYPE_LONGLONG, + ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, + &num_connections, GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { @@ -1586,16 +1507,11 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, return GNUNET_SYSERR; if (GNUNET_OK != - (ret = prepared_statement_run (extend_topology, - NULL, - MYSQL_TYPE_LONGLONG, - &topologyuid, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &first_uid, - GNUNET_YES, - MYSQL_TYPE_LONGLONG, - &second_uid, GNUNET_YES, -1))) + (ret = + prepared_statement_run (extend_topology, NULL, MYSQL_TYPE_LONGLONG, + &topologyuid, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &first_uid, GNUNET_YES, MYSQL_TYPE_LONGLONG, + &second_uid, GNUNET_YES, -1))) { if (ret == GNUNET_SYSERR) { diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 25958044c..bbb1da0c9 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c @@ -162,24 +162,16 @@ static int iopen () { #define PINIT(a) (GNUNET_OK != (prepared_statement_create(a))) - if (PINIT (INSERT_QUERIES_STMT) || - PINIT (INSERT_ROUTES_STMT) || - PINIT (INSERT_ROUND_STMT) || - PINIT (INSERT_ROUND_DETAILS_STMT) || - PINIT (INSERT_TRIALS_STMT) || - PINIT (SET_MALICIOUS_STMT) || - PINIT (INSERT_GENERIC_STAT_STMT) || - PINIT (INSERT_STAT_STMT) || - PINIT (INSERT_NODES_STMT) || - PINIT (INSERT_DHTKEY_STMT) || - PINIT (UPDATE_TRIALS_STMT) || - PINIT (GET_DHTKEYUID_STMT) || - PINIT (GET_NODEUID_STMT) || - PINIT (UPDATE_CONNECTIONS_STMT) || - PINIT (INSERT_TOPOLOGY_STMT) || - PINIT (EXTEND_TOPOLOGY_STMT) || - PINIT (UPDATE_TOPOLOGY_STMT) || - PINIT (GET_TRIAL_STMT) || PINIT (GET_TOPOLOGY_STMT)) + if (PINIT (INSERT_QUERIES_STMT) || PINIT (INSERT_ROUTES_STMT) || + PINIT (INSERT_ROUND_STMT) || PINIT (INSERT_ROUND_DETAILS_STMT) || + PINIT (INSERT_TRIALS_STMT) || PINIT (SET_MALICIOUS_STMT) || + PINIT (INSERT_GENERIC_STAT_STMT) || PINIT (INSERT_STAT_STMT) || + PINIT (INSERT_NODES_STMT) || PINIT (INSERT_DHTKEY_STMT) || + PINIT (UPDATE_TRIALS_STMT) || PINIT (GET_DHTKEYUID_STMT) || + PINIT (GET_NODEUID_STMT) || PINIT (UPDATE_CONNECTIONS_STMT) || + PINIT (INSERT_TOPOLOGY_STMT) || PINIT (EXTEND_TOPOLOGY_STMT) || + PINIT (UPDATE_TOPOLOGY_STMT) || PINIT (GET_TRIAL_STMT) || + PINIT (GET_TOPOLOGY_STMT)) { return GNUNET_SYSERR; } @@ -325,8 +317,10 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, if (ret < 0) return GNUNET_SYSERR; - ret = fprintf (outfile, "execute extend_topology using " - "@temp_first_node, @temp_second_node;\n"); + ret = + fprintf (outfile, + "execute extend_topology using " + "@temp_first_node, @temp_second_node;\n"); if (ret >= 0) return GNUNET_OK; @@ -376,13 +370,13 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) if (ret < 0) return GNUNET_SYSERR; - ret = fprintf (outfile, "execute insert_trial using " - "@date, @oid, @num, @topology, @t_p, @t_pr," - " @bl, @connect, @c_t_o," - "@c_t_o_m, @puts, @gets," - "@concurrent, @settle, @rounds," - "@m_gets, @m_puts, @m_drops," - "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); + ret = + fprintf (outfile, + "execute insert_trial using " + "@date, @oid, @num, @topology, @t_p, @t_pr," + " @bl, @connect, @c_t_o," "@c_t_o_m, @puts, @gets," + "@concurrent, @settle, @rounds," "@m_gets, @m_puts, @m_drops," + "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); if (ret < 0) return GNUNET_SYSERR; ret = fprintf (outfile, "execute select_trial;\n"); @@ -404,8 +398,8 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -add_generic_stat (const struct GNUNET_PeerIdentity *peer, - const char *name, const char *section, uint64_t value) +add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, + const char *section, uint64_t value) { int ret; @@ -466,10 +460,10 @@ int add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, unsigned int route_forwards, unsigned int result_requests, unsigned int client_requests, unsigned int result_forwards, - unsigned int gets, unsigned int puts, - unsigned int data_inserts, unsigned int find_peer_requests, - unsigned int find_peers_started, unsigned int gets_started, - unsigned int puts_started, unsigned int find_peer_responses_received, + unsigned int gets, unsigned int puts, unsigned int data_inserts, + unsigned int find_peer_requests, unsigned int find_peers_started, + unsigned int gets_started, unsigned int puts_started, + unsigned int find_peer_responses_received, unsigned int get_responses_received, unsigned int find_peer_responses_sent, unsigned int get_responses_sent) @@ -489,25 +483,27 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, if (ret < 0) return GNUNET_SYSERR; - ret = fprintf (outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " - "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " - "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, " - "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n", - route_requests, route_forwards, result_requests, - client_requests, result_forwards, gets, puts, - data_inserts, find_peer_requests, find_peers_started, - gets_started, puts_started, find_peer_responses_received, - get_responses_received, find_peer_responses_sent, - get_responses_sent); + ret = + fprintf (outfile, + "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " + "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " + "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, " + "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n", + route_requests, route_forwards, result_requests, client_requests, + result_forwards, gets, puts, data_inserts, find_peer_requests, + find_peers_started, gets_started, puts_started, + find_peer_responses_received, get_responses_received, + find_peer_responses_sent, get_responses_sent); if (ret < 0) return GNUNET_SYSERR; - ret = fprintf (outfile, "execute insert_stat using " - "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, " - "@res_f, @gets, @puts, @d_i, " - "@f_p_r, @f_p_s, @g_s, @p_s, " - "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); + ret = + fprintf (outfile, + "execute insert_stat using " + "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, " + "@res_f, @gets, @puts, @d_i, " "@f_p_r, @f_p_s, @g_s, @p_s, " + "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); if (ret < 0) return GNUNET_SYSERR; return GNUNET_OK; @@ -784,9 +780,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, */ int add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, - unsigned int type, unsigned int hops, - int succeeded, const struct GNUNET_PeerIdentity *node, - const GNUNET_HashCode * key, + unsigned int type, unsigned int hops, int succeeded, + const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *from_node, const struct GNUNET_PeerIdentity *to_node) { @@ -882,15 +877,15 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MySQL (DUMP) DHT Logger: initializing\n"); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, - "MYSQLDUMP", "PATH", - &outfile_path)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQLDUMP", "PATH", + &outfile_path)) { outfile_path = GNUNET_strdup (""); } - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump", + getpid ()); fn = GNUNET_STRINGS_filename_expand (outfile_name); diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index 7c3f67942..fada2029e 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c @@ -222,31 +222,33 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) if (outfile == NULL) return GNUNET_SYSERR; - ret = fprintf (outfile, "INSERT INTO trials " - "(starttime, other_trial_identifier, numnodes, topology," - "blacklist_topology, connect_topology, connect_topology_option," - "connect_topology_option_modifier, topology_percentage, topology_probability," - "puts, gets, " - "concurrent, settle_time, num_rounds, malicious_getters," - "malicious_putters, malicious_droppers, malicious_get_frequency," - "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, " - "gets_succeeded, message) " - "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n", - get_sql_time (), trial_info->other_identifier, - trial_info->num_nodes, trial_info->topology, - trial_info->blacklist_topology, trial_info->connect_topology, - trial_info->connect_topology_option, - trial_info->connect_topology_option_modifier, - trial_info->topology_percentage, - trial_info->topology_probability, trial_info->puts, - trial_info->gets, trial_info->concurrent, - trial_info->settle_time, trial_info->num_rounds, - trial_info->malicious_getters, trial_info->malicious_putters, - trial_info->malicious_droppers, - trial_info->malicious_get_frequency, - trial_info->malicious_put_frequency, trial_info->stop_closest, - trial_info->stop_found, trial_info->strict_kademlia, - trial_info->gets_succeeded, trial_info->message); + ret = + fprintf (outfile, + "INSERT INTO trials " + "(starttime, other_trial_identifier, numnodes, topology," + "blacklist_topology, connect_topology, connect_topology_option," + "connect_topology_option_modifier, topology_percentage, topology_probability," + "puts, gets, " + "concurrent, settle_time, num_rounds, malicious_getters," + "malicious_putters, malicious_droppers, malicious_get_frequency," + "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, " + "gets_succeeded, message) " + "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n", + get_sql_time (), trial_info->other_identifier, + trial_info->num_nodes, trial_info->topology, + trial_info->blacklist_topology, trial_info->connect_topology, + trial_info->connect_topology_option, + trial_info->connect_topology_option_modifier, + trial_info->topology_percentage, + trial_info->topology_probability, trial_info->puts, + trial_info->gets, trial_info->concurrent, + trial_info->settle_time, trial_info->num_rounds, + trial_info->malicious_getters, trial_info->malicious_putters, + trial_info->malicious_droppers, + trial_info->malicious_get_frequency, + trial_info->malicious_put_frequency, trial_info->stop_closest, + trial_info->stop_found, trial_info->strict_kademlia, + trial_info->gets_succeeded, trial_info->message); if (ret < 0) return GNUNET_SYSERR; @@ -273,8 +275,8 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -add_generic_stat (const struct GNUNET_PeerIdentity *peer, - const char *name, const char *section, uint64_t value) +add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, + const char *section, uint64_t value) { if (outfile == NULL) return GNUNET_SYSERR; @@ -315,10 +317,10 @@ int add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, unsigned int route_forwards, unsigned int result_requests, unsigned int client_requests, unsigned int result_forwards, - unsigned int gets, unsigned int puts, - unsigned int data_inserts, unsigned int find_peer_requests, - unsigned int find_peers_started, unsigned int gets_started, - unsigned int puts_started, unsigned int find_peer_responses_received, + unsigned int gets, unsigned int puts, unsigned int data_inserts, + unsigned int find_peer_requests, unsigned int find_peers_started, + unsigned int gets_started, unsigned int puts_started, + unsigned int find_peer_responses_received, unsigned int get_responses_received, unsigned int find_peer_responses_sent, unsigned int get_responses_sent) @@ -568,9 +570,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, */ int add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, - unsigned int type, unsigned int hops, - int succeeded, const struct GNUNET_PeerIdentity *node, - const GNUNET_HashCode * key, + unsigned int type, unsigned int hops, int succeeded, + const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *from_node, const struct GNUNET_PeerIdentity *to_node) { @@ -636,15 +637,15 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MySQL (DUMP) DHT Logger: initializing\n"); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, - "MYSQLDUMP", "PATH", - &outfile_path)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQLDUMP", "PATH", + &outfile_path)) { outfile_path = GNUNET_strdup (""); } - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump", + getpid ()); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -674,8 +675,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump_nodes", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_nodes", + getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -705,8 +706,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump_routes", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_routes", + getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -737,8 +738,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump_queries", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_queries", + getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -769,8 +770,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump_stats", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_stats", + getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -801,9 +802,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", - outfile_path, "mysqldump_generic_stats", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, + "mysqldump_generic_stats", getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -833,8 +833,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", outfile_path, "mysqldump_dhtkey", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_dhtkey", + getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); @@ -864,9 +864,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) } GNUNET_free (outfile_name); - GNUNET_asprintf (&outfile_name, - "%s%s-%d", - outfile_path, "mysqldump_extended_topology", getpid ()); + GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, + "mysqldump_extended_topology", getpid ()); GNUNET_free (fn); fn = GNUNET_STRINGS_filename_expand (outfile_name); diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 407e2279b..9fc5c2d7a 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c @@ -237,8 +237,8 @@ test_find_peer_processor (void *cls, const struct GNUNET_HELLO_Message *hello) * @param cls closure * @param tc context information (why was this task triggered now?) */ -void -retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +void retry_find_peer_stop (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** * Retry the find_peer task on timeout. @@ -330,8 +330,7 @@ test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) retry_context.next_timeout = BASE_TIMEOUT; retry_context.peer_ctx = peer; - peer->find_peer_handle - = + peer->find_peer_handle = GNUNET_DHT_find_peer_start (peer->dht_handle, retry_context.next_timeout, &hash, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, &test_find_peer_processor, &retry_context); @@ -374,8 +373,7 @@ test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } void -test_get_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, +test_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, @@ -409,13 +407,10 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) retry_context.next_timeout = BASE_TIMEOUT; peer->get_handle = - GNUNET_DHT_get_start (peer->dht_handle, - TOTAL_TIMEOUT, - GNUNET_BLOCK_TYPE_TEST, - &hash, - DEFAULT_GET_REPLICATION, - GNUNET_DHT_RO_NONE, - NULL, 0, NULL, 0, &test_get_iterator, NULL); + GNUNET_DHT_get_start (peer->dht_handle, TOTAL_TIMEOUT, + GNUNET_BLOCK_TYPE_TEST, &hash, + DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, + 0, NULL, 0, &test_get_iterator, NULL); if (peer->get_handle == NULL) { @@ -450,11 +445,8 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (peer->dht_handle != NULL); - GNUNET_DHT_put (peer->dht_handle, &hash, - DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_NONE, - GNUNET_BLOCK_TYPE_TEST, - data_size, data, + GNUNET_DHT_put (peer->dht_handle, &hash, DEFAULT_PUT_REPLICATION, + GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, data_size, data, GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT), TOTAL_TIMEOUT, &test_get, &p1); GNUNET_free (data); @@ -465,28 +457,29 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 1), - &end_badly, NULL); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 1), &end_badly, + NULL); setup_peer (&p1, "test_dht_api_peer1.conf"); @@ -512,8 +505,8 @@ check () }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-dht-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-dht-api", "nohelp", options, &run, &ok); stop_arm (&p1); return ok; } diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index 3bbf44be1..779aff88d 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c @@ -394,8 +394,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param data pointer to the result data */ void -get_result_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, +get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, @@ -473,15 +472,11 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Insert the data at the first peer */ GNUNET_assert (test_get->dht_handle != NULL); outstanding_gets++; - test_get->get_handle = GNUNET_DHT_get_start (test_get->dht_handle, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_TEST, - &key, - DEFAULT_GET_REPLICATION, - route_option, - NULL, 0, - NULL, 0, - &get_result_iterator, test_get); + test_get->get_handle = + GNUNET_DHT_get_start (test_get->dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BLOCK_TYPE_TEST, &key, + DEFAULT_GET_REPLICATION, route_option, NULL, 0, + NULL, 0, &get_result_iterator, test_get); #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", test_get->uid, test_get->daemon->shortname); @@ -546,14 +541,10 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (test_put->dht_handle != NULL); outstanding_puts++; - GNUNET_DHT_put (test_put->dht_handle, - &key, - DEFAULT_PUT_REPLICATION, - route_option, - GNUNET_BLOCK_TYPE_TEST, - sizeof (data), data, - GNUNET_TIME_UNIT_FOREVER_ABS, - GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, test_put); + GNUNET_DHT_put (test_put->dht_handle, &key, DEFAULT_PUT_REPLICATION, + route_option, GNUNET_BLOCK_TYPE_TEST, sizeof (data), data, + GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, + &put_finished, test_put); test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), &put_disconnect_task, test_put); @@ -616,10 +607,8 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * failure (peers failed to connect). */ void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -653,9 +642,9 @@ topology_callback (void *cls, total_connections); #endif GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from setup puts/gets"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from setup puts/gets"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), @@ -671,8 +660,7 @@ topology_callback (void *cls, } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -702,16 +690,14 @@ peers_started_callback (void *cls, expected_connections = -1; if ((pg != NULL) && (peers_left == 0)) { - expected_connections = GNUNET_TESTING_connect_topology (pg, - connection_topology, - connect_topology_option, - connect_topology_option_modifier, - TIMEOUT, - num_peers, - NULL, NULL); + expected_connections = + GNUNET_TESTING_connect_topology (pg, connection_topology, + connect_topology_option, + connect_topology_option_modifier, + TIMEOUT, num_peers, NULL, NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Have %d expected connections\n", expected_connections); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", + expected_connections); #endif } @@ -722,9 +708,9 @@ peers_started_callback (void *cls, "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from connect topology (timeout)"); ok = 0; } @@ -751,9 +737,9 @@ create_topology () "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from continue startup (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from continue startup (timeout)"); } /** @@ -765,8 +751,7 @@ create_topology () * @param emsg non-null on failure */ void -hostkey_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_TESTING_Daemon *d, const char *emsg) { if (emsg != NULL) @@ -777,8 +762,8 @@ hostkey_callback (void *cls, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey (%d/%d) created for peer `%s'\n", - num_peers - peers_left, num_peers, GNUNET_i2s (id)); + "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, + num_peers, GNUNET_i2s (id)); #endif @@ -792,9 +777,9 @@ hostkey_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from create_topology"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from create_topology"); GNUNET_SCHEDULER_add_now (&create_topology, NULL); ok = 0; } @@ -802,9 +787,8 @@ hostkey_callback (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *topology_str; char *connect_topology_str; @@ -962,9 +946,9 @@ check () GNUNET_GETOPT_OPTION_END }; /* Run the run function as a new program */ - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-dht-multipeer", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-dht-multipeer", "nohelp", options, &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index 6ba3799dc..50a27a093 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c @@ -155,8 +155,7 @@ static void do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); * @param data pointer to the result data */ void -get_result_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, +get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, @@ -200,8 +199,8 @@ get_result_iterator (void *cls, } -static void -stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void stop_retry_get (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); static void get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) @@ -260,24 +259,20 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (GNUNET_TIME_UNIT_SECONDS, 10), &stop_retry_get, get_context); - get_context->get_handle = GNUNET_DHT_get_start (get_context->dht_handle, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 5), - GNUNET_BLOCK_TYPE_DHT_HELLO, - &get_context-> - peer->hashPubKey, - DEFAULT_GET_REPLICATION, - GNUNET_DHT_RO_NONE, NULL, 0, - NULL, 0, &get_result_iterator, - get_context); + get_context->get_handle = + GNUNET_DHT_get_start (get_context->dht_handle, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 5), + GNUNET_BLOCK_TYPE_DHT_HELLO, + &get_context->peer->hashPubKey, + DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, + 0, NULL, 0, &get_result_iterator, get_context); } void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -311,8 +306,8 @@ topology_callback (void *cls, total_connections); #endif GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, "from test gets"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); curr_get_ctx.dht_handle = peer1dht; curr_get_ctx.peer = &peer2id; @@ -334,12 +329,10 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { expected_connections = -1; if ((pg != NULL) && (peers_left == 0)) - expected_connections = GNUNET_TESTING_connect_topology (pg, - GNUNET_TESTING_TOPOLOGY_CLIQUE, - GNUNET_TESTING_TOPOLOGY_OPTION_ALL, - 0.0, - TIMEOUT, 12, NULL, - NULL); + expected_connections = + GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, + GNUNET_TESTING_TOPOLOGY_OPTION_ALL, + 0.0, TIMEOUT, 12, NULL, NULL); GNUNET_SCHEDULER_cancel (die_task); if (expected_connections == GNUNET_SYSERR) @@ -348,14 +341,13 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "from connect topology (bad return)"); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from connect topology (timeout)"); } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -399,9 +391,9 @@ peers_started_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from peers_started_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from peers_started_callback"); GNUNET_SCHEDULER_add_now (&connect_topology, NULL); ok = 0; @@ -409,9 +401,8 @@ peers_started_callback (void *cls, } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { if (GNUNET_YES != @@ -431,18 +422,13 @@ run (void *cls, total_gets = num_peers; gets_succeeded = 0; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "didn't start all daemons in reasonable amount of time!!!"); - - pg = GNUNET_TESTING_daemons_start (cfg, - num_peers, - 10, - num_peers, - TIMEOUT, - NULL, NULL, - &peers_started_callback, - NULL, &topology_callback, NULL, NULL); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "didn't start all daemons in reasonable amount of time!!!"); + + pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 10, num_peers, TIMEOUT, + NULL, NULL, &peers_started_callback, NULL, + &topology_callback, NULL, NULL); } @@ -462,9 +448,9 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-dht-twopeer", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-dht-twopeer", "nohelp", options, &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/dht/test_dht_twopeer_path_tracking.c b/src/dht/test_dht_twopeer_path_tracking.c index ab0b1edd2..9985939ae 100644 --- a/src/dht/test_dht_twopeer_path_tracking.c +++ b/src/dht/test_dht_twopeer_path_tracking.c @@ -188,8 +188,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param data pointer to the result data */ void -get_result_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, +get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, @@ -262,9 +261,9 @@ static void put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, - &end_badly, - "waiting for get response (data not found)"); + die_task = + GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly, + "waiting for get response (data not found)"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); } @@ -282,13 +281,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) memset (data, 43, sizeof (data)); /* Insert the data at the first peer */ - GNUNET_DHT_put (peer1dht, - &key, - DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_RECORD_ROUTE, - GNUNET_BLOCK_TYPE_TEST, - sizeof (data), data, - GNUNET_TIME_UNIT_FOREVER_ABS, + GNUNET_DHT_put (peer1dht, &key, DEFAULT_PUT_REPLICATION, + GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_BLOCK_TYPE_TEST, + sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL); } @@ -302,10 +297,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * failure (peers failed to connect). */ void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -339,8 +332,8 @@ topology_callback (void *cls, total_connections); #endif GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, "from test gets"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); @@ -367,8 +360,7 @@ topology_callback (void *cls, * @param emsg NULL if peer started, non-NULL on error */ static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -415,12 +407,10 @@ peers_started_callback (void *cls, if ((pg != NULL)) /* Sanity check */ { /* Connect peers in a "straight line" topology, return the number of expected connections */ - expected_connections = GNUNET_TESTING_connect_topology (pg, - GNUNET_TESTING_TOPOLOGY_LINE, - GNUNET_TESTING_TOPOLOGY_OPTION_ALL, - 0.0, - TIMEOUT, - 2, NULL, NULL); + expected_connections = + GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE, + GNUNET_TESTING_TOPOLOGY_OPTION_ALL, + 0.0, TIMEOUT, 2, NULL, NULL); } /* Cancel current timeout fail task */ @@ -431,17 +421,16 @@ peers_started_callback (void *cls, "from connect topology (bad return)"); /* Schedule timeout on failure task */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from connect topology (timeout)"); ok = 0; } } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { /* Get path from configuration file */ @@ -463,20 +452,18 @@ run (void *cls, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "didn't start all daemons in reasonable amount of time!!!"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "didn't start all daemons in reasonable amount of time!!!"); /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ /* Read the API documentation for other parameters! */ pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ peers_left, /* Number of outstanding connections */ peers_left, /* Number of parallel ssh connections, or peers being started at once */ - TIMEOUT, - NULL, - NULL, - &peers_started_callback, - NULL, &topology_callback, NULL, NULL); + TIMEOUT, NULL, NULL, + &peers_started_callback, NULL, + &topology_callback, NULL, NULL); } @@ -498,9 +485,10 @@ check () GNUNET_GETOPT_OPTION_END }; /* Run the run function as a new program */ - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-dht-twopeer-put-get", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-dht-twopeer-put-get", "nohelp", options, &run, + &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c index 9db0ca385..8e77837b2 100644 --- a/src/dht/test_dht_twopeer_put_get.c +++ b/src/dht/test_dht_twopeer_put_get.c @@ -210,13 +210,12 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param data pointer to the result data */ void -get_result_iterator (void *cls, - struct GNUNET_TIME_Absolute exp, +get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, - enum GNUNET_BLOCK_Type type, - size_t size, const void *result_data) + enum GNUNET_BLOCK_Type type, size_t size, + const void *result_data) { GNUNET_HashCode original_key; /* Key data was stored data under */ char original_data[4]; /* Made up data that was stored */ @@ -273,9 +272,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #else GNUNET_BLOCK_TYPE_TEST, #endif - &key, - DEFAULT_GET_REPLICATION, - GNUNET_DHT_RO_NONE, + &key, DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, 0, NULL, 0, &get_result_iterator, NULL); } @@ -287,9 +284,9 @@ static void put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, - &end_badly, - "waiting for get response (data not found)"); + die_task = + GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly, + "waiting for get response (data not found)"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); } @@ -309,14 +306,10 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) memset (data, 43, sizeof (data)); /* Insert the data at the first peer */ - GNUNET_DHT_put (peer1dht, - &key, - DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_NONE, - GNUNET_BLOCK_TYPE_TEST, - sizeof (data), data, - GNUNET_TIME_UNIT_FOREVER_ABS, - GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL); + GNUNET_DHT_put (peer1dht, &key, DEFAULT_PUT_REPLICATION, GNUNET_DHT_RO_NONE, + GNUNET_BLOCK_TYPE_TEST, sizeof (data), data, + GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, + &put_finished, NULL); } #else @@ -353,24 +346,19 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); /* Sign the block */ - if (GNUNET_OK != GNUNET_CRYPTO_rsa_sign (my_private_key, - &data.purpose, &data.signature)) + if (GNUNET_OK != + GNUNET_CRYPTO_rsa_sign (my_private_key, &data.purpose, &data.signature)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not sign DNS_Record\n"); return; } GNUNET_CRYPTO_rsa_key_free (my_private_key); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Putting with key %08x\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting with key %08x\n", *((unsigned int *) &data.service_descriptor)); - GNUNET_DHT_put (peer1dht, - &data.service_descriptor, - DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_NONE, - GNUNET_BLOCK_TYPE_DNS, - size, + GNUNET_DHT_put (peer1dht, &data.service_descriptor, DEFAULT_PUT_REPLICATION, + GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_DNS, size, (char *) &data, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS), GNUNET_TIME_UNIT_MINUTES, &put_finished, NULL); @@ -387,10 +375,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * failure (peers failed to connect). */ void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -424,8 +410,8 @@ topology_callback (void *cls, total_connections); #endif GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, "from test gets"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); @@ -452,8 +438,7 @@ topology_callback (void *cls, * @param emsg NULL if peer started, non-NULL on error */ static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -500,12 +485,10 @@ peers_started_callback (void *cls, if ((pg != NULL)) /* Sanity check */ { /* Connect peers in a "straight line" topology, return the number of expected connections */ - expected_connections = GNUNET_TESTING_connect_topology (pg, - GNUNET_TESTING_TOPOLOGY_LINE, - GNUNET_TESTING_TOPOLOGY_OPTION_ALL, - 0.0, - TIMEOUT, - 12, NULL, NULL); + expected_connections = + GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE, + GNUNET_TESTING_TOPOLOGY_OPTION_ALL, + 0.0, TIMEOUT, 12, NULL, NULL); } /* Cancel current timeout fail task */ @@ -516,17 +499,16 @@ peers_started_callback (void *cls, "from connect topology (bad return)"); /* Schedule timeout on failure task */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from connect topology (timeout)"); ok = 0; } } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { /* Get path from configuration file */ @@ -548,21 +530,15 @@ run (void *cls, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "didn't start all daemons in reasonable amount of time!!!"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "didn't start all daemons in reasonable amount of time!!!"); /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ /* Read the API documentation for other parameters! */ - pg = GNUNET_TESTING_daemons_start (cfg, - num_peers, - 2, - 2, - TIMEOUT, - NULL, - NULL, - &peers_started_callback, - NULL, &topology_callback, NULL, NULL); + pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 2, 2, TIMEOUT, NULL, NULL, + &peers_started_callback, NULL, + &topology_callback, NULL, NULL); } @@ -584,9 +560,10 @@ check () GNUNET_GETOPT_OPTION_END }; /* Run the run function as a new program */ - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-dht-twopeer-put-get", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-dht-twopeer-put-get", "nohelp", options, &run, + &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c index 4021f5db5..89ec97d6c 100644 --- a/src/dht/test_dhtlog.c +++ b/src/dht/test_dhtlog.c @@ -195,9 +195,8 @@ test (struct GNUNET_DHTLOG_Handle *api) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DHTLOG_Handle *api; @@ -229,8 +228,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-dhtlog-api", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-dhtlog-api", "nohelp", options, &run, NULL); if (ok != 0) fprintf (stderr, "Test failed with error code: %d\n", ok); return ok; diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 7a250b5a6..3450e5844 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c @@ -282,15 +282,13 @@ process_pending_message (struct GNUNET_DV_Handle *handle) handle->current->next = NULL; if (NULL == - (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, - ntohs - (handle->current-> - msg->header.size), - handle->current-> - msg->timeout, - GNUNET_YES, - &transmit_pending, - handle))) + (handle->th = + GNUNET_CLIENT_notify_transmit_ready (handle->client, + ntohs (handle->current->msg->header. + size), + handle->current->msg->timeout, + GNUNET_YES, &transmit_pending, + handle))) { #if DEBUG_DV GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -397,12 +395,10 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg) ntohl (received_msg->distance)); #endif - handle->receive_handler (handle->receive_cls, - &received_msg->sender, - packed_msg, - packed_msg_len, - ntohl (received_msg->distance), - sender_address, sender_address_len); + handle->receive_handler (handle->receive_cls, &received_msg->sender, + packed_msg, packed_msg_len, + ntohl (received_msg->distance), sender_address, + sender_address_len); GNUNET_free (sender_address); break; @@ -431,9 +427,8 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg) default: break; } - GNUNET_CLIENT_receive (handle->client, - &handle_message_receipt, - handle, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (handle->client, &handle_message_receipt, handle, + GNUNET_TIME_UNIT_FOREVER_REL); } /** @@ -454,14 +449,11 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg) */ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - const void *addr, - size_t addrlen, - GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) + const struct GNUNET_PeerIdentity *target, const char *msgbuf, + size_t msgbuf_size, unsigned int priority, + struct GNUNET_TIME_Relative timeout, const void *addr, + size_t addrlen, GNUNET_TRANSPORT_TransmitContinuation cont, + void *cont_cls) { struct GNUNET_DV_SendMessage *msg; struct SendCallbackContext *send_ctx; @@ -537,9 +529,8 @@ transmit_start (void *cls, size_t size, void *buf) memcpy (buf, start_context->message, tsize); GNUNET_free (start_context->message); GNUNET_free (start_context); - GNUNET_CLIENT_receive (handle->client, - &handle_message_receipt, - handle, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (handle->client, &handle_message_receipt, handle, + GNUNET_TIME_UNIT_FOREVER_REL); return tsize; diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 4b68f69b1..876d056ac 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -662,8 +662,7 @@ static unsigned long long max_table_size; * respective neighbor. */ static int -find_destination (void *cls, - struct GNUNET_CONTAINER_HeapNode *node, +find_destination (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost) { struct FindDestinationContext *fdc = cls; @@ -752,21 +751,20 @@ transmit_to_plugin (void *cls, size_t size, void *buf) while ((NULL != (reply = plugin_pending_head)) && (size >= off + (msize = ntohs (reply->msg->size)))) { - GNUNET_CONTAINER_DLL_remove (plugin_pending_head, - plugin_pending_tail, reply); + GNUNET_CONTAINER_DLL_remove (plugin_pending_head, plugin_pending_tail, + reply); memcpy (&cbuf[off], reply->msg, msize); GNUNET_free (reply); off += msize; } if (plugin_pending_head != NULL) - plugin_transmit_handle = GNUNET_SERVER_notify_transmit_ready (client_handle, - ntohs - (plugin_pending_head->msg-> - size), - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_plugin, - NULL); + plugin_transmit_handle = + GNUNET_SERVER_notify_transmit_ready (client_handle, + ntohs (plugin_pending_head-> + msg->size), + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_plugin, NULL); return off; } @@ -783,8 +781,7 @@ transmit_to_plugin (void *cls, size_t size, void *buf) */ void send_to_plugin (const struct GNUNET_PeerIdentity *sender, - const struct GNUNET_MessageHeader *message, - size_t message_size, + const struct GNUNET_MessageHeader *message, size_t message_size, struct GNUNET_PeerIdentity *distant_neighbor, size_t cost) { struct GNUNET_DV_MessageReceived *received_msg; @@ -877,14 +874,13 @@ try_core_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; /* Message send already in progress */ if ((pending != NULL) && (coreAPI != NULL)) - core_transmit_handle = GNUNET_CORE_notify_transmit_ready (coreAPI, - GNUNET_YES, - pending->importance, - pending->timeout, - &pending->recipient, - pending->msg_size, - &core_transmit_notify, - NULL); + core_transmit_handle = + GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES, + pending->importance, + pending->timeout, + &pending->recipient, + pending->msg_size, + &core_transmit_notify, NULL); } @@ -1003,9 +999,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, find_context.via = recipient; find_context.tid = 0; GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, - &send_context-> - distant_peer->hashPubKey, - &find_specific_id, &find_context); + &send_context->distant_peer-> + hashPubKey, &find_specific_id, + &find_context); if (find_context.tid == 0) { @@ -1019,8 +1015,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, if (0 == (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity)))) { sender_id = 0; - source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, - &sender->hashPubKey); + source = + GNUNET_CONTAINER_multihashmap_get (extended_neighbors, + &sender->hashPubKey); if (source != NULL) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s: send_message_via found %s, myself in extended peer list???\n", @@ -1028,8 +1025,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, } else { - source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, - &sender->hashPubKey); + source = + GNUNET_CONTAINER_multihashmap_get (extended_neighbors, + &sender->hashPubKey); if (source == NULL) { /* sender unknown to us, drop! */ @@ -1067,8 +1065,7 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, "DV", &shortname, GNUNET_i2s (recipient), msg_size); #endif - GNUNET_CONTAINER_DLL_insert_after (core_pending_head, - core_pending_tail, + GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, core_pending_tail, pending_message); GNUNET_SCHEDULER_add_now (try_core_send, NULL); @@ -1117,10 +1114,9 @@ static int send_message (const struct GNUNET_PeerIdentity *recipient, const struct GNUNET_PeerIdentity *sender, const struct DistantNeighbor *specific_neighbor, - const struct GNUNET_MessageHeader *message, - size_t message_size, - unsigned int importance, - unsigned int uid, struct GNUNET_TIME_Relative timeout) + const struct GNUNET_MessageHeader *message, size_t message_size, + unsigned int importance, unsigned int uid, + struct GNUNET_TIME_Relative timeout) { p2p_dv_MESSAGE_Data *toSend; unsigned int msg_size; @@ -1160,12 +1156,13 @@ send_message (const struct GNUNET_PeerIdentity *recipient, } recipient_id = target->referrer_id; - source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, - &sender->hashPubKey); + source = + GNUNET_CONTAINER_multihashmap_get (extended_neighbors, + &sender->hashPubKey); if (source == NULL) { - if (0 != (memcmp (&my_identity, - sender, sizeof (struct GNUNET_PeerIdentity)))) + if (0 != + (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity)))) { /* sender unknown to us, drop! */ return GNUNET_SYSERR; @@ -1229,8 +1226,7 @@ send_message (const struct GNUNET_PeerIdentity *recipient, "%s: Sending message, but anticipate recipient will not know sender!!!\n\n\n", my_short_id); } - GNUNET_CONTAINER_DLL_insert_after (core_pending_head, - core_pending_tail, + GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, core_pending_tail, pending_message); #if DEBUG_DV GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1292,8 +1288,7 @@ checkPeerID (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ void -tokenized_message_handler (void *cls, - void *client, +tokenized_message_handler (void *cls, void *client, const struct GNUNET_MessageHeader *message) { struct TokenizedMessageContext *ctx = client; @@ -1335,13 +1330,9 @@ send_message_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (msg_ctx != NULL) { - send_message (&msg_ctx->dest, - &msg_ctx->sender, - NULL, - msg_ctx->message, - msg_ctx->message_size, - default_dv_priority, - msg_ctx->uid, GNUNET_TIME_relative_get_forever ()); + send_message (&msg_ctx->dest, &msg_ctx->sender, NULL, msg_ctx->message, + msg_ctx->message_size, default_dv_priority, msg_ctx->uid, + GNUNET_TIME_relative_get_forever ()); GNUNET_free (msg_ctx->message); GNUNET_free (msg_ctx); } @@ -1404,8 +1395,7 @@ get_atsi_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi) * @param atsi transport ATS information (latency, distance, etc.) */ static int -handle_dv_data_message (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_dv_data_message (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1478,8 +1468,9 @@ handle_dv_data_message (void *cls, } else { - pos = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, - &peer->hashPubKey); + pos = + GNUNET_CONTAINER_multihashmap_get (extended_neighbors, + &peer->hashPubKey); } #else pos = dn->referee_head; @@ -1547,11 +1538,9 @@ handle_dv_data_message (void *cls, tkm_ctx.peer = peer; tkm_ctx.distant = pos; tkm_ctx.uid = ntohl (incoming->uid); - if (GNUNET_OK != GNUNET_SERVER_mst_receive (coreMST, - &tkm_ctx, - cbuf, - packed_message_size, - GNUNET_NO, GNUNET_NO)) + if (GNUNET_OK != + GNUNET_SERVER_mst_receive (coreMST, &tkm_ctx, cbuf, packed_message_size, + GNUNET_NO, GNUNET_NO)) { GNUNET_break_op (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -1634,14 +1623,11 @@ handle_dv_data_message (void *cls, else #endif { - ret = send_message (destination, - original_sender, - NULL, - packed_message, - packed_message_size, - default_dv_priority, - ntohl (incoming->uid), - GNUNET_TIME_relative_get_forever ()); + ret = + send_message (destination, original_sender, NULL, packed_message, + packed_message_size, default_dv_priority, + ntohl (incoming->uid), + GNUNET_TIME_relative_get_forever ()); } if (ret != GNUNET_SYSERR) return GNUNET_OK; @@ -1756,17 +1742,17 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (about->hidden == GNUNET_NO) && #endif (to != NULL) && - (0 != memcmp (&about->identity, - &to->identity, sizeof (struct GNUNET_PeerIdentity))) && - (about->pkey != NULL)) + (0 != + memcmp (&about->identity, &to->identity, + sizeof (struct GNUNET_PeerIdentity))) && (about->pkey != NULL)) { #if DEBUG_DV_GOSSIP_SEND encPeerAbout = GNUNET_strdup (GNUNET_i2s (&about->identity)); encPeerTo = GNUNET_strdup (GNUNET_i2s (&to->identity)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Sending info about peer %s id %u to directly connected peer %s\n", - GNUNET_i2s (&my_identity), - encPeerAbout, about->our_id, encPeerTo); + GNUNET_i2s (&my_identity), encPeerAbout, about->our_id, + encPeerTo); GNUNET_free (encPeerAbout); GNUNET_free (encPeerTo); #endif @@ -1791,8 +1777,7 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) memcpy (&message->neighbor, &about->identity, sizeof (struct GNUNET_PeerIdentity)); - GNUNET_CONTAINER_DLL_insert_after (core_pending_head, - core_pending_tail, + GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, core_pending_tail, pending_message); GNUNET_SCHEDULER_add_now (try_core_send, NULL); @@ -1834,14 +1819,13 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param message the actual message */ static void -handle_start (void *cls, - struct GNUNET_SERVER_Client *client, +handle_start (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { #if DEBUG_DV - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' request from client\n", "START"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client\n", + "START"); #endif client_handle = client; @@ -1886,8 +1870,7 @@ send_iterator (void *cls, const GNUNET_HashCode * key, void *abs_value) * @param message the actual message */ void -handle_dv_send_message (void *cls, - struct GNUNET_SERVER_Client *client, +handle_dv_send_message (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_DV_SendMessage *send_msg; @@ -2139,8 +2122,8 @@ distant_neighbor_free (struct DistantNeighbor *referee) referrer = referee->referrer; if (referrer != NULL) { - GNUNET_CONTAINER_DLL_remove (referrer->referee_head, - referrer->referee_tail, referee); + GNUNET_CONTAINER_DLL_remove (referrer->referee_head, referrer->referee_tail, + referee); } GNUNET_CONTAINER_heap_remove_node (referee->max_loc); GNUNET_CONTAINER_heap_remove_node (referee->min_loc); @@ -2191,8 +2174,8 @@ direct_neighbor_free (struct DirectNeighbor *direct) * @return GNUNET_YES to continue iteration, GNUNET_NO to stop */ static int -schedule_disconnect_messages (void *cls, - const GNUNET_HashCode * key, void *value) +schedule_disconnect_messages (void *cls, const GNUNET_HashCode * key, + void *value) { struct DisconnectContext *disconnect_context = cls; struct DirectNeighbor *disconnected = disconnect_context->direct; @@ -2219,8 +2202,7 @@ schedule_disconnect_messages (void *cls, disconnect_message->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISCONNECT); disconnect_message->peer_id = htonl (disconnect_context->distant->our_id); - GNUNET_CONTAINER_DLL_insert_after (core_pending_head, - core_pending_tail, + GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, core_pending_tail, pending_message); GNUNET_SCHEDULER_add_now (try_core_send, NULL); @@ -2305,8 +2287,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * To be called on core init/fail. */ void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -2404,8 +2385,8 @@ update_matching_neighbors (void *cls, const GNUNET_HashCode * key, void *value) * @return GNUNET_YES to continue iteration, GNUNET_NO otherwise */ static int -add_distant_all_direct_neighbors (void *cls, - const GNUNET_HashCode * key, void *value) +add_distant_all_direct_neighbors (void *cls, const GNUNET_HashCode * key, + void *value) { struct DirectNeighbor *direct = (struct DirectNeighbor *) value; struct DistantNeighbor *distant = (struct DistantNeighbor *) cls; @@ -2541,13 +2522,13 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, #if DEBUG_DV_PEER_NUMBERS char *encAbout; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s Received sender id (%u)!\n", "DV SERVICE", referrer_peer_id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s Received sender id (%u)!\n", + "DV SERVICE", referrer_peer_id); #endif now = GNUNET_TIME_absolute_get (); - neighbor = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, - &peer->hashPubKey); + neighbor = + GNUNET_CONTAINER_multihashmap_get (extended_neighbors, &peer->hashPubKey); neighbor_update = GNUNET_malloc (sizeof (struct NeighborUpdateInfo)); neighbor_update->neighbor = neighbor; neighbor_update->cost = cost; @@ -2576,11 +2557,9 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, /* Either we do not know this peer, or we already do but via a different immediate peer */ if ((neighbor == NULL) || - (GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, - &peer->hashPubKey, - &update_matching_neighbors, - neighbor_update) != - GNUNET_SYSERR)) + (GNUNET_CONTAINER_multihashmap_get_multiple + (extended_neighbors, &peer->hashPubKey, &update_matching_neighbors, + neighbor_update) != GNUNET_SYSERR)) { #if AT_MOST_ONE if ((neighbor != NULL) && (cost < neighbor->cost)) /* New cost is less than old, remove old */ @@ -2630,12 +2609,12 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, } neighbor = GNUNET_malloc (sizeof (struct DistantNeighbor)); - GNUNET_CONTAINER_DLL_insert (referrer->referee_head, - referrer->referee_tail, neighbor); - neighbor->max_loc = GNUNET_CONTAINER_heap_insert (neighbor_max_heap, - neighbor, cost); - neighbor->min_loc = GNUNET_CONTAINER_heap_insert (neighbor_min_heap, - neighbor, cost); + GNUNET_CONTAINER_DLL_insert (referrer->referee_head, referrer->referee_tail, + neighbor); + neighbor->max_loc = + GNUNET_CONTAINER_heap_insert (neighbor_max_heap, neighbor, cost); + neighbor->min_loc = + GNUNET_CONTAINER_heap_insert (neighbor_min_heap, neighbor, cost); neighbor->referrer = referrer; memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); if (pkey != NULL) /* pkey will be null on direct neighbor addition */ @@ -2679,12 +2658,11 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, atsi[0].value = htonl (referrer->pending_messages[i].distance); atsi[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); atsi[1].value = - htonl ((uint32_t) referrer->pending_messages[i]. - latency.rel_value); + htonl ((uint32_t) referrer->pending_messages[i].latency. + rel_value); atsi[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); atsi[2].value = htonl (0); - handle_dv_data_message (NULL, - &referrer->pending_messages[i].sender, + handle_dv_data_message (NULL, &referrer->pending_messages[i].sender, referrer->pending_messages[i].message, (const struct GNUNET_TRANSPORT_ATS_Information *) &atsi); @@ -2733,9 +2711,8 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, #endif } #if DEBUG_DV - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "%s: Size of extended_neighbors is %d\n", "dv", - GNUNET_CONTAINER_multihashmap_size (extended_neighbors)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Size of extended_neighbors is %d\n", + "dv", GNUNET_CONTAINER_multihashmap_size (extended_neighbors)); #endif GNUNET_free (neighbor_update); @@ -2756,8 +2733,7 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, * @param atsi performance data */ static int -handle_dv_disconnect_message (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_dv_disconnect_message (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) @@ -2772,8 +2748,8 @@ handle_dv_disconnect_message (void *cls, return GNUNET_SYSERR; /* invalid message */ } - referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, - &peer->hashPubKey); + referrer = + GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); if (referrer == NULL) return GNUNET_OK; @@ -2806,8 +2782,7 @@ handle_dv_disconnect_message (void *cls, * @param atsi performance data */ static int -handle_dv_gossip_message (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_dv_gossip_message (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -2834,14 +2809,14 @@ handle_dv_gossip_message (void *cls, GNUNET_free (encPeerFrom); #endif - referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, - &peer->hashPubKey); + referrer = + GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); if (referrer == NULL) return GNUNET_OK; addUpdateNeighbor (&enc_message->neighbor, &enc_message->pkey, - ntohl (enc_message->neighbor_id), - referrer, ntohl (enc_message->cost) + 1); + ntohl (enc_message->neighbor_id), referrer, + ntohl (enc_message->cost) + 1); return GNUNET_OK; } @@ -2897,8 +2872,8 @@ add_all_extended_peers (void *cls, const GNUNET_HashCode * key, void *value) * GNUNET_NO if not. */ static int -gossip_all_to_all_iterator (void *cls, - const GNUNET_HashCode * key, void *abs_value) +gossip_all_to_all_iterator (void *cls, const GNUNET_HashCode * key, + void *abs_value) { struct DirectNeighbor *direct = abs_value; @@ -3007,8 +2982,7 @@ add_all_direct_neighbors (void *cls, const GNUNET_HashCode * key, void *value) * @param err_msg NULL if successful, otherwise contains error message */ static void -process_peerinfo (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_peerinfo (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { struct PeerIteratorContext *peerinfo_iterator = cls; @@ -3034,13 +3008,12 @@ process_peerinfo (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to get peerinfo information for this peer, retrying!\n"); #endif - peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle, - &peerinfo_iterator->neighbor-> - identity, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - 3), &process_peerinfo, - peerinfo_iterator); + peerinfo_iterator->ic = + GNUNET_PEERINFO_iterate (peerinfo_handle, + &peerinfo_iterator->neighbor->identity, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 3), + &process_peerinfo, peerinfo_iterator); } else { @@ -3111,8 +3084,7 @@ process_peerinfo (void *cls, * @param atsi performance data */ static void -handle_core_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct DirectNeighbor *neighbor; @@ -3146,12 +3118,11 @@ handle_core_connect (void *cls, about = addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST); peerinfo_iterator->distant = about; peerinfo_iterator->neighbor = neighbor; - peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle, - peer, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - 3), &process_peerinfo, - peerinfo_iterator); + peerinfo_iterator->ic = + GNUNET_PEERINFO_iterate (peerinfo_handle, peer, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 3), + &process_peerinfo, peerinfo_iterator); if ((about != NULL) && (about->pkey == NULL)) { @@ -3257,9 +3228,9 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) } GNUNET_assert (neighbor->referee_tail == NULL); - if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, - &peer->hashPubKey, - neighbor)) + if (GNUNET_NO == + GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, &peer->hashPubKey, + neighbor)) { GNUNET_break (0); } @@ -3278,8 +3249,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { unsigned long long max_hosts; @@ -3321,12 +3291,9 @@ run (void *cls, GNUNET_SERVER_add_handlers (server, plugin_handlers); coreAPI = GNUNET_CORE_connect (cfg, 1, NULL, /* FIXME: anything we want to pass around? */ - &core_init, - &handle_core_connect, - &handle_core_disconnect, - NULL, - NULL, - GNUNET_NO, NULL, GNUNET_NO, core_handlers); + &core_init, &handle_core_connect, + &handle_core_disconnect, NULL, NULL, GNUNET_NO, + NULL, GNUNET_NO, core_handlers); if (coreAPI == NULL) return; @@ -3342,8 +3309,9 @@ run (void *cls, } /* Scheduled the task to clean up when shutdown is called */ - cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + cleanup_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &shutdown_task, NULL); } @@ -3358,8 +3326,6 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "dv", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, argv, "dv", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 2803e347e..bd73e7e20 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c @@ -145,11 +145,8 @@ struct Plugin * Handler for messages received from the DV service. */ void -handle_dv_message_received (void *cls, - struct GNUNET_PeerIdentity *sender, - char *msg, - size_t msg_len, - uint32_t distance, +handle_dv_message_received (void *cls, struct GNUNET_PeerIdentity *sender, + char *msg, size_t msg_len, uint32_t distance, char *sender_address, size_t sender_address_len) { struct Plugin *plugin = cls; @@ -158,8 +155,7 @@ handle_dv_message_received (void *cls, char *my_id; my_id = GNUNET_strdup (GNUNET_i2s (plugin->env->my_identity)); - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "plugin_transport_dv", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "plugin_transport_dv", _("%s Received message from %s of type %d, distance %u!\n"), my_id, GNUNET_i2s (sender), ntohs (((struct GNUNET_MessageHeader *) msg)->type), @@ -173,8 +169,7 @@ handle_dv_message_received (void *cls, ats[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); ats[1].value = htonl (0); - plugin->env->receive (plugin->env->cls, - sender, + plugin->env->receive (plugin->env->cls, sender, (struct GNUNET_MessageHeader *) msg, (const struct GNUNET_TRANSPORT_ATS_Information *) &ats, 2, NULL, sender_address, sender_address_len); @@ -214,26 +209,18 @@ handle_dv_message_received (void *cls, * and does NOT mean that the message was not transmitted (DV) */ static ssize_t -dv_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - struct Session *session, - const void *addr, - size_t addrlen, - int force_address, +dv_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, + const char *msgbuf, size_t msgbuf_size, unsigned int priority, + struct GNUNET_TIME_Relative timeout, struct Session *session, + const void *addr, size_t addrlen, int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) { int ret = 0; struct Plugin *plugin = cls; - ret = GNUNET_DV_send (plugin->dv_handle, - target, - msgbuf, - msgbuf_size, - priority, timeout, addr, addrlen, cont, cont_cls); + ret = + GNUNET_DV_send (plugin->dv_handle, target, msgbuf, msgbuf_size, priority, + timeout, addr, addrlen, cont, cont_cls); return ret; } @@ -270,14 +257,11 @@ dv_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) * @param asc_cls closure for asc */ static void -dv_plugin_address_pretty_printer (void *cls, - const char *type, - const void *addr, - size_t addrlen, - int numeric, +dv_plugin_address_pretty_printer (void *cls, const char *type, const void *addr, + size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, - GNUNET_TRANSPORT_AddressStringCallback - asc, void *asc_cls) + GNUNET_TRANSPORT_AddressStringCallback asc, + void *asc_cls) { char *dest_peer; char *via_peer; @@ -337,8 +321,8 @@ address_to_string (void *cls, const void *addr, size_t addrlen) peer_hash.encoding[4] = '\0'; GNUNET_CRYPTO_hash_to_enc (&via->hashPubKey, &via_hash); via_hash.encoding[4] = '\0'; - GNUNET_snprintf (return_buffer, - sizeof (return_buffer), "%s:%s", &peer_hash, &via_hash); + GNUNET_snprintf (return_buffer, sizeof (return_buffer), "%s:%s", &peer_hash, + &via_hash); } else return NULL; diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 5d9d367e1..fee8eea81 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -285,15 +285,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Disconnect from the respective cores */ #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting from peer 1 `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); #endif if (pos->peer1handle != NULL) GNUNET_CORE_disconnect (pos->peer1handle); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting from peer 2 `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); #endif if (pos->peer2handle != NULL) @@ -384,8 +382,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } } -static void -send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void send_other_messages (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** * Get distance information from 'atsi'. @@ -409,8 +407,7 @@ get_atsi_distance (const struct GNUNET_TRANSPORT_ATS_Information *atsi) } static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -460,9 +457,9 @@ process_mtype (void *cls, (total_other_messages == 0)) { GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "waiting for DV peers to connect!"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "waiting for DV peers to connect!"); /* * if ((num_peers == 3) && (total_other_expected_messages == 2)) * { @@ -527,9 +524,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { * @param atsi performance data for the connection */ static void -connect_notify_peer2 (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_notify_peer2 (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct TestMessageContext *pos = cls; @@ -541,14 +536,11 @@ connect_notify_peer2 (void *cls, "Core connection from `%s' to `%4s' verfied, sending message!\n", GNUNET_i2s (&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey)); #endif - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - GNUNET_YES, - 0, - TIMEOUT, - &pos->peer2->id, - sizeof (struct - GNUNET_TestMessage), - &transmit_ready, pos)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, + TIMEOUT, &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) { /* This probably shouldn't happen, but it does (timing issue?) */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -565,8 +557,7 @@ connect_notify_peer2 (void *cls, } static void -init_notify_peer2 (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) @@ -588,9 +579,7 @@ init_notify_peer2 (void *cls, * @param atsi performance data for the connection */ static void -connect_notify_peer1 (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct TestMessageContext *pos = cls; @@ -605,21 +594,15 @@ connect_notify_peer1 (void *cls, /* * Connect to the receiving peer */ - pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, - 1, - pos, - &init_notify_peer2, - &connect_notify_peer2, - NULL, - NULL, NULL, - GNUNET_YES, NULL, GNUNET_YES, - handlers); + pos->peer2handle = + GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, + &connect_notify_peer2, NULL, NULL, NULL, + GNUNET_YES, NULL, GNUNET_YES, handlers); } } static void -init_notify_peer1 (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) @@ -643,9 +626,9 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (die_task == GNUNET_SCHEDULER_NO_TASK) { - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "from create topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "from create topology (timeout)"); } if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) @@ -663,16 +646,10 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* * Connect to the sending peer */ - pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, - 1, - pos, - &init_notify_peer1, - &connect_notify_peer1, - NULL, - NULL, - NULL, - GNUNET_NO, NULL, GNUNET_NO, - no_handlers); + pos->peer1handle = + GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1, + &connect_notify_peer1, NULL, NULL, NULL, GNUNET_NO, + NULL, GNUNET_NO, no_handlers); GNUNET_assert (pos->peer1handle != NULL); @@ -773,10 +750,8 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -859,15 +834,14 @@ connect_topology () expected_connections = -1; if ((pg != NULL) && (peers_left == 0)) { - expected_connections = GNUNET_TESTING_connect_topology (pg, - connection_topology, - connect_topology_option, - connect_topology_option_modifier, - TIMEOUT, - 12, NULL, NULL); + expected_connections = + GNUNET_TESTING_connect_topology (pg, connection_topology, + connect_topology_option, + connect_topology_option_modifier, + TIMEOUT, 12, NULL, NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Have %d expected connections\n", expected_connections); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", + expected_connections); #endif } @@ -879,9 +853,9 @@ connect_topology () "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "from connect topology (timeout)"); } static void @@ -905,9 +879,9 @@ create_topology () "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "from continue startup (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "from continue startup (timeout)"); } /** @@ -919,9 +893,7 @@ create_topology () * @param distance reported distance (DV) to 'other' */ static void -all_connect_handler (void *cls, - const struct - GNUNET_PeerIdentity *peer, +all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct GNUNET_TESTING_Daemon *d = cls; @@ -940,8 +912,8 @@ all_connect_handler (void *cls, #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "connected peer %s to peer %s, distance %u\n", - d->shortname, second_shortname, distance); + "connected peer %s to peer %s, distance %u\n", d->shortname, + second_shortname, distance); #endif second_daemon = @@ -993,8 +965,7 @@ all_connect_handler (void *cls, } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -1017,13 +988,9 @@ peers_started_callback (void *cls, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); new_peer = GNUNET_malloc (sizeof (struct PeerContext)); - new_peer->peer_handle = GNUNET_CORE_connect (cfg, - 1, - d, NULL, - &all_connect_handler, - NULL, NULL, NULL, - GNUNET_NO, NULL, GNUNET_NO, - no_handlers); + new_peer->peer_handle = + GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL, NULL, + NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); new_peer->daemon = d; new_peer->next = all_peers; all_peers = new_peer; @@ -1038,10 +1005,10 @@ peers_started_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "from peers_started_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "from peers_started_callback"); connect_topology (); ok = 0; @@ -1057,8 +1024,7 @@ peers_started_callback (void *cls, * @param emsg non-null on failure */ static void -hostkey_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_TESTING_Daemon *d, const char *emsg) { if (emsg != NULL) @@ -1068,8 +1034,8 @@ hostkey_callback (void *cls, } #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey created for peer `%s'\n", GNUNET_i2s (id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostkey created for peer `%s'\n", + GNUNET_i2s (id)); #endif peers_left--; if (peers_left == 0) @@ -1081,19 +1047,18 @@ hostkey_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "from hostkey_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "from hostkey_callback"); GNUNET_SCHEDULER_add_now (&create_topology, NULL); ok = 0; } } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *topology_str; char *connect_topology_str; @@ -1216,20 +1181,18 @@ run (void *cls, peers_left = num_peers; /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "didn't start all daemons in reasonable amount of time!!!"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "didn't start all daemons in reasonable amount of time!!!"); peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create (peers_left); pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ peers_left, /* Number of outstanding connections */ peers_left, /* Number of parallel ssh connections, or peers being started at once */ - TIMEOUT, - &hostkey_callback, - NULL, - &peers_started_callback, - NULL, &topology_callback, NULL, NULL); + TIMEOUT, &hostkey_callback, NULL, + &peers_started_callback, NULL, + &topology_callback, NULL, NULL); } @@ -1249,9 +1212,9 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-transport-dv", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-transport-dv", "nohelp", options, &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c index 35d59854f..bd4dfba5a 100644 --- a/src/fragmentation/defragmentation.c +++ b/src/fragmentation/defragmentation.c @@ -203,8 +203,7 @@ struct GNUNET_DEFRAGMENT_Context */ struct GNUNET_DEFRAGMENT_Context * GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, - uint16_t mtu, - unsigned int num_msgs, + uint16_t mtu, unsigned int num_msgs, void *cls, GNUNET_FRAGMENT_MessageProcessor proc, GNUNET_DEFRAGMENT_AckProcessor ackp) @@ -268,8 +267,8 @@ send_ack (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fa.fragment_id = htonl (mc->fragment_id); fa.bits = GNUNET_htonll (mc->bits); GNUNET_STATISTICS_update (mc->dc->stats, - _("# acknowledgements sent for fragment"), - 1, GNUNET_NO); + _("# acknowledgements sent for fragment"), 1, + GNUNET_NO); dc->ackp (dc->cls, mc->fragment_id, &fa.header); } @@ -279,9 +278,9 @@ send_ack (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * (C) 2000 Brian Gough */ static void -gsl_fit_mul (const double *x, const size_t xstride, - const double *y, const size_t ystride, - const size_t n, double *c1, double *cov_11, double *sumsq) +gsl_fit_mul (const double *x, const size_t xstride, const double *y, + const size_t ystride, const size_t n, double *c1, double *cov_11, + double *sumsq) { double m_x = 0, m_y = 0, m_dx2 = 0, m_dxdy = 0; @@ -457,8 +456,8 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, while ((NULL != mc) && (fid != mc->fragment_id)) mc = mc->next; bit = foff / (dc->mtu - sizeof (struct FragmentHeader)); - if (bit * (dc->mtu - sizeof (struct FragmentHeader)) + ntohs (msg->size) - - sizeof (struct FragmentHeader) > msize) + if (bit * (dc->mtu - sizeof (struct FragmentHeader)) + ntohs (msg->size) - + sizeof (struct FragmentHeader) > msize) { /* payload extends past total message size */ GNUNET_break_op (0); @@ -497,8 +496,8 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, { mc->bits -= 1LL << bit; mbuf = (char *) &mc[1]; - memcpy (&mbuf[bit * (dc->mtu - sizeof (struct FragmentHeader))], - &fh[1], ntohs (msg->size) - sizeof (struct FragmentHeader)); + memcpy (&mbuf[bit * (dc->mtu - sizeof (struct FragmentHeader))], &fh[1], + ntohs (msg->size) - sizeof (struct FragmentHeader)); mc->last_update = now; if (bit < mc->last_bit) mc->frag_times_start_offset = mc->frag_times_write_offset; @@ -511,9 +510,8 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, else { duplicate = GNUNET_YES; - GNUNET_STATISTICS_update (dc->stats, - _("# duplicate fragments received"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (dc->stats, _("# duplicate fragments received"), 1, + GNUNET_NO); } /* count number of missing fragments */ @@ -531,8 +529,8 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, mc->ack_task = GNUNET_SCHEDULER_add_delayed (delay, &send_ack, mc); if ((duplicate == GNUNET_NO) && (0 == mc->bits)) { - GNUNET_STATISTICS_update (dc->stats, - _("# messages defragmented"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (dc->stats, _("# messages defragmented"), 1, + GNUNET_NO); /* message complete, notify! */ dc->proc (dc->cls, mc->msg); } diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c index d3483fc8d..cea33b652 100644 --- a/src/fragmentation/fragmentation.c +++ b/src/fragmentation/fragmentation.c @@ -176,16 +176,15 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fh->fragment_id = htonl (fc->fragment_id); fh->total_size = fc->msg->size; /* already in big-endian */ fh->offset = htons ((fc->mtu - sizeof (struct FragmentHeader)) * bit); - memcpy (&fh[1], - &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))], + memcpy (&fh[1], &mbuf[bit * (fc->mtu - sizeof (struct FragmentHeader))], fsize - sizeof (struct FragmentHeader)); if (NULL != fc->tracker) GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); - GNUNET_STATISTICS_update (fc->stats, - _("# fragments transmitted"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (fc->stats, _("# fragments transmitted"), 1, + GNUNET_NO); if (0 != fc->last_round.abs_value) - GNUNET_STATISTICS_update (fc->stats, - _("# fragments retransmitted"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (fc->stats, _("# fragments retransmitted"), 1, + GNUNET_NO); /* select next message to calculate delay */ bit = fc->next_transmission; @@ -201,8 +200,9 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (wrap) { /* full round transmitted wait 2x delay for ACK before going again */ - delay = GNUNET_TIME_relative_max (GNUNET_TIME_relative_multiply (delay, 2), - fc->delay); + delay = + GNUNET_TIME_relative_max (GNUNET_TIME_relative_multiply (delay, 2), + fc->delay); /* never use zero, need some time for ACK always */ delay = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS, delay); fc->last_round = GNUNET_TIME_absolute_get (); @@ -248,8 +248,7 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, GNUNET_STATISTICS_update (stats, _("# messages fragmented"), 1, GNUNET_NO); GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); size = ntohs (msg->size); - GNUNET_STATISTICS_update (stats, - _("# total size of fragmented messages"), + GNUNET_STATISTICS_update (stats, _("# total size of fragmented messages"), size, GNUNET_NO); GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); @@ -260,8 +259,8 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, fc->msg = (const struct GNUNET_MessageHeader *) &fc[1]; fc->proc = proc; fc->proc_cls = proc_cls; - fc->fragment_id = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX); + fc->fragment_id = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); memcpy (&fc[1], msg, size); bits = (size + mtu - sizeof (struct FragmentHeader) - 1) / (mtu - @@ -333,14 +332,14 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, fc->delay.rel_value = (ndelay.rel_value + 3 * fc->delay.rel_value) / 4; } GNUNET_STATISTICS_update (fc->stats, - _("# fragment acknowledgements received"), - 1, GNUNET_NO); + _("# fragment acknowledgements received"), 1, + GNUNET_NO); if (abits != (fc->acks & abits)) { /* ID collission or message reordering, count! This should be rare! */ GNUNET_STATISTICS_update (fc->stats, - _("# bits removed from fragmentation ACKs"), - 1, GNUNET_NO); + _("# bits removed from fragmentation ACKs"), 1, + GNUNET_NO); } fc->acks = abits & fc->acks_mask; if (0 != fc->acks) @@ -363,8 +362,8 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, /* all done */ GNUNET_STATISTICS_update (fc->stats, - _("# fragmentation transmissions completed"), - 1, GNUNET_NO); + _("# fragmentation transmissions completed"), 1, + GNUNET_NO); if (fc->task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (fc->task); diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c index b534a134e..b04b28385 100644 --- a/src/fragmentation/test_fragmentation.c +++ b/src/fragmentation/test_fragmentation.c @@ -183,9 +183,8 @@ proc_frac (void *cls, const struct GNUNET_MessageHeader *hdr) * Main function run with scheduler. */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { unsigned int i; struct GNUNET_MessageHeader *msg; @@ -202,10 +201,9 @@ run (void *cls, msg->size = htons (sizeof (struct GNUNET_MessageHeader) + (17 * i) % (32 * 1024)); frags[i] = GNUNET_FRAGMENT_context_create (NULL /* no stats */ , - MTU, - &trackers[i], - GNUNET_TIME_UNIT_SECONDS, - msg, &proc_frac, &frags[i]); + MTU, &trackers[i], + GNUNET_TIME_UNIT_SECONDS, msg, + &proc_frac, &frags[i]); } } diff --git a/src/fs/fs.c b/src/fs/fs.c index 318b7088e..e26a01996 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -52,8 +52,7 @@ start_job (struct GNUNET_FS_QueueEntry *qe) qe->h->active_blocks += qe->blocks; qe->start_time = GNUNET_TIME_absolute_get (); GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, qe->h->pending_tail, qe); - GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, - qe->h->running_tail, + GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, qe->h->running_tail, qe->h->running_tail, qe); } @@ -71,12 +70,12 @@ stop_job (struct GNUNET_FS_QueueEntry *qe) qe->stop (qe->cls); qe->h->active_downloads--; qe->h->active_blocks -= qe->blocks; - qe->run_time = GNUNET_TIME_relative_add (qe->run_time, - GNUNET_TIME_absolute_get_duration - (qe->start_time)); + qe->run_time = + GNUNET_TIME_relative_add (qe->run_time, + GNUNET_TIME_absolute_get_duration (qe-> + start_time)); GNUNET_CONTAINER_DLL_remove (qe->h->running_head, qe->h->running_tail, qe); - GNUNET_CONTAINER_DLL_insert_after (qe->h->pending_head, - qe->h->pending_tail, + GNUNET_CONTAINER_DLL_insert_after (qe->h->pending_head, qe->h->pending_tail, qe->h->pending_tail, qe); } @@ -123,8 +122,9 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) while (NULL != (qe = next)) { next = qe->next; - run_time = GNUNET_TIME_relative_multiply (h->avg_block_latency, - qe->blocks * qe->start_times); + run_time = + GNUNET_TIME_relative_multiply (h->avg_block_latency, + qe->blocks * qe->start_times); end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); rst = GNUNET_TIME_absolute_get_remaining (end_time); restart_at = GNUNET_TIME_relative_min (rst, restart_at); @@ -132,8 +132,8 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) continue; stop_job (qe); } - h->queue_job = GNUNET_SCHEDULER_add_delayed (restart_at, - &process_job_queue, h); + h->queue_job = + GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h); } @@ -148,8 +148,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return queue handle */ struct GNUNET_FS_QueueEntry * -GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, - GNUNET_FS_QueueStart start, +GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, GNUNET_FS_QueueStart start, GNUNET_FS_QueueStop stop, void *cls, unsigned int blocks) { struct GNUNET_FS_QueueEntry *qe; @@ -161,8 +160,8 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, qe->cls = cls; qe->queue_time = GNUNET_TIME_absolute_get (); qe->blocks = blocks; - GNUNET_CONTAINER_DLL_insert_after (h->pending_head, - h->pending_tail, h->pending_tail, qe); + GNUNET_CONTAINER_DLL_insert_after (h->pending_head, h->pending_tail, + h->pending_tail, qe); if (h->queue_job != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (h->queue_job); h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h); @@ -199,8 +198,8 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qh) * @return fresh top-level activity handle */ struct TopLevelActivity * -GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, - SuspendSignalFunction ssf, void *ssf_cls) +GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, + void *ssf_cls) { struct TopLevelActivity *ret; @@ -261,9 +260,8 @@ struct FileInfo * @return number of bytes written, usually "max", 0 on error */ size_t -GNUNET_FS_data_reader_file_ (void *cls, - uint64_t offset, - size_t max, void *buf, char **emsg) +GNUNET_FS_data_reader_file_ (void *cls, uint64_t offset, size_t max, void *buf, + char **emsg) { struct FileInfo *fi = cls; ssize_t ret; @@ -278,14 +276,13 @@ GNUNET_FS_data_reader_file_ (void *cls, } if (fi->fd == NULL) { - fi->fd = GNUNET_DISK_file_open (fi->filename, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE); + fi->fd = + GNUNET_DISK_file_open (fi->filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (fi->fd == NULL) { - GNUNET_asprintf (emsg, - _("Could not open file `%s': %s"), - fi->filename, STRERROR (errno)); + GNUNET_asprintf (emsg, _("Could not open file `%s': %s"), fi->filename, + STRERROR (errno)); return 0; } } @@ -293,15 +290,14 @@ GNUNET_FS_data_reader_file_ (void *cls, ret = GNUNET_DISK_file_read (fi->fd, buf, max); if (ret == -1) { - GNUNET_asprintf (emsg, - _("Could not read file `%s': %s"), - fi->filename, STRERROR (errno)); + GNUNET_asprintf (emsg, _("Could not read file `%s': %s"), fi->filename, + STRERROR (errno)); return 0; } if (ret != max) { - GNUNET_asprintf (emsg, - _("Short read reading from file `%s'!"), fi->filename); + GNUNET_asprintf (emsg, _("Short read reading from file `%s'!"), + fi->filename); return 0; } return max; @@ -347,9 +343,8 @@ GNUNET_FS_make_file_reader_context_ (const char *filename) * @return number of bytes written, usually "max", 0 on error */ size_t -GNUNET_FS_data_reader_copy_ (void *cls, - uint64_t offset, - size_t max, void *buf, char **emsg) +GNUNET_FS_data_reader_copy_ (void *cls, uint64_t offset, size_t max, void *buf, + char **emsg) { char *data = cls; @@ -373,8 +368,8 @@ GNUNET_FS_data_reader_copy_ (void *cls, * @return NULL on error */ static char * -get_serialization_file_name (struct GNUNET_FS_Handle *h, - const char *ext, const char *ent) +get_serialization_file_name (struct GNUNET_FS_Handle *h, const char *ext, + const char *ent) { char *basename; char *ret; @@ -382,15 +377,12 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h, if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) return NULL; /* persistence not requested */ if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (h->cfg, - "fs", "STATE_DIR", &basename)) + GNUNET_CONFIGURATION_get_value_filename (h->cfg, "fs", "STATE_DIR", + &basename)) return NULL; - GNUNET_asprintf (&ret, - "%s%s%s%s%s%s%s", - basename, - DIR_SEPARATOR_STR, - h->client_name, - DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR, ent); + GNUNET_asprintf (&ret, "%s%s%s%s%s%s%s", basename, DIR_SEPARATOR_STR, + h->client_name, DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR, + ent); GNUNET_free (basename); return ret; } @@ -408,8 +400,7 @@ get_serialization_file_name (struct GNUNET_FS_Handle *h, * @return NULL on error */ static char * -get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, - const char *ext, +get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, const char *ext, const char *uni, const char *ent) { char *basename; @@ -418,16 +409,12 @@ get_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h, if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) return NULL; /* persistence not requested */ if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (h->cfg, - "fs", "STATE_DIR", &basename)) + GNUNET_CONFIGURATION_get_value_filename (h->cfg, "fs", "STATE_DIR", + &basename)) return NULL; - GNUNET_asprintf (&ret, - "%s%s%s%s%s%s%s.dir%s%s", - basename, - DIR_SEPARATOR_STR, - h->client_name, - DIR_SEPARATOR_STR, - ext, DIR_SEPARATOR_STR, uni, DIR_SEPARATOR_STR, ent); + GNUNET_asprintf (&ret, "%s%s%s%s%s%s%s.dir%s%s", basename, DIR_SEPARATOR_STR, + h->client_name, DIR_SEPARATOR_STR, ext, DIR_SEPARATOR_STR, + uni, DIR_SEPARATOR_STR, ent); GNUNET_free (basename); return ret; } @@ -493,8 +480,8 @@ get_write_handle (struct GNUNET_FS_Handle *h, const char *ext, const char *ent) * @return NULL on error */ static struct GNUNET_BIO_WriteHandle * -get_write_handle_in_dir (struct GNUNET_FS_Handle *h, - const char *ext, const char *uni, const char *ent) +get_write_handle_in_dir (struct GNUNET_FS_Handle *h, const char *ext, + const char *uni, const char *ent) { char *fn; struct GNUNET_BIO_WriteHandle *ret; @@ -516,8 +503,8 @@ get_write_handle_in_dir (struct GNUNET_FS_Handle *h, * @param ent entity identifier */ void -GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, - const char *ext, const char *ent) +GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, const char *ext, + const char *ent) { char *filename; @@ -545,8 +532,8 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h, * @param ent entity identifier */ static void -remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, - const char *ext, const char *uni, const char *ent) +remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, const char *ext, + const char *uni, const char *ent) { char *filename; @@ -573,8 +560,8 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h, * @param uni unique name of parent */ void -GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, - const char *ext, const char *uni) +GNUNET_FS_remove_sync_dir_ (struct GNUNET_FS_Handle *h, const char *ext, + const char *uni) { char *dn; @@ -670,8 +657,8 @@ static struct GNUNET_FS_FileInformation *deserialize_file_information (struct * @return NULL on error */ static struct GNUNET_FS_FileInformation * -deserialize_fi_node (struct GNUNET_FS_Handle *h, - const char *fn, struct GNUNET_BIO_ReadHandle *rh) +deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, + struct GNUNET_BIO_ReadHandle *rh) { struct GNUNET_FS_FileInformation *ret; struct GNUNET_FS_FileInformation *nxt; @@ -691,34 +678,23 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, ksks = NULL; chks = NULL; filename = NULL; - if ((GNUNET_OK != - GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) || + if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) || + (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) || ((ksks != NULL) && - (NULL == - (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL)))) || - (GNUNET_YES != - GNUNET_FS_uri_test_ksk (ret->keywords)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "chk-uri", &chks, 1024)) || + (NULL == (ret->keywords = GNUNET_FS_uri_parse (ksks, NULL)))) || + (GNUNET_YES != GNUNET_FS_uri_test_ksk (ret->keywords)) || + (GNUNET_OK != GNUNET_BIO_read_string (rh, "chk-uri", &chks, 1024)) || ((chks != NULL) && - ((NULL == - (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) || - (GNUNET_YES != - GNUNET_FS_uri_test_chk (ret->chk_uri)))) || - (GNUNET_OK != - read_start_time (rh, &ret->start_time)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) || + ((NULL == (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) || + (GNUNET_YES != GNUNET_FS_uri_test_chk (ret->chk_uri)))) || + (GNUNET_OK != read_start_time (rh, &ret->start_time)) || + (GNUNET_OK != GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024)) + || (GNUNET_OK != + GNUNET_BIO_read_string (rh, "fn", &ret->filename, 16 * 1024)) || (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->bo.expiration_time.abs_value)) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.anonymity_level)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.content_priority)) || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &ret->bo.replication_level))) { GNUNET_break (0); @@ -786,8 +762,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, GNUNET_break (0); goto cleanup; } - if ((GNUNET_OK != - GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) || + if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) || (GNUNET_OK != GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id, sizeof (GNUNET_HashCode)))) @@ -809,8 +784,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, GNUNET_break (0); goto cleanup; } - if ((GNUNET_OK != - GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) || + if ((GNUNET_OK != GNUNET_BIO_read_int64 (rh, &ret->data.file.file_size)) || (GNUNET_OK != GNUNET_BIO_read (rh, "fileid", &ret->data.file.file_id, sizeof (GNUNET_HashCode)))) @@ -828,8 +802,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, break; case 4: /* directory */ ret->is_directory = GNUNET_YES; - if ((GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &dsize)) || + if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dsize)) || (NULL == (ret->data.dir.dir_data = GNUNET_malloc_large (dsize))) || (GNUNET_OK != GNUNET_BIO_read (rh, "dir-data", ret->data.dir.dir_data, dsize)) || @@ -1046,8 +1019,8 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh, while (off < fi->data.file.file_size) { left = GNUNET_MIN (sizeof (buf), fi->data.file.file_size - off); - ret = fi->data.file.reader (fi->data.file.reader_cls, - off, left, buf, &emsg); + ret = + fi->data.file.reader (fi->data.file.reader_cls, off, left, buf, &emsg); if (ret == 0) { GNUNET_free (emsg); @@ -1107,26 +1080,17 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) chks = GNUNET_FS_uri_to_string (fi->chk_uri); else chks = NULL; - if ((GNUNET_OK != - GNUNET_BIO_write (wh, &b, sizeof (b))) || - (GNUNET_OK != - GNUNET_BIO_write_meta_data (wh, fi->meta)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, ksks)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, chks)) || - (GNUNET_OK != - write_start_time (wh, fi->start_time)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, fi->emsg)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, fi->filename)) || + if ((GNUNET_OK != GNUNET_BIO_write (wh, &b, sizeof (b))) || + (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, fi->meta)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, ksks)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, chks)) || + (GNUNET_OK != write_start_time (wh, fi->start_time)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->emsg)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) || (GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->bo.expiration_time.abs_value)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.anonymity_level)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.content_priority)) || (GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->bo.replication_level))) { GNUNET_break (0); @@ -1171,8 +1135,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) GNUNET_break (0); goto cleanup; } - if ((GNUNET_OK != - GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) || + if ((GNUNET_OK != GNUNET_BIO_write_int64 (wh, fi->data.file.file_size)) || (GNUNET_OK != GNUNET_BIO_write (wh, &fi->data.file.file_id, sizeof (GNUNET_HashCode)))) @@ -1182,16 +1145,15 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) } break; case 4: /* directory */ - if ((GNUNET_OK != - GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) || + if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, fi->data.dir.dir_size)) || (GNUNET_OK != GNUNET_BIO_write (wh, fi->data.dir.dir_data, (uint32_t) fi->data.dir.dir_size)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, (fi->data.dir.entries == - NULL) ? NULL : fi->data.dir. - entries->serialization))) + NULL) ? NULL : fi->data.dir.entries-> + serialization))) { GNUNET_break (0); goto cleanup; @@ -1279,13 +1241,11 @@ find_file_position (struct GNUNET_FS_FileInformation *pos, const char *srch) * @return GNUNET_OK to continue (always) */ static int -fip_signal_resume (void *cls, - struct GNUNET_FS_FileInformation *fi, - uint64_t length, - struct GNUNET_CONTAINER_MetaData *meta, +fip_signal_resume (void *cls, struct GNUNET_FS_FileInformation *fi, + uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - struct GNUNET_FS_BlockOptions *bo, - int *do_index, void **client_info) + struct GNUNET_FS_BlockOptions *bo, int *do_index, + void **client_info) { struct GNUNET_FS_PublishContext *sc = cls; struct GNUNET_FS_ProgressInfo pi; @@ -1331,19 +1291,15 @@ deserialize_publish_file (void *cls, const char *filename) GNUNET_break (0); goto cleanup; } - if ((GNUNET_OK != - GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &options)) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &all_done)) || + if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-nid", &pc->nid, 1024)) + || (GNUNET_OK != + GNUNET_BIO_read_string (rh, "publish-nuid", &pc->nuid, 1024)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &all_done)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-firoot", &fi_root, 128)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) || - (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-ns", &ns, 1024))) + (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-fipos", &fi_pos, 128)) + || (GNUNET_OK != GNUNET_BIO_read_string (rh, "publish-ns", &ns, 1024))) { GNUNET_break (0); goto cleanup; @@ -1402,8 +1358,7 @@ deserialize_publish_file (void *cls, const char *filename) if (pc->all_done != GNUNET_YES) { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -1426,8 +1381,8 @@ cleanup: if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to resume publishing operation `%s': %s\n"), - filename, emsg); + _("Failed to resume publishing operation `%s': %s\n"), filename, + emsg); GNUNET_free (emsg); } if (pc->fi != NULL) @@ -1454,8 +1409,9 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) struct GNUNET_BIO_WriteHandle *wh; if (NULL == pc->serialization) - pc->serialization = make_serialization_file_name (pc->h, - GNUNET_FS_SYNC_PATH_MASTER_PUBLISH); + pc->serialization = + make_serialization_file_name (pc->h, + GNUNET_FS_SYNC_PATH_MASTER_PUBLISH); if (NULL == pc->serialization) return; if (NULL == pc->fi) @@ -1472,16 +1428,11 @@ GNUNET_FS_publish_sync_ (struct GNUNET_FS_PublishContext *pc) GNUNET_break (0); goto cleanup; } - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, pc->nid)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, pc->nuid)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, pc->options)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, pc->all_done)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, pc->fi->serialization)) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nid)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->nuid)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->options)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pc->all_done)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, pc->fi->serialization)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, (pc->fi_pos == @@ -1525,8 +1476,9 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) struct GNUNET_BIO_WriteHandle *wh; if (NULL == uc->serialization) - uc->serialization = make_serialization_file_name (uc->h, - GNUNET_FS_SYNC_PATH_MASTER_UNINDEX); + uc->serialization = + make_serialization_file_name (uc->h, + GNUNET_FS_SYNC_PATH_MASTER_UNINDEX); if (NULL == uc->serialization) return; wh = get_write_handle (uc->h, GNUNET_FS_SYNC_PATH_MASTER_UNINDEX, @@ -1536,14 +1488,10 @@ GNUNET_FS_unindex_sync_ (struct GNUNET_FS_UnindexContext *uc) GNUNET_break (0); goto cleanup; } - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, uc->filename)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, uc->file_size)) || - (GNUNET_OK != - write_start_time (wh, uc->start_time)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uc->filename)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, uc->file_size)) || + (GNUNET_OK != write_start_time (wh, uc->start_time)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) uc->state)) || ((uc->state == UNINDEX_STATE_FS_NOTIFY) && (GNUNET_OK != GNUNET_BIO_write (wh, &uc->file_id, sizeof (GNUNET_HashCode)))) || @@ -1583,12 +1531,9 @@ write_download_request (struct GNUNET_BIO_WriteHandle *wh, { unsigned int i; - if ((GNUNET_OK != - GNUNET_BIO_write_int32 (wh, dr->state)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, dr->offset)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, dr->num_children)) || + if ((GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->state)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dr->offset)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->num_children)) || (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dr->depth))) return GNUNET_NO; if ((dr->state == BRS_CHK_SET) && @@ -1616,16 +1561,14 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh) dr = GNUNET_malloc (sizeof (struct DownloadRequest)); - if ((GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &dr->state)) || - (GNUNET_OK != - GNUNET_BIO_read_int64 (rh, &dr->offset)) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &dr->num_children)) || + if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->state)) || + (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || (dr->num_children > CHK_PER_INODE) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &dr->depth)) || - ((dr->depth == 0) && (dr->num_children > 0)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->depth)) || ((dr->depth == 0) + && (dr-> + num_children + > 0)) || ((dr->depth > 0) && (dr->num_children == 0))) { GNUNET_break (0); @@ -1633,8 +1576,8 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh) goto cleanup; } if (dr->num_children > 0) - dr->children = GNUNET_malloc (dr->num_children * - sizeof (struct ContentHashKey)); + dr->children = + GNUNET_malloc (dr->num_children * sizeof (struct ContentHashKey)); switch (dr->state) { case BRS_INIT: @@ -1686,7 +1629,8 @@ get_download_sync_filename (struct GNUNET_FS_DownloadContext *dc, if (dc->parent == NULL) return get_serialization_file_name (dc->h, - (dc->search != NULL) ? + (dc->search != + NULL) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, uni); @@ -1755,30 +1699,18 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc) GNUNET_assert ((GNUNET_YES == GNUNET_FS_uri_test_chk (dc->uri)) || (GNUNET_YES == GNUNET_FS_uri_test_loc (dc->uri))); uris = GNUNET_FS_uri_to_string (dc->uri); - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, uris)) || - (GNUNET_OK != - GNUNET_BIO_write_meta_data (wh, dc->meta)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, dc->emsg)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, dc->filename)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, dc->temp_filename)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, dc->old_file_size)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, dc->offset)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, dc->length)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, dc->completed)) || - (GNUNET_OK != - write_start_time (wh, dc->start_time)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, dc->anonymity)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, (uint32_t) dc->options)) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || + (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, dc->meta)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->emsg)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->filename)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, dc->temp_filename)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->old_file_size)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->offset)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->length)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, dc->completed)) || + (GNUNET_OK != write_start_time (wh, dc->start_time)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, dc->anonymity)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->options)) || (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) dc->has_finished))) { GNUNET_break (0); @@ -1831,22 +1763,19 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) uris = NULL; if (NULL == sr->serialization) - sr->serialization = make_serialization_file_name_in_dir (sr->sc->h, - (sr-> - sc->psearch_result - == - NULL) ? - GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : - GNUNET_FS_SYNC_PATH_CHILD_SEARCH, - sr-> - sc->serialization); + sr->serialization = + make_serialization_file_name_in_dir (sr->sc->h, + (sr->sc->psearch_result == + NULL) ? + GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + sr->sc->serialization); if (NULL == sr->serialization) return; wh = get_write_handle_in_dir (sr->sc->h, - (sr->sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + (sr->sc->psearch_result == + NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, sr->sc->serialization, sr->serialization); if (wh == NULL) { @@ -1854,8 +1783,7 @@ GNUNET_FS_search_result_sync_ (struct GNUNET_FS_SearchResult *sr) goto cleanup; } uris = GNUNET_FS_uri_to_string (sr->uri); - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, uris)) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, sr->download != @@ -1887,9 +1815,9 @@ cleanup: if (wh != NULL) (void) GNUNET_BIO_write_close (wh); remove_sync_file_in_dir (sr->sc->h, - (sr->sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + (sr->sc->psearch_result == + NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, sr->sc->serialization, sr->serialization); GNUNET_free (sr->serialization); sr->serialization = NULL; @@ -1912,8 +1840,10 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) char in_pause; const char *category; - category = (sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : GNUNET_FS_SYNC_PATH_CHILD_SEARCH; + category = + (sc->psearch_result == + NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH; if (NULL == sc->serialization) sc->serialization = make_serialization_file_name (sc->h, category); if (NULL == sc->serialization) @@ -1929,16 +1859,11 @@ GNUNET_FS_search_sync_ (struct GNUNET_FS_SearchContext *sc) (GNUNET_YES == GNUNET_FS_uri_test_sks (sc->uri))); uris = GNUNET_FS_uri_to_string (sc->uri); in_pause = (sc->task != GNUNET_SCHEDULER_NO_TASK) ? 'r' : '\0'; - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, uris)) || - (GNUNET_OK != - write_start_time (wh, sc->start_time)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, sc->emsg)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, (uint32_t) sc->options)) || - (GNUNET_OK != - GNUNET_BIO_write (wh, &in_pause, sizeof (in_pause))) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, uris)) || + (GNUNET_OK != write_start_time (wh, sc->start_time)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, sc->emsg)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, (uint32_t) sc->options)) || + (GNUNET_OK != GNUNET_BIO_write (wh, &in_pause, sizeof (in_pause))) || (GNUNET_OK != GNUNET_BIO_write_int32 (wh, sc->anonymity))) { GNUNET_break (0); @@ -1992,10 +1917,8 @@ deserialize_unindex_file (void *cls, const char *filename) } if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "unindex-fn", &uc->filename, 10 * 1024)) || - (GNUNET_OK != - GNUNET_BIO_read_int64 (rh, &uc->file_size)) || - (GNUNET_OK != - read_start_time (rh, &uc->start_time)) || + (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &uc->file_size)) || + (GNUNET_OK != read_start_time (rh, &uc->start_time)) || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &state))) { GNUNET_break (0); @@ -2034,17 +1957,16 @@ deserialize_unindex_file (void *cls, const char *filename) uc->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, uc); pi.status = GNUNET_FS_STATUS_UNINDEX_RESUME; pi.value.unindex.specifics.resume.message = uc->emsg; - GNUNET_FS_unindex_make_status_ (&pi, - uc, - (uc->state == UNINDEX_STATE_COMPLETE) - ? uc->file_size : 0); + GNUNET_FS_unindex_make_status_ (&pi, uc, + (uc->state == + UNINDEX_STATE_COMPLETE) ? uc->file_size : 0); switch (uc->state) { case UNINDEX_STATE_HASHING: - uc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, - uc->filename, - HASHING_BLOCKSIZE, - &GNUNET_FS_unindex_process_hash_, uc); + uc->fhc = + GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, uc->filename, + HASHING_BLOCKSIZE, + &GNUNET_FS_unindex_process_hash_, uc); break; case UNINDEX_STATE_FS_NOTIFY: uc->state = UNINDEX_STATE_HASHING; @@ -2073,8 +1995,8 @@ cleanup: if ((rh != NULL) && (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to resume unindexing operation `%s': %s\n"), - filename, emsg); + _("Failed to resume unindexing operation `%s': %s\n"), filename, + emsg); GNUNET_free (emsg); } if (uc->serialization != NULL) @@ -2095,12 +2017,11 @@ cleanup: * @param search associated search * @param serialization name under which the search was serialized */ -static void -deserialize_download (struct GNUNET_FS_Handle *h, - struct GNUNET_BIO_ReadHandle *rh, - struct GNUNET_FS_DownloadContext *parent, - struct GNUNET_FS_SearchResult *search, - const char *serialization); +static void deserialize_download (struct GNUNET_FS_Handle *h, + struct GNUNET_BIO_ReadHandle *rh, + struct GNUNET_FS_DownloadContext *parent, + struct GNUNET_FS_SearchResult *search, + const char *serialization); /** @@ -2151,9 +2072,9 @@ deserialize_search_result (void *cls, const char *filename) if (ser != NULL) { remove_sync_file_in_dir (sc->h, - (sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + (sc->psearch_result == + NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, sc->serialization, ser); GNUNET_free (ser); } @@ -2165,15 +2086,12 @@ deserialize_search_result (void *cls, const char *filename) update_srch = NULL; sr = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchResult)); sr->serialization = ser; - if ((GNUNET_OK != - GNUNET_BIO_read_string (rh, "result-uri", &uris, 10 * 1024)) || - (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) || - (GNUNET_OK != - GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) || + if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "result-uri", &uris, 10 * 1024)) + || (NULL == (sr->uri = GNUNET_FS_uri_parse (uris, &emsg))) || + (GNUNET_OK != GNUNET_BIO_read_string (rh, "download-lnk", &download, 16)) + || (GNUNET_OK != + GNUNET_BIO_read_string (rh, "search-lnk", &update_srch, 16)) || + (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "result-meta", &sr->meta)) || (GNUNET_OK != GNUNET_BIO_read (rh, "result-key", &sr->key, sizeof (GNUNET_HashCode))) || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sr->mandatory_missing)) || @@ -2194,8 +2112,8 @@ deserialize_search_result (void *cls, const char *filename) if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to resume sub-download `%s': %s\n"), - download, emsg); + _("Failed to resume sub-download `%s': %s\n"), download, + emsg); GNUNET_free (emsg); } } @@ -2203,24 +2121,22 @@ deserialize_search_result (void *cls, const char *filename) } if (update_srch != NULL) { - drh = get_read_handle (sc->h, - GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch); + drh = + get_read_handle (sc->h, GNUNET_FS_SYNC_PATH_CHILD_SEARCH, update_srch); if (drh != NULL) { deserialize_search (sc->h, drh, sr, update_srch); if (GNUNET_OK != GNUNET_BIO_read_close (drh, &emsg)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to resume sub-search `%s': %s\n"), - update_srch, emsg); + _("Failed to resume sub-search `%s': %s\n"), update_srch, + emsg); GNUNET_free (emsg); } } GNUNET_free (update_srch); } - GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, - &sr->key, - sr, + GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &sr->key, sr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg)) { @@ -2378,14 +2294,14 @@ free_search_context (struct GNUNET_FS_SearchContext *sc) if (sc->serialization != NULL) { GNUNET_FS_remove_sync_file_ (sc->h, - (sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + (sc->psearch_result == + NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, sc->serialization); GNUNET_FS_remove_sync_dir_ (sc->h, - (sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + (sc->psearch_result == + NULL) ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, sc->serialization); } GNUNET_free_non_null (sc->serialization); @@ -2394,8 +2310,8 @@ free_search_context (struct GNUNET_FS_SearchContext *sc) GNUNET_FS_uri_destroy (sc->uri); if (sc->master_result_map != NULL) { - GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, - &free_result, sc); + GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, &free_result, + sc); GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map); } GNUNET_free (sc); @@ -2507,10 +2423,9 @@ deserialize_download (struct GNUNET_FS_Handle *h, (NULL == (dc->uri = GNUNET_FS_uri_parse (uris, &emsg))) || ((GNUNET_YES != GNUNET_FS_uri_test_chk (dc->uri)) && (GNUNET_YES != GNUNET_FS_uri_test_loc (dc->uri))) || - (GNUNET_OK != - GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta)) || - (GNUNET_OK != - GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) || + (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "download-meta", &dc->meta)) + || (GNUNET_OK != + GNUNET_BIO_read_string (rh, "download-emsg", &dc->emsg, 10 * 1024)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "download-fn", &dc->filename, 10 * 1024)) || (GNUNET_OK != @@ -2565,8 +2480,8 @@ deserialize_download (struct GNUNET_FS_Handle *h, } if ((parent == NULL) && (search == NULL)) { - dc->top = GNUNET_FS_make_top (dc->h, - &GNUNET_FS_download_signal_suspend_, dc); + dc->top = + GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc); signal_download_resume (dc); } GNUNET_free (uris); @@ -2637,17 +2552,14 @@ deserialize_search (struct GNUNET_FS_Handle *h, } sc->h = h; sc->serialization = GNUNET_strdup (serialization); - if ((GNUNET_OK != - GNUNET_BIO_read_string (rh, "search-uri", &uris, 10 * 1024)) || - (NULL == (sc->uri = GNUNET_FS_uri_parse (uris, &emsg))) || + if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "search-uri", &uris, 10 * 1024)) + || (NULL == (sc->uri = GNUNET_FS_uri_parse (uris, &emsg))) || ((GNUNET_YES != GNUNET_FS_uri_test_ksk (sc->uri)) && (GNUNET_YES != GNUNET_FS_uri_test_sks (sc->uri))) || - (GNUNET_OK != - read_start_time (rh, &sc->start_time)) || + (GNUNET_OK != read_start_time (rh, &sc->start_time)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "search-emsg", &sc->emsg, 10 * 1024)) || - (GNUNET_OK != - GNUNET_BIO_read_int32 (rh, &options)) || + (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &options)) || (GNUNET_OK != GNUNET_BIO_read (rh, "search-pause", &in_pause, sizeof (in_pause))) || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &sc->anonymity))) @@ -2658,9 +2570,10 @@ deserialize_search (struct GNUNET_FS_Handle *h, sc->options = (enum GNUNET_FS_SearchOptions) options; sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16); dn = get_serialization_file_name_in_dir (h, - (sc->psearch_result == NULL) - ? GNUNET_FS_SYNC_PATH_MASTER_SEARCH - : GNUNET_FS_SYNC_PATH_CHILD_SEARCH, + (sc->psearch_result == + NULL) ? + GNUNET_FS_SYNC_PATH_MASTER_SEARCH : + GNUNET_FS_SYNC_PATH_CHILD_SEARCH, sc->serialization, ""); if (dn != NULL) { @@ -2775,8 +2688,7 @@ deserialize_download_file (void *cls, const char *filename) * @param h the 'struct GNUNET_FS_Handle*' */ static void -deserialization_master (const char *master_path, - GNUNET_FileNameCallback proc, +deserialization_master (const char *master_path, GNUNET_FileNameCallback proc, struct GNUNET_FS_Handle *h) { char *dn; @@ -2803,8 +2715,7 @@ deserialization_master (const char *master_path, */ struct GNUNET_FS_Handle * GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *client_name, - GNUNET_FS_ProgressCallback upcb, + const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags, ...) { struct GNUNET_FS_Handle *ret; diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c index f22480d5f..61ed1586f 100644 --- a/src/fs/fs_directory.c +++ b/src/fs/fs_directory.c @@ -88,11 +88,9 @@ GNUNET_FS_meta_data_make_directory (struct GNUNET_CONTAINER_MetaData *md) GNUNET_free (mime); return; } - GNUNET_CONTAINER_meta_data_insert (md, - "", + GNUNET_CONTAINER_meta_data_insert (md, "", EXTRACTOR_METATYPE_MIMETYPE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", GNUNET_FS_DIRECTORY_MIME, strlen (GNUNET_FS_DIRECTORY_MIME) + 1); } @@ -134,10 +132,8 @@ struct GetFullDataClosure * @return 0 to continue extracting, 1 to abort */ static int -find_full_data (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, +find_full_data (void *cls, const char *plugin_name, + enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len) { struct GetFullDataClosure *gfdc = cls; @@ -182,8 +178,7 @@ find_full_data (void *cls, * GNUNET_SYSERR if 'data' does not represent a directory */ int -GNUNET_FS_directory_list_contents (size_t size, - const void *data, +GNUNET_FS_directory_list_contents (size_t size, const void *data, uint64_t offset, GNUNET_FS_DirectoryEntryProcessor dep, void *dep_cls) @@ -219,8 +214,7 @@ GNUNET_FS_directory_list_contents (size_t size, _("MAGIC mismatch. This is not a GNUnet directory.\n")); return GNUNET_SYSERR; } - md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + - sizeof (uint32_t)], + md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + sizeof (uint32_t)], mdSize); if (md == NULL) { @@ -289,8 +283,9 @@ GNUNET_FS_directory_list_contents (size_t size, return GNUNET_NO; /* malformed ! */ } pos += mdSize; - filename = GNUNET_CONTAINER_meta_data_get_by_type (md, - EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); + filename = + GNUNET_CONTAINER_meta_data_get_by_type (md, + EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); full_data.size = 0; full_data.data = NULL; GNUNET_CONTAINER_meta_data_iterate (md, &find_full_data, &full_data); @@ -425,11 +420,10 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, if (fsize > 0) { meta = GNUNET_CONTAINER_meta_data_duplicate (md); - GNUNET_CONTAINER_meta_data_insert (meta, - "", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_GNUNET_FULL_DATA, - EXTRACTOR_METAFORMAT_BINARY, - NULL, data, fsize); + EXTRACTOR_METAFORMAT_BINARY, NULL, data, + fsize); mdxs = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); if ((slen + sizeof (uint32_t) + mdxs - 1) / DBLOCK_SIZE == (slen + sizeof (uint32_t) + mds - 1) / DBLOCK_SIZE) @@ -443,16 +437,15 @@ GNUNET_FS_directory_builder_add (struct GNUNET_FS_DirectoryBuilder *bld, if (mds > GNUNET_MAX_MALLOC_CHECKED / 2) mds = GNUNET_MAX_MALLOC_CHECKED / 2; - e = GNUNET_malloc (sizeof (struct BuilderEntry) + - slen + mds + sizeof (uint32_t)); + e = GNUNET_malloc (sizeof (struct BuilderEntry) + slen + mds + + sizeof (uint32_t)); ser = (char *) &e[1]; memcpy (ser, uris, slen); GNUNET_free (uris); sptr = &ser[slen + sizeof (uint32_t)]; - ret = GNUNET_CONTAINER_meta_data_serialize (meta_use, - &sptr, - mds, - GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); + ret = + GNUNET_CONTAINER_meta_data_serialize (meta_use, &sptr, mds, + GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); if (NULL != meta) GNUNET_CONTAINER_meta_data_destroy (meta); if (ret == -1) @@ -495,8 +488,8 @@ do_align (size_t start_position, size_t end_position) * @param perm the permutation of the blocks (updated) */ static void -block_align (size_t start, - unsigned int count, const size_t * sizes, unsigned int *perm) +block_align (size_t start, unsigned int count, const size_t * sizes, + unsigned int *perm) { unsigned int i; unsigned int j; @@ -625,10 +618,10 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, off = strlen (GNUNET_DIRECTORY_MAGIC); sptr = &data[off + sizeof (uint32_t)]; - ret = GNUNET_CONTAINER_meta_data_serialize (bld->meta, - &sptr, - size - off - sizeof (uint32_t), - GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); + ret = + GNUNET_CONTAINER_meta_data_serialize (bld->meta, &sptr, + size - off - sizeof (uint32_t), + GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); GNUNET_assert (ret != -1); big = htonl (ret); memcpy (&data[off], &big, sizeof (uint32_t)); diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 6b72b4e56..a3c5b9b62 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -111,19 +111,19 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi, { pi->value.download.dc = dc; pi->value.download.cctx = dc->client_info; - pi->value.download.pctx - = (dc->parent == NULL) ? NULL : dc->parent->client_info; - pi->value.download.sctx - = (dc->search == NULL) ? NULL : dc->search->client_info; + pi->value.download.pctx = + (dc->parent == NULL) ? NULL : dc->parent->client_info; + pi->value.download.sctx = + (dc->search == NULL) ? NULL : dc->search->client_info; pi->value.download.uri = dc->uri; pi->value.download.filename = dc->filename; pi->value.download.size = dc->length; - pi->value.download.duration - = GNUNET_TIME_absolute_get_duration (dc->start_time); + pi->value.download.duration = + GNUNET_TIME_absolute_get_duration (dc->start_time); pi->value.download.completed = dc->completed; pi->value.download.anonymity = dc->anonymity; - pi->value.download.eta - = GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length); + pi->value.download.eta = + GNUNET_TIME_calculate_eta (dc->start_time, dc->completed, dc->length); pi->value.download.is_active = (dc->client == NULL) ? GNUNET_NO : GNUNET_YES; if (0 == (dc->options & GNUNET_FS_DOWNLOAD_IS_PROBE)) dc->client_info = dc->h->upcb (dc->h->upcb_cls, pi); @@ -194,9 +194,8 @@ struct ProcessResultClosure * @param value value in the hash map (a 'struct DownloadRequest') * @return GNUNET_YES (we should continue to iterate); unless serious error */ -static int -process_result_with_request (void *cls, - const GNUNET_HashCode * key, void *value); +static int process_result_with_request (void *cls, const GNUNET_HashCode * key, + void *value); /** @@ -215,8 +214,8 @@ process_result_with_request (void *cls, static int encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc, const struct ContentHashKey *chk, - struct DownloadRequest *dr, - const char *block, size_t len, int do_store) + struct DownloadRequest *dr, const char *block, + size_t len, int do_store) { struct ProcessResultClosure prc; char enc[len]; @@ -245,8 +244,9 @@ encrypt_existing_match (struct GNUNET_FS_DownloadContext *dc, prc.dc = dc; prc.data = enc; prc.size = len; - prc.type = (0 == dr->depth) - ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK; + prc.type = + (0 == + dr->depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : GNUNET_BLOCK_TYPE_FS_IBLOCK; prc.query = chk->query; prc.do_store = do_store; process_result_with_request (&prc, &chk->key, dr); @@ -275,12 +275,10 @@ static void try_reconnect (struct GNUNET_FS_DownloadContext *dc); * @param length number of bytes in data * @param data contents of the file (or NULL if they were not inlined) */ -static void -trigger_recursive_download (void *cls, - const char *filename, - const struct GNUNET_FS_Uri *uri, - const struct GNUNET_CONTAINER_MetaData *meta, - size_t length, const void *data); +static void trigger_recursive_download (void *cls, const char *filename, + const struct GNUNET_FS_Uri *uri, + const struct GNUNET_CONTAINER_MetaData + *meta, size_t length, const void *data); /** @@ -309,14 +307,14 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc) } if (dc->filename != NULL) { - h = GNUNET_DISK_file_open (dc->filename, - GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); + h = GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); } else { GNUNET_assert (dc->temp_filename != NULL); - h = GNUNET_DISK_file_open (dc->temp_filename, - GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); + h = GNUNET_DISK_file_open (dc->temp_filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); } if (h == NULL) return; /* oops */ @@ -328,17 +326,16 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc) } else { - GNUNET_FS_directory_list_contents (size, - data, - 0, &trigger_recursive_download, dc); + GNUNET_FS_directory_list_contents (size, data, 0, + &trigger_recursive_download, dc); GNUNET_DISK_file_unmap (m); } GNUNET_DISK_file_close (h); if (dc->filename == NULL) { if (0 != UNLINK (dc->temp_filename)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", dc->temp_filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + dc->temp_filename); GNUNET_free (dc->temp_filename); dc->temp_filename = NULL; } @@ -483,8 +480,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc, if (fh == NULL) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn); - GNUNET_asprintf (&dc->emsg, - _("Failed to open file `%s' for writing"), fn); + GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"), + fn); GNUNET_DISK_file_close (fh); dr->state = BRS_ERROR; pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; @@ -495,8 +492,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc, if (data_len != GNUNET_DISK_file_write (fh, odata, odata_len)) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", fn); - GNUNET_asprintf (&dc->emsg, - _("Failed to open file `%s' for writing"), fn); + GNUNET_asprintf (&dc->emsg, _("Failed to open file `%s' for writing"), + fn); GNUNET_DISK_file_close (fh); dr->state = BRS_ERROR; pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR; @@ -516,10 +513,11 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc, pi.value.download.specifics.progress.depth = 0; GNUNET_FS_download_make_status_ (&pi, dc); if ((NULL != dc->filename) && - (0 != truncate (dc->filename, - GNUNET_ntohll (dc->uri->data.chk.file_length)))) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "truncate", dc->filename); + (0 != + truncate (dc->filename, + GNUNET_ntohll (dc->uri->data.chk.file_length)))) + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate", + dc->filename); check_completed (dc); break; default: @@ -549,10 +547,8 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc, * @return 0 to continue extracting, 1 to abort */ static int -match_full_data (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, +match_full_data (void *cls, const char *plugin_name, + enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len) { struct GNUNET_FS_DownloadContext *dc = cls; @@ -560,8 +556,8 @@ match_full_data (void *cls, if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA) return 0; #if DEBUG_DOWNLOAD - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found %u bytes of FD!\n", (unsigned int) data_len); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u bytes of FD!\n", + (unsigned int) data_len); #endif if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len) { @@ -729,28 +725,26 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc, #if DEBUG_DOWNLOAD GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling download at offset %llu and depth %u for `%s'\n", - (unsigned long long) dr->offset, - dr->depth, GNUNET_h2s (&dr->chk.query)); + (unsigned long long) dr->offset, dr->depth, + GNUNET_h2s (&dr->chk.query)); #endif if (GNUNET_NO != - GNUNET_CONTAINER_multihashmap_contains_value (dc->active, - &dr->chk.query, dr)) + GNUNET_CONTAINER_multihashmap_contains_value (dc->active, &dr->chk.query, + dr)) return; /* already active */ - GNUNET_CONTAINER_multihashmap_put (dc->active, - &dr->chk.query, - dr, + GNUNET_CONTAINER_multihashmap_put (dc->active, &dr->chk.query, dr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); if (dc->client == NULL) return; /* download not active */ GNUNET_CONTAINER_DLL_insert (dc->pending_head, dc->pending_tail, dr); dr->is_pending = GNUNET_YES; if (NULL == dc->th) - dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, - sizeof (struct SearchMessage), - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - GNUNET_NO, - &transmit_download_request, - dc); + dc->th = + GNUNET_CLIENT_notify_transmit_ready (dc->client, + sizeof (struct SearchMessage), + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + GNUNET_NO, + &transmit_download_request, dc); } @@ -768,8 +762,7 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc, * @param data contents of the file (or NULL if they were not inlined) */ static void -trigger_recursive_download (void *cls, - const char *filename, +trigger_recursive_download (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta, size_t length, const void *data) @@ -790,8 +783,7 @@ trigger_recursive_download (void *cls, cpos = dc->child_head; while (cpos != NULL) { - if ((GNUNET_FS_uri_test_equal (uri, - cpos->uri)) || + if ((GNUNET_FS_uri_test_equal (uri, cpos->uri)) || ((filename != NULL) && (0 == strcmp (cpos->filename, filename)))) break; cpos = cpos->next; @@ -812,8 +804,8 @@ trigger_recursive_download (void *cls, { ext = fn; us = GNUNET_FS_uri_to_string (uri); - GNUNET_asprintf (&fn, - "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)], ext); + GNUNET_asprintf (&fn, "%s%s", &us[strlen (GNUNET_FS_URI_CHK_PREFIX)], + ext); GNUNET_free (ext); GNUNET_free (us); } @@ -858,9 +850,8 @@ trigger_recursive_download (void *cls, strstr (filename + strlen (filename) - strlen (GNUNET_FS_DIRECTORY_EXT), GNUNET_FS_DIRECTORY_EXT)))) { - GNUNET_asprintf (&full_name, - "%s%s%s%s", - dn, DIR_SEPARATOR_STR, sfn, GNUNET_FS_DIRECTORY_EXT); + GNUNET_asprintf (&full_name, "%s%s%s%s", dn, DIR_SEPARATOR_STR, sfn, + GNUNET_FS_DIRECTORY_EXT); } else { @@ -889,11 +880,7 @@ trigger_recursive_download (void *cls, (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size (meta)); #endif - GNUNET_FS_download_start (dc->h, - uri, - meta, - full_name, temp_name, - 0, + GNUNET_FS_download_start (dc->h, uri, meta, full_name, temp_name, 0, GNUNET_FS_uri_chk_get_file_size (uri), dc->anonymity, dc->options, NULL, dc); GNUNET_free_non_null (full_name); @@ -931,8 +918,8 @@ GNUNET_FS_free_download_request_ (struct DownloadRequest *dr) * @return GNUNET_YES (we should continue to iterate); unless serious error */ static int -process_result_with_request (void *cls, - const GNUNET_HashCode * key, void *value) +process_result_with_request (void *cls, const GNUNET_HashCode * key, + void *value) { struct ProcessResultClosure *prc = cls; struct DownloadRequest *dr = value; @@ -952,11 +939,9 @@ process_result_with_request (void *cls, #if DEBUG_DOWNLOAD GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received block `%s' matching pending request at depth %u and offset %llu/%llu\n", - GNUNET_h2s (key), - dr->depth, - (unsigned long long) dr->offset, - (unsigned long long) GNUNET_ntohll (dc->uri->data. - chk.file_length)); + GNUNET_h2s (key), dr->depth, (unsigned long long) dr->offset, + (unsigned long long) GNUNET_ntohll (dc->uri->data.chk. + file_length)); #endif bs = GNUNET_FS_tree_calculate_block_size (GNUNET_ntohll @@ -968,8 +953,8 @@ process_result_with_request (void *cls, _ ("Internal error or bogus download URI (expected %u bytes at depth %u and offset %llu/%llu, got %u bytes)\n"), bs, dr->depth, (unsigned long long) dr->offset, - (unsigned long long) GNUNET_ntohll (dc->uri->data. - chk.file_length), + (unsigned long long) GNUNET_ntohll (dc->uri->data.chk. + file_length), prc->size); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s", dc->emsg); while (dr->parent != NULL) @@ -996,18 +981,17 @@ process_result_with_request (void *cls, dc->emsg = GNUNET_strdup (_("internal error decrypting content")); goto signal_error; } - off = compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length), - dr->offset, dr->depth); + off = + compute_disk_offset (GNUNET_ntohll (dc->uri->data.chk.file_length), + dr->offset, dr->depth); /* save to disk */ if ((GNUNET_YES == prc->do_store) && - ((dc->filename != NULL) || - (is_recursive_download (dc))) && + ((dc->filename != NULL) || (is_recursive_download (dc))) && ((dr->depth == dc->treedepth) || (0 == (dc->options & GNUNET_FS_DOWNLOAD_NO_TEMPORARIES)))) { - fh = GNUNET_DISK_file_open (dc->filename != NULL - ? dc->filename - : dc->temp_filename, + fh = GNUNET_DISK_file_open (dc->filename != + NULL ? dc->filename : dc->temp_filename, GNUNET_DISK_OPEN_READWRITE | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ | @@ -1030,8 +1014,8 @@ process_result_with_request (void *cls, { GNUNET_asprintf (&dc->emsg, _("Failed to seek to offset %llu in file `%s': %s\n"), - (unsigned long long) off, - dc->filename, STRERROR (errno)); + (unsigned long long) off, dc->filename, + STRERROR (errno)); goto signal_error; } if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size)) @@ -1072,9 +1056,8 @@ process_result_with_request (void *cls, * says it is a directory or if no meta data is given AND filename * ends in '.gnd' (top-level case) */ if (is_recursive_download (dc)) - GNUNET_FS_directory_list_contents (prc->size, - pt, - off, &trigger_recursive_download, dc); + GNUNET_FS_directory_list_contents (prc->size, pt, off, + &trigger_recursive_download, dc); } dr->state = BRS_DOWNLOAD_DOWN; @@ -1094,16 +1077,17 @@ process_result_with_request (void *cls, #if DEBUG_DOWNLOAD GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download completed, truncating file to desired length %llu\n", - (unsigned long long) GNUNET_ntohll (dc->uri->data. - chk.file_length)); + (unsigned long long) GNUNET_ntohll (dc->uri->data.chk. + file_length)); #endif /* truncate file to size (since we store IBlocks at the end) */ if (dc->filename != NULL) { - if (0 != truncate (dc->filename, - GNUNET_ntohll (dc->uri->data.chk.file_length))) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "truncate", dc->filename); + if (0 != + truncate (dc->filename, + GNUNET_ntohll (dc->uri->data.chk.file_length))) + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate", + dc->filename); } GNUNET_assert (dr->depth == 0); check_completed (dc); @@ -1212,8 +1196,7 @@ process_result (struct GNUNET_FS_DownloadContext *dc, "Received result for query `%s' from `%s'-service\n", GNUNET_h2s (&prc.query), "FS"); #endif - GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, - &prc.query, + GNUNET_CONTAINER_multihashmap_get_multiple (dc->active, &prc.query, &process_result_with_request, &prc); } @@ -1233,8 +1216,7 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) const struct PutMessage *cm; uint16_t msize; - if ((NULL == msg) || - (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || + if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || (sizeof (struct PutMessage) > ntohs (msg->size))) { GNUNET_break (msg == NULL); @@ -1243,13 +1225,13 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) } msize = ntohs (msg->size); cm = (const struct PutMessage *) msg; - process_result (dc, - ntohl (cm->type), &cm[1], msize - sizeof (struct PutMessage)); + process_result (dc, ntohl (cm->type), &cm[1], + msize - sizeof (struct PutMessage)); if (dc->client == NULL) return; /* fatal error */ /* continue receiving */ - GNUNET_CLIENT_receive (dc->client, - &receive_results, dc, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (dc->client, &receive_results, dc, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -1315,19 +1297,19 @@ transmit_download_request (void *cls, size_t size, void *buf) } if (dc->pending_head != NULL) { - dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, - sizeof (struct SearchMessage), - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - GNUNET_NO, - &transmit_download_request, - dc); + dc->th = + GNUNET_CLIENT_notify_transmit_ready (dc->client, + sizeof (struct SearchMessage), + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + GNUNET_NO, + &transmit_download_request, dc); GNUNET_assert (dc->th != NULL); } if (GNUNET_NO == dc->in_receive) { dc->in_receive = GNUNET_YES; - GNUNET_CLIENT_receive (dc->client, - &receive_results, dc, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (dc->client, &receive_results, dc, + GNUNET_TIME_UNIT_FOREVER_REL); } return msize; } @@ -1357,12 +1339,12 @@ do_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) dc->client = client; if (dc->pending_head != NULL) { - dc->th = GNUNET_CLIENT_notify_transmit_ready (client, - sizeof (struct SearchMessage), - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - GNUNET_NO, - &transmit_download_request, - dc); + dc->th = + GNUNET_CLIENT_notify_transmit_ready (client, + sizeof (struct SearchMessage), + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + GNUNET_NO, + &transmit_download_request, dc); GNUNET_assert (dc->th != NULL); } } @@ -1423,9 +1405,9 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc) #if DEBUG_DOWNLOAD GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will try to reconnect in 1s\n"); #endif - dc->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &do_reconnect, dc); + dc->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect, + dc); } @@ -1459,12 +1441,12 @@ activate_fs_download (void *cls, struct GNUNET_CLIENT_Connection *client) #endif if (dc->pending_head != NULL) { - dc->th = GNUNET_CLIENT_notify_transmit_ready (dc->client, - sizeof (struct SearchMessage), - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - GNUNET_NO, - &transmit_download_request, - dc); + dc->th = + GNUNET_CLIENT_notify_transmit_ready (dc->client, + sizeof (struct SearchMessage), + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + GNUNET_NO, + &transmit_download_request, dc); GNUNET_assert (dc->th != NULL); } } @@ -1521,10 +1503,9 @@ deactivate_fs_download (void *cls) * the specified depth */ static struct DownloadRequest * -create_download_request (struct DownloadRequest *parent, - unsigned int depth, - uint64_t dr_offset, - uint64_t file_start_offset, uint64_t desired_length) +create_download_request (struct DownloadRequest *parent, unsigned int depth, + uint64_t dr_offset, uint64_t file_start_offset, + uint64_t desired_length) { struct DownloadRequest *dr; unsigned int i; @@ -1561,15 +1542,13 @@ create_download_request (struct DownloadRequest *parent, /* why else would we have gotten here to begin with? (that'd be a bad logic error) */ GNUNET_assert (dr->num_children > 0); - dr->children = GNUNET_malloc (dr->num_children * - sizeof (struct DownloadRequest *)); + dr->children = + GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *)); for (i = 0; i < dr->num_children; i++) - dr->children[i] = create_download_request (dr, - depth - 1, - dr_offset + - i * child_block_size, - file_start_offset, - desired_length); + dr->children[i] = + create_download_request (dr, depth - 1, + dr_offset + i * child_block_size, + file_start_offset, desired_length); } return dr; } @@ -1643,11 +1622,8 @@ get_next_block (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param block_size size of block (in bytes) */ static void -reconstruct_cb (void *cls, - const struct ContentHashKey *chk, - uint64_t offset, - unsigned int depth, - enum GNUNET_BLOCK_Type type, +reconstruct_cb (void *cls, const struct ContentHashKey *chk, uint64_t offset, + unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size) { struct GNUNET_FS_DownloadContext *dc = cls; @@ -1781,7 +1757,8 @@ GNUNET_FS_download_start_task_ (void *cls, GNUNET_DISK_OPEN_READWRITE | GNUNET_DISK_OPEN_CREATE | ((0 == - GNUNET_FS_uri_chk_get_file_size (dc->uri)) ? + GNUNET_FS_uri_chk_get_file_size (dc-> + uri)) ? GNUNET_DISK_OPEN_TRUNCATE : 0), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | @@ -1797,11 +1774,13 @@ GNUNET_FS_download_start_task_ (void *cls, return; if (dc->top_request == NULL) { - dc->top_request = create_download_request (NULL, dc->treedepth - 1, 0, - dc->offset, dc->length); + dc->top_request = + create_download_request (NULL, dc->treedepth - 1, 0, dc->offset, + dc->length); dc->top_request->state = BRS_CHK_SET; - dc->top_request->chk = (dc->uri->type == chk) - ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk; + dc->top_request->chk = + (dc->uri->type == + chk) ? dc->uri->data.chk.chk : dc->uri->data.loc.fi.chk; /* signal start */ GNUNET_FS_download_sync_ (dc); pi.status = GNUNET_FS_STATUS_DOWNLOAD_START; @@ -1811,9 +1790,9 @@ GNUNET_FS_download_start_task_ (void *cls, GNUNET_FS_download_start_downloading_ (dc); /* attempt reconstruction from disk */ if (GNUNET_YES == GNUNET_DISK_file_test (dc->filename)) - dc->rfh = GNUNET_DISK_file_open (dc->filename, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE); + dc->rfh = + GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (dc->top_request->state == BRS_CHK_SET) { if (dc->rfh != NULL) @@ -1884,12 +1863,10 @@ GNUNET_FS_download_start_task_ (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying bottom-up reconstruction of file `%s'\n", dc->filename); #endif - dc->te = GNUNET_FS_tree_encoder_create (dc->h, - dc->old_file_size, - dc, - &fh_reader, - &reconstruct_cb, - NULL, &reconstruct_cont); + dc->te = + GNUNET_FS_tree_encoder_create (dc->h, dc->old_file_size, dc, &fh_reader, + &reconstruct_cb, NULL, + &reconstruct_cont); dc->task = GNUNET_SCHEDULER_add_now (&get_next_block, dc); } else @@ -1929,8 +1906,8 @@ GNUNET_FS_download_signal_suspend_ (void *cls) dc->job_queue = NULL; } if (dc->parent != NULL) - GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, - dc->parent->child_tail, dc); + GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail, + dc); if (dc->task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (dc->task); @@ -1997,13 +1974,10 @@ struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta, - const char *filename, - const char *tempname, - uint64_t offset, - uint64_t length, - uint32_t anonymity, - enum GNUNET_FS_DownloadOptions options, - void *cctx, struct GNUNET_FS_DownloadContext *parent) + const char *filename, const char *tempname, + uint64_t offset, uint64_t length, uint32_t anonymity, + enum GNUNET_FS_DownloadOptions options, void *cctx, + struct GNUNET_FS_DownloadContext *parent) { struct GNUNET_FS_DownloadContext *dc; @@ -2016,8 +1990,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, return NULL; } #if DEBUG_DOWNLOAD - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting download `%s' of %llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n", filename, (unsigned long long) length); #endif dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext)); @@ -2057,13 +2030,13 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h, } #if DEBUG_DOWNLOAD - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Download tree has depth %u\n", dc->treedepth); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n", + dc->treedepth); #endif if (parent == NULL) { - dc->top = GNUNET_FS_make_top (dc->h, - &GNUNET_FS_download_signal_suspend_, dc); + dc->top = + GNUNET_FS_make_top (dc->h, &GNUNET_FS_download_signal_suspend_, dc); } dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc); return dc; @@ -2108,10 +2081,8 @@ struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchResult *sr, const char *filename, - const char *tempname, - uint64_t offset, - uint64_t length, - uint32_t anonymity, + const char *tempname, uint64_t offset, + uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx) { @@ -2131,8 +2102,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, return NULL; } #if DEBUG_DOWNLOAD - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting download `%s' of %llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting download `%s' of %llu bytes\n", filename, (unsigned long long) length); #endif dc = GNUNET_malloc (sizeof (struct GNUNET_FS_DownloadContext)); @@ -2174,8 +2144,8 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h, } #if DEBUG_DOWNLOAD - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Download tree has depth %u\n", dc->treedepth); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download tree has depth %u\n", + dc->treedepth); #endif dc->task = GNUNET_SCHEDULER_add_now (&GNUNET_FS_download_start_task_, dc); return dc; @@ -2193,12 +2163,9 @@ GNUNET_FS_download_start_downloading_ (struct GNUNET_FS_DownloadContext *dc) if (dc->completed == dc->length) return; GNUNET_assert (dc->job_queue == NULL); - dc->job_queue = GNUNET_FS_queue_ (dc->h, - &activate_fs_download, - &deactivate_fs_download, - dc, - (dc->length + DBLOCK_SIZE - - 1) / DBLOCK_SIZE); + dc->job_queue = + GNUNET_FS_queue_ (dc->h, &activate_fs_download, &deactivate_fs_download, + dc, (dc->length + DBLOCK_SIZE - 1) / DBLOCK_SIZE); } @@ -2242,19 +2209,20 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete) while (NULL != dc->child_head) GNUNET_FS_download_stop (dc->child_head, do_delete); if (dc->parent != NULL) - GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, - dc->parent->child_tail, dc); + GNUNET_CONTAINER_DLL_remove (dc->parent->child_head, dc->parent->child_tail, + dc); if (dc->serialization != NULL) GNUNET_FS_remove_sync_file_ (dc->h, - ((dc->parent != NULL) || (dc->search != NULL)) - ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD - : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, + ((dc->parent != NULL) || + (dc->search != + NULL)) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD : + GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, dc->serialization); if ((GNUNET_YES == have_children) && (dc->parent == NULL)) GNUNET_FS_remove_sync_dir_ (dc->h, - (dc->search != NULL) - ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD - : GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, + (dc->search != + NULL) ? GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD : + GNUNET_FS_SYNC_PATH_MASTER_DOWNLOAD, dc->serialization); pi.status = GNUNET_FS_STATUS_DOWNLOAD_STOPPED; GNUNET_FS_download_make_status_ (&pi, dc); @@ -2270,8 +2238,8 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete) if ((dc->completed != dc->length) && (GNUNET_YES == do_delete)) { if (0 != UNLINK (dc->filename)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", dc->filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + dc->filename); } GNUNET_free (dc->filename); } @@ -2280,8 +2248,8 @@ GNUNET_FS_download_stop (struct GNUNET_FS_DownloadContext *dc, int do_delete) if (NULL != dc->temp_filename) { if (0 != UNLINK (dc->temp_filename)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "unlink", dc->temp_filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", + dc->temp_filename); GNUNET_free (dc->temp_filename); } GNUNET_free_non_null (dc->serialization); diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index bb323bbbc..6809e3055 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -52,18 +52,13 @@ * @return always 0 to continue extracting */ static int -add_to_md (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, const char *data, size_t data_len) +add_to_md (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, const char *data_mime_type, + const char *data, size_t data_len) { struct GNUNET_CONTAINER_MetaData *md = cls; - (void) GNUNET_CONTAINER_meta_data_insert (md, - plugin_name, - type, - format, + (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, data_mime_type, data, data_len); return 0; } @@ -76,8 +71,8 @@ add_to_md (void *cls, * of meta-data items obtained */ int -GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData - *md, const char *filename, +GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData *md, + const char *filename, struct EXTRACTOR_PluginList *extractors) { int old; @@ -160,13 +155,12 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, GNUNET_break (0); return NULL; } - ret = GNUNET_FS_file_information_create_from_reader (h, - client_info, - sbuf.st_size, - &GNUNET_FS_data_reader_file_, - fi, - keywords, - meta, do_index, bo); + ret = + GNUNET_FS_file_information_create_from_reader (h, client_info, + sbuf.st_size, + &GNUNET_FS_data_reader_file_, + fi, keywords, meta, + do_index, bo); if (ret == NULL) return NULL; ret->h = h; @@ -179,8 +173,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, #endif while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) fn = ss + 1; - GNUNET_CONTAINER_meta_data_insert (ret->meta, - "", + GNUNET_CONTAINER_meta_data_insert (ret->meta, "", EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, EXTRACTOR_METAFORMAT_C_STRING, "text/plain", fn, strlen (fn) + 1); @@ -206,8 +199,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h, */ struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, - void *client_info, - uint64_t length, + void *client_info, uint64_t length, void *data, const struct GNUNET_FS_Uri *keywords, @@ -222,13 +214,10 @@ GNUNET_FS_file_information_create_from_data (struct GNUNET_FS_Handle *h, GNUNET_break (0); return NULL; } - return GNUNET_FS_file_information_create_from_reader (h, - client_info, - length, + return GNUNET_FS_file_information_create_from_reader (h, client_info, length, &GNUNET_FS_data_reader_copy_, - data, - keywords, - meta, do_index, bo); + data, keywords, meta, + do_index, bo); } @@ -357,15 +346,13 @@ dir_scan_cb (void *cls, const char *filename) if (0 != STAT (filename, &sbuf)) { - GNUNET_asprintf (&dsc->emsg, - _("`%s' failed on file `%s': %s"), - "stat", filename, STRERROR (errno)); + GNUNET_asprintf (&dsc->emsg, _("`%s' failed on file `%s': %s"), "stat", + filename, STRERROR (errno)); return GNUNET_SYSERR; } if (S_ISDIR (sbuf.st_mode)) { - fi = GNUNET_FS_file_information_create_from_directory (dsc->h, - NULL, + fi = GNUNET_FS_file_information_create_from_directory (dsc->h, NULL, filename, dsc->scanner, dsc->scanner_cls, @@ -383,11 +370,8 @@ dir_scan_cb (void *cls, const char *filename) GNUNET_FS_meta_data_extract_from_file (meta, filename, dsc->extractors); keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords); - fi = GNUNET_FS_file_information_create_from_file (dsc->h, - NULL, - filename, - ksk_uri, - meta, + fi = GNUNET_FS_file_information_create_from_file (dsc->h, NULL, filename, + ksk_uri, meta, dsc->do_index, dsc->bo); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_FS_uri_destroy (keywords); @@ -420,10 +404,8 @@ dir_scan_cb (void *cls, const char *filename) * @return GNUNET_OK on success */ int -GNUNET_FS_directory_scanner_default (void *cls, - struct GNUNET_FS_Handle *h, - const char *dirname, - int do_index, +GNUNET_FS_directory_scanner_default (void *cls, struct GNUNET_FS_Handle *h, + const char *dirname, int do_index, const struct GNUNET_FS_BlockOptions *bo, GNUNET_FS_FileProcessor proc, void *proc_cls, char **emsg) @@ -527,9 +509,9 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, scanner (scanner_cls, h, filename, do_index, bo, &dirproc, &dc, emsg); ksk = NULL; // FIXME... // FIXME: create meta! - ret = GNUNET_FS_file_information_create_empty_directory (h, - client_info, - ksk, meta, bo); + ret = + GNUNET_FS_file_information_create_empty_directory (h, client_info, ksk, + meta, bo); GNUNET_CONTAINER_meta_data_destroy (meta); ret->data.dir.entries = dc.entries; while (dc.entries != NULL) @@ -541,8 +523,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, while ((NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) && (strlen (ss) > 1)) fn = ss + 1; GNUNET_asprintf (&dn, "%s/", fn); - GNUNET_CONTAINER_meta_data_insert (ret->meta, - "", + GNUNET_CONTAINER_meta_data_insert (ret->meta, "", EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, EXTRACTOR_METAFORMAT_C_STRING, "text/plain", dn, strlen (dn) + 1); @@ -656,10 +637,9 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir, no = GNUNET_NO; if (GNUNET_OK != - proc (proc_cls, - dir, - (dir->is_directory) ? dir->data.dir.dir_size : dir->data. - file.file_size, dir->meta, &dir->keywords, &dir->bo, + proc (proc_cls, dir, + (dir->is_directory) ? dir->data.dir.dir_size : dir->data.file. + file_size, dir->meta, &dir->keywords, &dir->bo, (dir->is_directory) ? &no : &dir->data.file.do_index, &dir->client_info)) return; @@ -670,10 +650,9 @@ GNUNET_FS_file_information_inspect (struct GNUNET_FS_FileInformation *dir, { no = GNUNET_NO; if (GNUNET_OK != - proc (proc_cls, - pos, - (pos->is_directory) ? pos->data.dir.dir_size : pos->data. - file.file_size, pos->meta, &pos->keywords, &pos->bo, + proc (proc_cls, pos, + (pos->is_directory) ? pos->data.dir.dir_size : pos->data.file. + file_size, pos->meta, &pos->keywords, &pos->bo, (dir->is_directory) ? &no : &dir->data.file.do_index, &pos->client_info)) break; @@ -711,10 +690,8 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, } /* clean up client-info */ if (NULL != cleaner) - cleaner (cleaner_cls, - fi, - fi->data.dir.dir_size, - fi->meta, &fi->keywords, &fi->bo, &no, &fi->client_info); + cleaner (cleaner_cls, fi, fi->data.dir.dir_size, fi->meta, &fi->keywords, + &fi->bo, &no, &fi->client_info); GNUNET_free_non_null (fi->data.dir.dir_data); } else @@ -724,20 +701,17 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL); /* clean up client-info */ if (NULL != cleaner) - cleaner (cleaner_cls, - fi, - fi->data.file.file_size, - fi->meta, - &fi->keywords, - &fi->bo, &fi->data.file.do_index, &fi->client_info); + cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta, + &fi->keywords, &fi->bo, &fi->data.file.do_index, + &fi->client_info); } GNUNET_free_non_null (fi->filename); GNUNET_free_non_null (fi->emsg); GNUNET_free_non_null (fi->chk_uri); /* clean up serialization */ if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization))) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", fi->serialization); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + fi->serialization); if (NULL != fi->keywords) GNUNET_FS_uri_destroy (fi->keywords); if (NULL != fi->meta) diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c index 6c54fd69b..b50d0624b 100644 --- a/src/fs/fs_getopt.c +++ b/src/fs/fs_getopt.c @@ -154,9 +154,7 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext (tmp[strlen (typename)] == ':') && (0 == strncmp (typename, tmp, strlen (typename)))) { - GNUNET_CONTAINER_meta_data_insert (meta, - "", - type, + GNUNET_CONTAINER_meta_data_insert (meta, "", type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", &tmp[strlen (typename) + 1], @@ -170,9 +168,7 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext (tmp[strlen (typename_i18n)] == ':') && (0 == strncmp (typename_i18n, tmp, strlen (typename_i18n)))) { - GNUNET_CONTAINER_meta_data_insert (meta, - "", - type, + GNUNET_CONTAINER_meta_data_insert (meta, "", type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", &tmp[strlen (typename_i18n) + 1], @@ -186,11 +182,10 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext } if (tmp != NULL) { - GNUNET_CONTAINER_meta_data_insert (meta, - "", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_UNKNOWN, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", tmp, strlen (tmp) + 1); + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + tmp, strlen (tmp) + 1); GNUNET_free (tmp); printf (_ ("Unknown metadata type in metadata option `%s'. Using metadata type `unknown' instead.\n"), diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c index 1eb290f11..85e12db32 100644 --- a/src/fs/fs_list_indexed.c +++ b/src/fs/fs_list_indexed.c @@ -98,8 +98,7 @@ handle_index_info (void *cls, const struct GNUNET_MessageHeader *msg) if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END) { /* normal end-of-list */ - GNUNET_SCHEDULER_add_continuation (gic->cont, - gic->cont_cls, + GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); GNUNET_free (gic); @@ -125,17 +124,15 @@ handle_index_info (void *cls, const struct GNUNET_MessageHeader *msg) } if (GNUNET_OK != gic->iterator (gic->iterator_cls, filename, &iim->file_id)) { - GNUNET_SCHEDULER_add_continuation (gic->cont, - gic->cont_cls, + GNUNET_SCHEDULER_add_continuation (gic->cont, gic->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_CLIENT_disconnect (gic->client, GNUNET_NO); GNUNET_free (gic); return; } /* get more */ - GNUNET_CLIENT_receive (gic->client, - &handle_index_info, - gic, GNUNET_CONSTANTS_SERVICE_TIMEOUT); + GNUNET_CLIENT_receive (gic->client, &handle_index_info, gic, + GNUNET_CONSTANTS_SERVICE_TIMEOUT); } @@ -153,8 +150,8 @@ handle_index_info (void *cls, const struct GNUNET_MessageHeader *msg) void GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, GNUNET_FS_IndexedFileProcessor iterator, - void *iterator_cls, - GNUNET_SCHEDULER_Task cont, void *cont_cls) + void *iterator_cls, GNUNET_SCHEDULER_Task cont, + void *cont_cls) { struct GNUNET_CLIENT_Connection *client; struct GetIndexedContext *gic; @@ -165,8 +162,7 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to not connect to `%s' service.\n"), "fs"); - GNUNET_SCHEDULER_add_continuation (cont, - cont_cls, + GNUNET_SCHEDULER_add_continuation (cont, cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); return; } @@ -181,8 +177,7 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, msg.size = htons (sizeof (struct GNUNET_MessageHeader)); msg.type = htons (GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET); GNUNET_assert (GNUNET_OK == - GNUNET_CLIENT_transmit_and_get_response (client, - &msg, + GNUNET_CLIENT_transmit_and_get_response (client, &msg, GNUNET_CONSTANTS_SERVICE_TIMEOUT, GNUNET_YES, &handle_index_info, diff --git a/src/fs/fs_misc.c b/src/fs/fs_misc.c index 9fa86a5c4..3a8260d05 100644 --- a/src/fs/fs_misc.c +++ b/src/fs/fs_misc.c @@ -108,44 +108,45 @@ GNUNET_FS_meta_data_suggest_filename (const struct GNUNET_CONTAINER_MetaData char *base; const char *ext; - ret = GNUNET_CONTAINER_meta_data_get_by_type (md, - EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); + ret = + GNUNET_CONTAINER_meta_data_get_by_type (md, + EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); if (ret != NULL) return ret; ext = NULL; - mime = GNUNET_CONTAINER_meta_data_get_by_type (md, - EXTRACTOR_METATYPE_MIMETYPE); + mime = + GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_MIMETYPE); if (mime != NULL) { i = 0; while ((mimeMap[i][0] != NULL) && (0 != strcmp (mime, mimeMap[i][0]))) i++; if (mimeMap[i][1] == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | - GNUNET_ERROR_TYPE_BULK, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, _("Did not find mime type `%s' in extension list.\n"), mime); else ext = mimeMap[i][1]; GNUNET_free (mime); } - base = GNUNET_CONTAINER_meta_data_get_first_by_types (md, - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METATYPE_BOOK_TITLE, - EXTRACTOR_METATYPE_ORIGINAL_TITLE, - EXTRACTOR_METATYPE_PACKAGE_NAME, - EXTRACTOR_METATYPE_URL, - EXTRACTOR_METATYPE_URI, - EXTRACTOR_METATYPE_DESCRIPTION, - EXTRACTOR_METATYPE_ISRC, - EXTRACTOR_METATYPE_JOURNAL_NAME, - EXTRACTOR_METATYPE_AUTHOR_NAME, - EXTRACTOR_METATYPE_SUBJECT, - EXTRACTOR_METATYPE_ALBUM, - EXTRACTOR_METATYPE_ARTIST, - EXTRACTOR_METATYPE_KEYWORDS, - EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METATYPE_UNKNOWN, - -1); + base = + GNUNET_CONTAINER_meta_data_get_first_by_types (md, + EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METATYPE_BOOK_TITLE, + EXTRACTOR_METATYPE_ORIGINAL_TITLE, + EXTRACTOR_METATYPE_PACKAGE_NAME, + EXTRACTOR_METATYPE_URL, + EXTRACTOR_METATYPE_URI, + EXTRACTOR_METATYPE_DESCRIPTION, + EXTRACTOR_METATYPE_ISRC, + EXTRACTOR_METATYPE_JOURNAL_NAME, + EXTRACTOR_METATYPE_AUTHOR_NAME, + EXTRACTOR_METATYPE_SUBJECT, + EXTRACTOR_METATYPE_ALBUM, + EXTRACTOR_METATYPE_ARTIST, + EXTRACTOR_METATYPE_KEYWORDS, + EXTRACTOR_METATYPE_COMMENT, + EXTRACTOR_METATYPE_UNKNOWN, + -1); if ((base == NULL) && (ext == NULL)) return NULL; if (base == NULL) diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index e8dd56ef4..236e8d59b 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c @@ -45,8 +45,8 @@ get_namespace_directory (struct GNUNET_FS_Handle *h) char *dn; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (h->cfg, - "FS", "IDENTITY_DIR", &dn)) + GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "IDENTITY_DIR", + &dn)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Configuration fails to specify `%s' in section `%s'\n"), @@ -71,8 +71,8 @@ get_update_information_directory (struct GNUNET_FS_Namespace *ns) char *ret; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (ns->h->cfg, - "FS", "UPDATE_DIR", &dn)) + GNUNET_CONFIGURATION_get_value_filename (ns->h->cfg, "FS", "UPDATE_DIR", + &dn)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Configuration fails to specify `%s' in section `%s'\n"), @@ -114,12 +114,9 @@ write_update_information_graph (struct GNUNET_FS_Namespace *ns) { n = ns->update_nodes[i]; uris = GNUNET_FS_uri_to_string (n->uri); - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, n->id)) || - (GNUNET_OK != - GNUNET_BIO_write_meta_data (wh, n->md)) || - (GNUNET_OK != - GNUNET_BIO_write_string (wh, n->update)) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) || + (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, uris))) { GNUNET_free (uris); @@ -129,8 +126,8 @@ write_update_information_graph (struct GNUNET_FS_Namespace *ns) } END: if (GNUNET_OK != GNUNET_BIO_write_close (wh)) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to write `%s': %s\n"), STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to write `%s': %s\n"), + STRERROR (errno)); GNUNET_free (fn); } @@ -185,10 +182,8 @@ read_update_information_graph (struct GNUNET_FS_Namespace *ns) for (i = 0; i < count; i++) { n = GNUNET_malloc (sizeof (struct NamespaceUpdateNode)); - if ((GNUNET_OK != - GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024)) || - (GNUNET_OK != - GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) || + if ((GNUNET_OK != GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024)) + || (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2))) @@ -320,8 +315,7 @@ advertisement_cont (void *cls, int success, const char *msg) if (GNUNET_OK != success) { /* error! */ - GNUNET_SCHEDULER_add_continuation (&do_disconnect, - ac->dsh, + GNUNET_SCHEDULER_add_continuation (&do_disconnect, ac->dsh, GNUNET_SCHEDULER_REASON_PREREQ_DONE); if (msg == NULL) { @@ -340,8 +334,7 @@ advertisement_cont (void *cls, int success, const char *msg) if (ac->pos == ac->ksk_uri->data.ksk.keywordCount) { /* done! */ - GNUNET_SCHEDULER_add_continuation (&do_disconnect, - ac->dsh, + GNUNET_SCHEDULER_add_continuation (&do_disconnect, ac->dsh, GNUNET_SCHEDULER_REASON_PREREQ_DONE); if (ac->cont != NULL) ac->cont (ac->cont_cls, ac->ksk_uri, NULL); @@ -359,8 +352,7 @@ advertisement_cont (void *cls, int success, const char *msg) GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); GNUNET_CRYPTO_aes_encrypt (ac->pt, ac->pt_size, &skey, &iv, &ac->nb[1]); GNUNET_break (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (ac->ns->key, - &ac->nb->ns_purpose, + GNUNET_CRYPTO_rsa_sign (ac->ns->key, &ac->nb->ns_purpose, &ac->nb->ns_signature)); pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); GNUNET_assert (pk != NULL); @@ -369,22 +361,16 @@ advertisement_cont (void *cls, int success, const char *msg) sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &query); GNUNET_break (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (pk, - &ac->nb->ksk_purpose, + GNUNET_CRYPTO_rsa_sign (pk, &ac->nb->ksk_purpose, &ac->nb->ksk_signature)); GNUNET_CRYPTO_rsa_key_free (pk); GNUNET_DATASTORE_put (ac->dsh, 0 /* no reservation */ , - &query, - ac->pt_size + sizeof (struct NBlock), - ac->nb, - GNUNET_BLOCK_TYPE_FS_NBLOCK, - ac->bo.content_priority, - ac->bo.anonymity_level, - ac->bo.replication_level, - ac->bo.expiration_time, - -2, 1, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - &advertisement_cont, ac); + &query, ac->pt_size + sizeof (struct NBlock), ac->nb, + GNUNET_BLOCK_TYPE_FS_NBLOCK, ac->bo.content_priority, + ac->bo.anonymity_level, ac->bo.replication_level, + ac->bo.expiration_time, -2, 1, + GNUNET_CONSTANTS_SERVICE_TIMEOUT, &advertisement_cont, + ac); } @@ -437,10 +423,9 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, pt = GNUNET_malloc (mdsize + reslen); memcpy (pt, rootEntry, reslen); mdst = &pt[reslen]; - mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, - &mdst, - mdsize, - GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); + mdsize = + GNUNET_CONTAINER_meta_data_serialize (meta, &mdst, mdsize, + GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); if (mdsize == -1) { GNUNET_break (0); @@ -451,11 +436,10 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, size = mdsize + sizeof (struct NBlock) + reslen; nb = GNUNET_malloc (size); GNUNET_CRYPTO_rsa_key_get_public (namespace->key, &nb->subspace); - nb->ns_purpose.size = htonl (mdsize + reslen + - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) - + - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); + nb->ns_purpose.size = + htonl (mdsize + reslen + + sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK); nb->ksk_purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature)); @@ -541,8 +525,8 @@ GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace, int freeze) if (freeze) { if (0 != UNLINK (namespace->filename)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "unlink", namespace->filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "unlink", + namespace->filename); } if (0 == namespace->rc) { @@ -558,8 +542,8 @@ GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *namespace, int freeze) GNUNET_free (nsn->update); GNUNET_free (nsn); } - GNUNET_array_grow (namespace->update_nodes, - namespace->update_node_count, 0); + GNUNET_array_grow (namespace->update_nodes, namespace->update_node_count, + 0); if (namespace->update_map != NULL) GNUNET_CONTAINER_multihashmap_destroy (namespace->update_map); GNUNET_free (namespace); @@ -733,8 +717,7 @@ sb_put_cont (void *cls, int success, const char *msg) if (psc->namespace->update_map != NULL) { GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc); - GNUNET_CONTAINER_multihashmap_put (psc->namespace->update_map, - &hc, + GNUNET_CONTAINER_multihashmap_put (psc->namespace->update_map, &hc, psc->nsn, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } @@ -775,8 +758,7 @@ sb_put_cont (void *cls, int success, const char *msg) void GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, struct GNUNET_FS_Namespace *namespace, - const char *identifier, - const char *update, + const char *identifier, const char *update, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, @@ -829,10 +811,9 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, memcpy (dest, uris, slen); GNUNET_free (uris); dest += slen; - mdsize = GNUNET_CONTAINER_meta_data_serialize (mmeta, - &dest, - mdsize, - GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); + mdsize = + GNUNET_CONTAINER_meta_data_serialize (mmeta, &dest, mdsize, + GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); GNUNET_CONTAINER_meta_data_destroy (mmeta); if (mdsize == -1) { @@ -852,19 +833,18 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &sks_uri->data.sks.namespace); sks_uri->data.sks.identifier = GNUNET_strdup (identifier); - GNUNET_CRYPTO_hash_xor (&id, - &sks_uri->data.sks.namespace, &sb_enc->identifier); + GNUNET_CRYPTO_hash_xor (&id, &sks_uri->data.sks.namespace, + &sb_enc->identifier); GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv); - GNUNET_CRYPTO_aes_encrypt (&sb[1], - size - sizeof (struct SBlock), - &sk, &iv, &sb_enc[1]); + GNUNET_CRYPTO_aes_encrypt (&sb[1], size - sizeof (struct SBlock), &sk, &iv, + &sb_enc[1]); sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK); - sb_enc->purpose.size = htonl (slen + mdsize + nidlen - + sizeof (struct SBlock) - - sizeof (struct GNUNET_CRYPTO_RsaSignature)); + sb_enc->purpose.size = + htonl (slen + mdsize + nidlen + sizeof (struct SBlock) - + sizeof (struct GNUNET_CRYPTO_RsaSignature)); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (namespace->key, - &sb_enc->purpose, &sb_enc->signature)); + GNUNET_CRYPTO_rsa_sign (namespace->key, &sb_enc->purpose, + &sb_enc->signature)); psc = GNUNET_malloc (sizeof (struct PublishSksContext)); psc->uri = sks_uri; psc->cont = cont; @@ -895,17 +875,10 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta); psc->nsn->uri = GNUNET_FS_uri_dup (uri); } - GNUNET_DATASTORE_put (psc->dsh, - 0, - &sb_enc->identifier, - size, - sb_enc, - GNUNET_BLOCK_TYPE_FS_SBLOCK, - bo->content_priority, - bo->anonymity_level, - bo->replication_level, - bo->expiration_time, - -2, 1, + GNUNET_DATASTORE_put (psc->dsh, 0, &sb_enc->identifier, size, sb_enc, + GNUNET_BLOCK_TYPE_FS_SBLOCK, bo->content_priority, + bo->anonymity_level, bo->replication_level, + bo->expiration_time, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &sb_put_cont, psc); GNUNET_free (sb); GNUNET_free (sb_enc); @@ -1030,8 +1003,8 @@ find_trees (void *cls, const GNUNET_HashCode * key, void *value) nsn->tree_id = UINT_MAX; /* mark as undef */ /* trace */ GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc); - GNUNET_CONTAINER_multihashmap_get_multiple (fc->namespace->update_map, - &hc, &find_trees, fc); + GNUNET_CONTAINER_multihashmap_get_multiple (fc->namespace->update_map, &hc, + &find_trees, fc); } return GNUNET_YES; } @@ -1093,9 +1066,7 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, { nsn = namespace->update_nodes[i]; GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc); - GNUNET_CONTAINER_multihashmap_put (namespace->update_map, - &hc, - nsn, + GNUNET_CONTAINER_multihashmap_put (namespace->update_map, &hc, nsn, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } } @@ -1104,8 +1075,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc); pc.ip = ip; pc.ip_cls = ip_cls; - GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, - &hc, &process_update_node, &pc); + GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc, + &process_update_node, &pc); return; } #if DEBUG_NAMESPACE @@ -1123,8 +1094,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, if (nsn->nug == nug) { #if DEBUG_NAMESPACE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "TREE of node `%s' is %u\n", nsn->id, nsn->nug); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id, + nsn->nug); #endif continue; /* already placed in TREE */ } @@ -1133,8 +1104,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, fc.id = UINT_MAX; fc.nug = nug; fc.namespace = namespace; - GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, - &hc, &find_trees, &fc); + GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc, + &find_trees, &fc); if (fc.id == UINT_MAX) { /* start new TREE */ @@ -1154,16 +1125,16 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, } #if DEBUG_NAMESPACE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting new TREE %u with node `%s'\n", - nsn->tree_id, nsn->id); + "Starting new TREE %u with node `%s'\n", nsn->tree_id, + nsn->id); #endif /* put all nodes with same identifier into this TREE */ GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc); fc.id = nsn->tree_id; fc.nug = nug; fc.namespace = namespace; - GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, - &hc, &find_trees, &fc); + GNUNET_CONTAINER_multihashmap_get_multiple (namespace->update_map, &hc, + &find_trees, &fc); } else { @@ -1172,8 +1143,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, nsn->tree_id = fc.id; } #if DEBUG_NAMESPACE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "TREE of node `%s' is %u\n", nsn->id, fc.id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TREE of node `%s' is %u\n", nsn->id, + fc.id); #endif } for (i = 0; i < fc.tree_array_size; i++) @@ -1182,8 +1153,8 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace, if (NULL != nsn) { #if DEBUG_NAMESPACE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Root of TREE %u is node `%s'\n", i, nsn->id); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Root of TREE %u is node `%s'\n", i, + nsn->id); #endif ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update); diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 87161501b..746f4f099 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -58,11 +58,10 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, pi->value.publish.cctx = p->client_info; pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; pi->value.publish.filename = p->filename; - pi->value.publish.size - = (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; - pi->value.publish.eta - = GNUNET_TIME_calculate_eta (p->start_time, - offset, pi->value.publish.size); + pi->value.publish.size = + (p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; + pi->value.publish.eta = + GNUNET_TIME_calculate_eta (p->start_time, offset, pi->value.publish.size); pi->value.publish.completed = offset; pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time); @@ -132,8 +131,8 @@ ds_put_cont (void *cls, int success, const char *msg) if (GNUNET_SYSERR == pc->in_network_wait) { /* we were aborted in the meantime, finish shutdown! */ - GNUNET_SCHEDULER_add_continuation (&publish_cleanup, - pc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&publish_cleanup, pc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } GNUNET_assert (GNUNET_YES == pc->in_network_wait); @@ -155,8 +154,7 @@ ds_put_cont (void *cls, int success, const char *msg) } } GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -179,10 +177,10 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED; pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; pi.value.publish.specifics.completed.chk_uri = p->chk_uri; - p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, - GNUNET_ntohll (p-> - chk_uri->data. - chk.file_length)); + p->client_info = + GNUNET_FS_publish_make_status_ (&pi, pc, p, + GNUNET_ntohll (p->chk_uri->data.chk. + file_length)); } @@ -206,8 +204,8 @@ signal_publish_error (struct GNUNET_FS_FileInformation *p, pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; pi.value.publish.specifics.error.message = emsg; p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, 0); - if ((p->is_directory == GNUNET_NO) && - (p->filename != NULL) && (p->data.file.do_index == GNUNET_YES)) + if ((p->is_directory == GNUNET_NO) && (p->filename != NULL) && + (p->data.file.do_index == GNUNET_YES)) { /* run unindex to clean up */ GNUNET_FS_unindex_start (pc->h, p->filename, NULL); @@ -247,8 +245,8 @@ finish_release_reserve (void *cls, int success, const char *msg) * @param emsg NULL on success, otherwise error message */ static void -publish_sblocks_cont (void *cls, - const struct GNUNET_FS_Uri *uri, const char *emsg) +publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, + const char *emsg) { struct GNUNET_FS_PublishContext *pc = cls; @@ -261,12 +259,10 @@ publish_sblocks_cont (void *cls, GNUNET_assert (pc->qre == NULL); if ((pc->dsh != NULL) && (pc->rid != 0)) { - pc->qre = GNUNET_DATASTORE_release_reserve (pc->dsh, - pc->rid, - UINT_MAX, - UINT_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, - &finish_release_reserve, pc); + pc->qre = + GNUNET_DATASTORE_release_reserve (pc->dsh, pc->rid, UINT_MAX, UINT_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + &finish_release_reserve, pc); } else { @@ -285,13 +281,9 @@ static void publish_sblock (struct GNUNET_FS_PublishContext *pc) { if (NULL != pc->namespace) - GNUNET_FS_publish_sks (pc->h, - pc->namespace, - pc->nid, - pc->nuid, - pc->fi->meta, - pc->fi->chk_uri, - &pc->fi->bo, pc->options, &publish_sblocks_cont, pc); + GNUNET_FS_publish_sks (pc->h, pc->namespace, pc->nid, pc->nuid, + pc->fi->meta, pc->fi->chk_uri, &pc->fi->bo, + pc->options, &publish_sblocks_cont, pc); else publish_sblocks_cont (pc, NULL, NULL); } @@ -307,8 +299,8 @@ publish_sblock (struct GNUNET_FS_PublishContext *pc) * @param emsg NULL on success, otherwise error message */ static void -publish_kblocks_cont (void *cls, - const struct GNUNET_FS_Uri *uri, const char *emsg) +publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, + const char *emsg) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p = pc->fi_pos; @@ -316,15 +308,14 @@ publish_kblocks_cont (void *cls, if (NULL != emsg) { #if DEBUG_PUBLISH - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Error uploading KSK blocks: %s\n", emsg); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error uploading KSK blocks: %s\n", + emsg); #endif signal_publish_error (p, pc, emsg); GNUNET_FS_file_information_sync_ (p); GNUNET_FS_publish_sync_ (pc); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); return; @@ -342,8 +333,7 @@ publish_kblocks_cont (void *cls, pc->fi_pos = p->dir; GNUNET_FS_publish_sync_ (pc); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -384,8 +374,8 @@ block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) return 0; /* calling reader with pt_size==0 * might free buf, so don't! */ if (pt_size != - p->data.file.reader (p->data.file.reader_cls, - offset, pt_size, buf, emsg)) + p->data.file.reader (p->data.file.reader_cls, offset, pt_size, buf, + emsg)) return 0; } return pt_size; @@ -438,8 +428,7 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* continue with main */ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -460,11 +449,9 @@ encode_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param block_size size of block (in bytes) */ static void -block_proc (void *cls, - const struct ContentHashKey *chk, - uint64_t offset, - unsigned int depth, - enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size) +block_proc (void *cls, const struct ContentHashKey *chk, uint64_t offset, + unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, + uint16_t block_size) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p; @@ -477,8 +464,7 @@ block_proc (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for datastore connection\n"); #endif GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); return; @@ -486,54 +472,42 @@ block_proc (void *cls, GNUNET_assert (GNUNET_NO == pc->in_network_wait); pc->in_network_wait = GNUNET_YES; - if ((!p->is_directory) && - (GNUNET_YES == p->data.file.do_index) && + if ((!p->is_directory) && (GNUNET_YES == p->data.file.do_index) && (type == GNUNET_BLOCK_TYPE_FS_DBLOCK)) { #if DEBUG_PUBLISH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Indexing block `%s' for offset %llu with index size %u\n", - GNUNET_h2s (&chk->query), - (unsigned long long) offset, sizeof (struct OnDemandBlock)); + GNUNET_h2s (&chk->query), (unsigned long long) offset, + sizeof (struct OnDemandBlock)); #endif odb.offset = GNUNET_htonll (offset); odb.file_id = p->data.file.file_id; GNUNET_assert (pc->qre == NULL); - pc->qre = GNUNET_DATASTORE_put (pc->dsh, - (p->is_directory) ? 0 : pc->rid, - &chk->query, - sizeof (struct OnDemandBlock), - &odb, - GNUNET_BLOCK_TYPE_FS_ONDEMAND, - p->bo.content_priority, - p->bo.anonymity_level, - p->bo.replication_level, - p->bo.expiration_time, - -2, 1, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - &ds_put_cont, pc); + pc->qre = + GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid, + &chk->query, sizeof (struct OnDemandBlock), &odb, + GNUNET_BLOCK_TYPE_FS_ONDEMAND, + p->bo.content_priority, p->bo.anonymity_level, + p->bo.replication_level, p->bo.expiration_time, + -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, + &ds_put_cont, pc); return; } #if DEBUG_PUBLISH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing block `%s' for offset %llu with size %u\n", - GNUNET_h2s (&chk->query), - (unsigned long long) offset, (unsigned int) block_size); + GNUNET_h2s (&chk->query), (unsigned long long) offset, + (unsigned int) block_size); #endif GNUNET_assert (pc->qre == NULL); - pc->qre = GNUNET_DATASTORE_put (pc->dsh, - (p->is_directory) ? 0 : pc->rid, - &chk->query, - block_size, - block, - type, - p->bo.content_priority, - p->bo.anonymity_level, - p->bo.replication_level, - p->bo.expiration_time, - -2, 1, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - &ds_put_cont, pc); + pc->qre = + GNUNET_DATASTORE_put (pc->dsh, (p->is_directory) ? 0 : pc->rid, + &chk->query, block_size, block, type, + p->bo.content_priority, p->bo.anonymity_level, + p->bo.replication_level, p->bo.expiration_time, -2, + 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont, + pc); } @@ -548,9 +522,8 @@ block_proc (void *cls, * @param depth depth of the block in the tree, 0 for DBLOCK */ static void -progress_proc (void *cls, - uint64_t offset, - const void *pt_block, size_t pt_size, unsigned int depth) +progress_proc (void *cls, uint64_t offset, const void *pt_block, size_t pt_size, + unsigned int depth) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p; @@ -610,10 +583,9 @@ publish_content (struct GNUNET_FS_PublishContext *pc) raw_data = GNUNET_malloc (dirpos->data.file.file_size); emsg = NULL; if (dirpos->data.file.file_size != - dirpos->data.file.reader (dirpos->data.file.reader_cls, - 0, - dirpos->data.file.file_size, - raw_data, &emsg)) + dirpos->data.file.reader (dirpos->data.file.reader_cls, 0, + dirpos->data.file.file_size, raw_data, + &emsg)) { GNUNET_free_non_null (emsg); GNUNET_free (raw_data); @@ -621,17 +593,15 @@ publish_content (struct GNUNET_FS_PublishContext *pc) } } } - GNUNET_FS_directory_builder_add (db, - dirpos->chk_uri, - dirpos->meta, raw_data); + GNUNET_FS_directory_builder_add (db, dirpos->chk_uri, dirpos->meta, + raw_data); GNUNET_free_non_null (raw_data); dirpos = dirpos->next; } GNUNET_free_non_null (p->data.dir.dir_data); p->data.dir.dir_data = NULL; p->data.dir.dir_size = 0; - GNUNET_FS_directory_builder_finish (db, - &p->data.dir.dir_size, + GNUNET_FS_directory_builder_finish (db, &p->data.dir.dir_size, &p->data.dir.dir_data); GNUNET_FS_file_information_sync_ (p); } @@ -639,12 +609,10 @@ publish_content (struct GNUNET_FS_PublishContext *pc) #if DEBUG_PUBLISH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tree encoder\n"); #endif - p->te = GNUNET_FS_tree_encoder_create (pc->h, - size, - pc, - &block_reader, - &block_proc, - &progress_proc, &encode_cont); + p->te = + GNUNET_FS_tree_encoder_create (pc->h, size, pc, &block_reader, + &block_proc, &progress_proc, + &encode_cont); } #if DEBUG_PUBLISH @@ -761,8 +729,7 @@ hash_for_index_cb (void *cls, const GNUNET_HashCode * res) return; } #if DEBUG_PUBLISH - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hash of indexed file `%s' is `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hash of indexed file `%s' is `%s'\n", p->filename, GNUNET_h2s (res)); #endif if (0 != (pc->options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) @@ -813,8 +780,7 @@ hash_for_index_cb (void *cls, const GNUNET_HashCode * res) GNUNET_free (fn); pc->client = client; GNUNET_break (GNUNET_YES == - GNUNET_CLIENT_transmit_and_get_response (client, - &ism->header, + GNUNET_CLIENT_transmit_and_get_response (client, &ism->header, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &process_index_start_response, @@ -854,9 +820,8 @@ GNUNET_FS_publish_main_ (void *cls, return; } /* find starting position */ - while ((p->is_directory) && - (NULL != p->data.dir.entries) && - (NULL == p->emsg) && (NULL == p->data.dir.entries->chk_uri)) + while ((p->is_directory) && (NULL != p->data.dir.entries) && (NULL == p->emsg) + && (NULL == p->data.dir.entries->chk_uri)) { p = p->data.dir.entries; pc->fi_pos = p; @@ -877,8 +842,8 @@ GNUNET_FS_publish_main_ (void *cls, p = p->dir; if (fn != NULL) { - GNUNET_asprintf (&p->emsg, - _("Recursive upload failed at `%s': %s"), fn, p->emsg); + GNUNET_asprintf (&p->emsg, _("Recursive upload failed at `%s': %s"), fn, + p->emsg); GNUNET_free (fn); } else @@ -904,8 +869,9 @@ GNUNET_FS_publish_main_ (void *cls, if (0 == p->bo.anonymity_level) { /* zero anonymity, box CHK URI in LOC URI */ - loc = GNUNET_FS_uri_loc_create (p->chk_uri, - pc->h->cfg, p->bo.expiration_time); + loc = + GNUNET_FS_uri_loc_create (p->chk_uri, pc->h->cfg, + p->bo.expiration_time); GNUNET_FS_uri_destroy (p->chk_uri); p->chk_uri = loc; } @@ -913,11 +879,8 @@ GNUNET_FS_publish_main_ (void *cls, /* upload of "p" complete, publish KBlocks! */ if (p->keywords != NULL) { - GNUNET_FS_publish_ksk (pc->h, - p->keywords, - p->meta, - p->chk_uri, - &p->bo, pc->options, &publish_kblocks_cont, pc); + GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, &p->bo, + pc->options, &publish_kblocks_cont, pc); } else { @@ -945,10 +908,9 @@ GNUNET_FS_publish_main_ (void *cls, else { p->start_time = GNUNET_TIME_absolute_get (); - pc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, - p->filename, - HASHING_BLOCKSIZE, - &hash_for_index_cb, pc); + pc->fhc = + GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, p->filename, + HASHING_BLOCKSIZE, &hash_for_index_cb, pc); } return; } @@ -971,12 +933,9 @@ GNUNET_FS_publish_main_ (void *cls, * @return GNUNET_OK to continue (always) */ static int -fip_signal_start (void *cls, - struct GNUNET_FS_FileInformation *fi, - uint64_t length, - struct GNUNET_CONTAINER_MetaData *meta, - struct GNUNET_FS_Uri **uri, - struct GNUNET_FS_BlockOptions *bo, +fip_signal_start (void *cls, struct GNUNET_FS_FileInformation *fi, + uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, + struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { struct GNUNET_FS_PublishContext *pc = cls; @@ -1040,13 +999,11 @@ fip_signal_start (void *cls, * @return GNUNET_OK to continue (always) */ static int -fip_signal_suspend (void *cls, - struct GNUNET_FS_FileInformation *fi, - uint64_t length, - struct GNUNET_CONTAINER_MetaData *meta, +fip_signal_suspend (void *cls, struct GNUNET_FS_FileInformation *fi, + uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, - struct GNUNET_FS_BlockOptions *bo, - int *do_index, void **client_info) + struct GNUNET_FS_BlockOptions *bo, int *do_index, + void **client_info) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_ProgressInfo pi; @@ -1118,15 +1075,14 @@ finish_reserve (void *cls, int success, const char *msg) #endif if ((msg != NULL) || (success <= 0)) { - GNUNET_asprintf (&pc->fi->emsg, - _("Insufficient space for publishing: %s"), msg); + GNUNET_asprintf (&pc->fi->emsg, _("Insufficient space for publishing: %s"), + msg); signal_publish_error (pc->fi, pc, pc->fi->emsg); return; } pc->rid = success; GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); - pc->upload_task - = + pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); } @@ -1148,8 +1104,7 @@ finish_reserve (void *cls, int success, const char *msg) struct GNUNET_FS_PublishContext * GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, - struct GNUNET_FS_Namespace *namespace, - const char *nid, + struct GNUNET_FS_Namespace *namespace, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options) { @@ -1203,8 +1158,7 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, else { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ret->upload_task); - ret->upload_task - = + ret->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, ret); } @@ -1227,12 +1181,9 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, * @return GNUNET_OK to continue (always) */ static int -fip_signal_stop (void *cls, - struct GNUNET_FS_FileInformation *fi, - uint64_t length, - struct GNUNET_CONTAINER_MetaData *meta, - struct GNUNET_FS_Uri **uri, - struct GNUNET_FS_BlockOptions *bo, +fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi, + uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, + struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { struct GNUNET_FS_PublishContext *pc = cls; @@ -1241,8 +1192,7 @@ fip_signal_stop (void *cls, if (fi->serialization != NULL) { - GNUNET_FS_remove_sync_file_ (pc->h, - GNUNET_FS_SYNC_PATH_FILE_INFO, + GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization); GNUNET_free (fi->serialization); fi->serialization = NULL; @@ -1383,8 +1333,8 @@ struct PublishKskContext * @param cls closure of type "struct PublishKskContext*" * @param tc unused */ -static void -publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void publish_ksk_cont (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -1418,8 +1368,8 @@ kb_put_cont (void *cls, int success, const char *msg) GNUNET_free (pkc); return; } - GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, - pkc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -1461,15 +1411,15 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++]; #if DEBUG_PUBLISH - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing under keyword `%s'\n", keyword); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n", + keyword); #endif /* first character of keyword indicates if it is * mandatory or not -- ignore for hashing */ GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key); GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); - GNUNET_CRYPTO_aes_encrypt (&pkc->kb[1], - pkc->slen + pkc->mdsize, &skey, &iv, &pkc->cpy[1]); + GNUNET_CRYPTO_aes_encrypt (&pkc->kb[1], pkc->slen + pkc->mdsize, &skey, &iv, + &pkc->cpy[1]); pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); GNUNET_assert (NULL != pk); GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace); @@ -1477,25 +1427,17 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &query); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (pk, - &pkc->cpy->purpose, + GNUNET_CRYPTO_rsa_sign (pk, &pkc->cpy->purpose, &pkc->cpy->signature)); GNUNET_CRYPTO_rsa_key_free (pk); - pkc->qre = GNUNET_DATASTORE_put (pkc->dsh, - 0, - &query, - pkc->mdsize + - sizeof (struct KBlock) + - pkc->slen, - pkc->cpy, - GNUNET_BLOCK_TYPE_FS_KBLOCK, - pkc->bo.content_priority, - pkc->bo.anonymity_level, - pkc->bo.replication_level, - pkc->bo.expiration_time, - -2, 1, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - &kb_put_cont, pkc); + pkc->qre = + GNUNET_DATASTORE_put (pkc->dsh, 0, &query, + pkc->mdsize + sizeof (struct KBlock) + pkc->slen, + pkc->cpy, GNUNET_BLOCK_TYPE_FS_KBLOCK, + pkc->bo.content_priority, pkc->bo.anonymity_level, + pkc->bo.replication_level, pkc->bo.expiration_time, + -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, + &kb_put_cont, pkc); } @@ -1561,10 +1503,9 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, GNUNET_free (uris); sptr = &kbe[pkc->slen]; if (meta != NULL) - pkc->mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, - &sptr, - pkc->mdsize, - GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); + pkc->mdsize = + GNUNET_CONTAINER_meta_data_serialize (meta, &sptr, pkc->mdsize, + GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); if (pkc->mdsize == -1) { GNUNET_break (0); @@ -1587,8 +1528,8 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h, pkc->mdsize + pkc->slen); pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK); pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); - GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, - pkc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&publish_ksk_cont, pkc, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 60b7a1cc8..89a8c5582 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c @@ -48,8 +48,8 @@ GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, pi->value.search.sc = sc; pi->value.search.cctx = sc->client_info; - pi->value.search.pctx - = (sc->psearch_result == NULL) ? NULL : sc->psearch_result->client_info; + pi->value.search.pctx = + (sc->psearch_result == NULL) ? NULL : sc->psearch_result->client_info; pi->value.search.query = sc->uri; pi->value.search.duration = GNUNET_TIME_absolute_get_duration (sc->start_time); @@ -121,10 +121,10 @@ notify_client_chk_update (struct GNUNET_FS_SearchContext *sc, pi.value.search.specifics.update.cctx = sr->client_info; pi.value.search.specifics.update.meta = sr->meta; pi.value.search.specifics.update.uri = sr->uri; - pi.value.search.specifics.update.availability_rank - = 2 * sr->availability_success - sr->availability_trials; - pi.value.search.specifics.update.availability_certainty - = sr->availability_trials; + pi.value.search.specifics.update.availability_rank = + 2 * sr->availability_success - sr->availability_trials; + pi.value.search.specifics.update.availability_certainty = + sr->availability_trials; pi.value.search.specifics.update.applicability_rank = sr->optional_support; sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc); } @@ -386,16 +386,15 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, /* check if new */ GNUNET_FS_uri_to_key (uri, &key); if (GNUNET_SYSERR == - GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, - &key, + GNUNET_CONTAINER_multihashmap_get_multiple (ent->results, &key, &test_result_present, (void *) uri)) return; /* duplicate result */ /* try to find search result in master map */ grc.sr = NULL; grc.uri = uri; - GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, - &key, &get_result_present, &grc); + GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, + &get_result_present, &grc); sr = grc.sr; is_new = (NULL == sr) || (sr->mandatory_missing > 0); if (NULL == sr) @@ -406,9 +405,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc, sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); sr->mandatory_missing = sc->mandatory_count; sr->key = key; - GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, - &key, - sr, + GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } else @@ -464,8 +461,7 @@ static struct GNUNET_FS_SearchContext *search_start (struct GNUNET_FS_Handle *h, * @param meta metadata associated with the URI */ static void -process_sks_result (struct GNUNET_FS_SearchContext *sc, - const char *id_update, +process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta) { @@ -475,11 +471,10 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, /* check if new */ GNUNET_FS_uri_to_key (uri, &key); - GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, - &uri->data.chk.chk.query, &key); + GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key, &uri->data.chk.chk.query, + &key); if (GNUNET_SYSERR == - GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, - &key, + GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map, &key, &test_result_present, (void *) uri)) return; /* duplicate result */ @@ -488,9 +483,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, sr->uri = GNUNET_FS_uri_dup (uri); sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); sr->key = key; - GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, - &key, - sr, + GNUNET_CONTAINER_multihashmap_put (sc->master_result_map, &key, sr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); GNUNET_FS_search_result_sync_ (sr); GNUNET_FS_search_start_probe_ (sr); @@ -515,8 +508,8 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, * @param size size of kb */ static void -process_kblock (struct GNUNET_FS_SearchContext *sc, - const struct KBlock *kb, size_t size) +process_kblock (struct GNUNET_FS_SearchContext *sc, const struct KBlock *kb, + size_t size) { unsigned int i; size_t j; @@ -544,9 +537,9 @@ process_kblock (struct GNUNET_FS_SearchContext *sc, } /* decrypt */ GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv); - if (-1 == GNUNET_CRYPTO_aes_decrypt (&kb[1], - size - sizeof (struct KBlock), - &skey, &iv, pt)) + if (-1 == + GNUNET_CRYPTO_aes_decrypt (&kb[1], size - sizeof (struct KBlock), &skey, + &iv, pt)) { GNUNET_break (0); return; @@ -593,8 +586,8 @@ process_kblock (struct GNUNET_FS_SearchContext *sc, * @param size size of nb */ static void -process_nblock (struct GNUNET_FS_SearchContext *sc, - const struct NBlock *nb, size_t size) +process_nblock (struct GNUNET_FS_SearchContext *sc, const struct NBlock *nb, + size_t size) { unsigned int i; size_t j; @@ -622,9 +615,9 @@ process_nblock (struct GNUNET_FS_SearchContext *sc, } /* decrypt */ GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv); - if (-1 == GNUNET_CRYPTO_aes_decrypt (&nb[1], - size - sizeof (struct NBlock), - &skey, &iv, pt)) + if (-1 == + GNUNET_CRYPTO_aes_decrypt (&nb[1], size - sizeof (struct NBlock), &skey, + &iv, pt)) { GNUNET_break (0); return; @@ -654,11 +647,9 @@ process_nblock (struct GNUNET_FS_SearchContext *sc, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &uri->data.sks.namespace); uris = GNUNET_FS_uri_to_string (uri); - GNUNET_CONTAINER_meta_data_insert (meta, - "", - EXTRACTOR_METATYPE_URI, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", uris, strlen (uris) + 1); + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_URI, + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + uris, strlen (uris) + 1); GNUNET_free (uris); GNUNET_PSEUDONYM_add (sc->h->cfg, &uri->data.sks.namespace, meta); /* process */ @@ -678,8 +669,8 @@ process_nblock (struct GNUNET_FS_SearchContext *sc, * @param size size of sb */ static void -process_sblock (struct GNUNET_FS_SearchContext *sc, - const struct SBlock *sb, size_t size) +process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb, + size_t size) { size_t len = size - sizeof (struct SBlock); char pt[len]; @@ -719,8 +710,8 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, uri = GNUNET_FS_uri_parse (uris, &emsg); if (uri == NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse URI `%s': %s\n", uris, emsg); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse URI `%s': %s\n", uris, + emsg); GNUNET_break_op (0); /* sblock malformed */ GNUNET_free_non_null (emsg); GNUNET_CONTAINER_meta_data_destroy (meta); @@ -744,10 +735,9 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, * @param size size of data */ static void -process_result (struct GNUNET_FS_SearchContext *sc, - enum GNUNET_BLOCK_Type type, - struct GNUNET_TIME_Absolute expiration, - const void *data, size_t size) +process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type, + struct GNUNET_TIME_Absolute expiration, const void *data, + size_t size) { if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0) { @@ -840,8 +830,7 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) const struct PutMessage *cm; uint16_t msize; - if ((NULL == msg) || - (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || + if ((NULL == msg) || (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || (ntohs (msg->size) <= sizeof (struct PutMessage))) { try_reconnect (sc); @@ -851,13 +840,12 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving %u bytes of result from fs service\n", msize); cm = (const struct PutMessage *) msg; - process_result (sc, - ntohl (cm->type), - GNUNET_TIME_absolute_ntoh (cm->expiration), - &cm[1], msize - sizeof (struct PutMessage)); + process_result (sc, ntohl (cm->type), + GNUNET_TIME_absolute_ntoh (cm->expiration), &cm[1], + msize - sizeof (struct PutMessage)); /* continue receiving */ - GNUNET_CLIENT_receive (sc->client, - &receive_results, sc, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (sc->client, &receive_results, sc, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -867,8 +855,8 @@ receive_results (void *cls, const struct GNUNET_MessageHeader *msg) * * @param sc context for the search */ -static void -schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc); +static void schedule_transmit_search_request (struct GNUNET_FS_SearchContext + *sc); /** @@ -1064,8 +1052,8 @@ transmit_search_request (void *cls, size_t size, void *buf) return msize; } } - GNUNET_CLIENT_receive (sc->client, - &receive_results, sc, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (sc->client, &receive_results, sc, + GNUNET_TIME_UNIT_FOREVER_REL); return msize; } @@ -1090,8 +1078,7 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) fit = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - size) / sizeof (GNUNET_HashCode); fit = GNUNET_MIN (fit, sqms); size += sizeof (GNUNET_HashCode) * fit; - GNUNET_CLIENT_notify_transmit_ready (sc->client, - size, + GNUNET_CLIENT_notify_transmit_ready (sc->client, size, GNUNET_CONSTANTS_SERVICE_TIMEOUT, GNUNET_NO, &transmit_search_request, sc); @@ -1140,9 +1127,9 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc) GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO); sc->client = NULL; } - sc->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &do_reconnect, sc); + sc->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_reconnect, + sc); } @@ -1159,10 +1146,8 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc) * @return context that can be used to control the search */ static struct GNUNET_FS_SearchContext * -search_start (struct GNUNET_FS_Handle *h, - const struct GNUNET_FS_Uri *uri, - uint32_t anonymity, - enum GNUNET_FS_SearchOptions options, +search_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, + uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx, struct GNUNET_FS_SearchResult *psearch) { struct GNUNET_FS_SearchContext *sc; @@ -1215,8 +1200,9 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) if (GNUNET_FS_uri_test_ksk (sc->uri)) { GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); - sc->requests = GNUNET_malloc (sizeof (struct SearchRequestEntry) * - sc->uri->data.ksk.keywordCount); + sc->requests = + GNUNET_malloc (sizeof (struct SearchRequestEntry) * + sc->uri->data.ksk.keywordCount); for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) { keyword = &sc->uri->data.ksk.keywords[i][1]; @@ -1253,8 +1239,8 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) * @return GNUNET_OK */ static int -search_result_freeze_probes (void *cls, - const GNUNET_HashCode * key, void *value) +search_result_freeze_probes (void *cls, const GNUNET_HashCode * key, + void *value) { struct GNUNET_FS_SearchResult *sr = value; @@ -1283,8 +1269,8 @@ search_result_freeze_probes (void *cls, * @return GNUNET_OK */ static int -search_result_resume_probes (void *cls, - const GNUNET_HashCode * key, void *value) +search_result_resume_probes (void *cls, const GNUNET_HashCode * key, + void *value) { struct GNUNET_FS_SearchResult *sr = value; @@ -1383,8 +1369,7 @@ GNUNET_FS_search_signal_suspend_ (void *cls) */ struct GNUNET_FS_SearchContext * GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, - const struct GNUNET_FS_Uri *uri, - uint32_t anonymity, + const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx) { struct GNUNET_FS_SearchContext *ret; @@ -1460,13 +1445,12 @@ search_result_free (void *cls, const GNUNET_HashCode * key, void *value) if (NULL != sr->download) { sr->download->search = NULL; - sr->download->top = GNUNET_FS_make_top (sr->download->h, - &GNUNET_FS_download_signal_suspend_, - sr->download); + sr->download->top = + GNUNET_FS_make_top (sr->download->h, + &GNUNET_FS_download_signal_suspend_, sr->download); if (NULL != sr->download->serialization) { - GNUNET_FS_remove_sync_file_ (sc->h, - GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, + GNUNET_FS_remove_sync_file_ (sc->h, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, sr->download->serialization); GNUNET_free (sr->download->serialization); sr->download->serialization = NULL; @@ -1519,14 +1503,14 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) if (sc->serialization != NULL) { GNUNET_FS_remove_sync_file_ (sc->h, - (sc->psearch_result != NULL) - ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH - : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, + (sc->psearch_result != + NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH : + GNUNET_FS_SYNC_PATH_MASTER_SEARCH, sc->serialization); GNUNET_FS_remove_sync_dir_ (sc->h, - (sc->psearch_result != NULL) - ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH - : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, + (sc->psearch_result != + NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH : + GNUNET_FS_SYNC_PATH_MASTER_SEARCH, sc->serialization); GNUNET_free (sc->serialization); } diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 334432232..17291d1bd 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -151,8 +151,8 @@ shutdown_callback (void *cls, const char *emsg) if (emsg != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Shutdown of peers failed: %s\n", emsg); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown of peers failed: %s\n", + emsg); } else { @@ -213,23 +213,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) break; case GNUNET_FS_STATUS_PUBLISH_PROGRESS: if (daemon->verbose) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Publishing at %llu/%llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Publishing at %llu/%llu bytes\n", (unsigned long long) info->value.publish.completed, (unsigned long long) info->value.publish.size); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: if (daemon->verbose) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Download at %llu/%llu bytes\n", + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n", (unsigned long long) info->value.download.completed, (unsigned long long) info->value.download.size); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: GNUNET_SCHEDULER_cancel (daemon->download_timeout_task); daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; - GNUNET_SCHEDULER_add_continuation (&report_success, - daemon, + GNUNET_SCHEDULER_add_continuation (&report_success, daemon, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: @@ -260,8 +257,7 @@ struct StartContext static void -notify_running (void *cls, - const struct GNUNET_PeerIdentity *id, +notify_running (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -270,8 +266,8 @@ notify_running (void *cls, if (emsg != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to start daemon: %s\n"), emsg); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start daemon: %s\n"), + emsg); return; } i = 0; @@ -291,19 +287,16 @@ notify_running (void *cls, sctx->have++; if (sctx->have == sctx->total) { - GNUNET_SCHEDULER_add_continuation (sctx->cont, - sctx->cont_cls, + GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); sctx->daemons[0]->gcfg = sctx->cfg; GNUNET_SCHEDULER_cancel (sctx->timeout_task); for (i = 0; i < sctx->total; i++) { - sctx->daemons[i]->fs = GNUNET_FS_start (sctx->daemons[i]->cfg, - "", - &progress_cb, - sctx->daemons[i], - GNUNET_FS_FLAGS_NONE, - GNUNET_FS_OPTIONS_END); + sctx->daemons[i]->fs = + GNUNET_FS_start (sctx->daemons[i]->cfg, "", &progress_cb, + sctx->daemons[i], GNUNET_FS_FLAGS_NONE, + GNUNET_FS_OPTIONS_END); } GNUNET_free (sctx); } @@ -330,8 +323,7 @@ start_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) sctx->daemons[i] = NULL; } GNUNET_CONFIGURATION_destroy (sctx->cfg); - GNUNET_SCHEDULER_add_continuation (sctx->cont, - sctx->cont_cls, + GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); GNUNET_free (sctx); } @@ -371,8 +363,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, GNUNET_break (0); GNUNET_CONFIGURATION_destroy (sctx->cfg); GNUNET_free (sctx); - GNUNET_SCHEDULER_add_continuation (cont, - cont_cls, + GNUNET_SCHEDULER_add_continuation (cont, cont_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); return; } @@ -380,13 +371,11 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon)); sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, total, /* Outstanding connections */ total, /* Outstanding ssh connections */ - timeout, - NULL, - NULL, - ¬ify_running, - sctx, NULL, NULL, NULL); - sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &start_timeout, sctx); + timeout, NULL, NULL, + ¬ify_running, sctx, NULL, NULL, + NULL); + sctx->timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &start_timeout, sctx); } @@ -412,10 +401,8 @@ struct ConnectContext * @param emsg error message (NULL on success) */ static void -notify_connection (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +notify_connection (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -425,13 +412,12 @@ notify_connection (void *cls, struct ConnectContext *cc = cls; if (emsg != NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to connect peers: %s\n", emsg); - GNUNET_SCHEDULER_add_continuation (cc->cont, - cc->cont_cls, - (emsg != NULL) - ? GNUNET_SCHEDULER_REASON_TIMEOUT - : GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peers: %s\n", + emsg); + GNUNET_SCHEDULER_add_continuation (cc->cont, cc->cont_cls, + (emsg != + NULL) ? GNUNET_SCHEDULER_REASON_TIMEOUT : + GNUNET_SCHEDULER_REASON_PREREQ_DONE); GNUNET_free (cc); } @@ -457,11 +443,9 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, ncc = GNUNET_malloc (sizeof (struct ConnectContext)); ncc->cont = cont; ncc->cont_cls = cont_cls; - GNUNET_TESTING_daemons_connect (daemon1->daemon, - daemon2->daemon, - timeout, - CONNECT_ATTEMPTS, - GNUNET_YES, ¬ify_connection, ncc); + GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout, + CONNECT_ATTEMPTS, GNUNET_YES, + ¬ify_connection, ncc); } @@ -610,11 +594,8 @@ file_generator (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) */ void GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, - struct GNUNET_TIME_Relative timeout, - uint32_t anonymity, - int do_index, - uint64_t size, - uint32_t seed, + struct GNUNET_TIME_Relative timeout, uint32_t anonymity, + int do_index, uint64_t size, uint32_t seed, unsigned int verbose, GNUNET_FS_TEST_UriContinuation cont, void *cont_cls) { @@ -657,29 +638,23 @@ GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, off += bsize; } GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); - fi = GNUNET_FS_file_information_create_from_file (daemon->fs, - daemon, + fi = GNUNET_FS_file_information_create_from_file (daemon->fs, daemon, daemon->publish_tmp_file, - NULL, NULL, - do_index, &bo); + NULL, NULL, do_index, + &bo); } else { - fi = GNUNET_FS_file_information_create_from_reader (daemon->fs, - daemon, - size, - &file_generator, - daemon, - NULL, - NULL, do_index, &bo); + fi = GNUNET_FS_file_information_create_from_reader (daemon->fs, daemon, + size, &file_generator, + daemon, NULL, NULL, + do_index, &bo); } - daemon->publish_context = GNUNET_FS_publish_start (daemon->fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); - daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &publish_timeout, - daemon); + daemon->publish_context = + GNUNET_FS_publish_start (daemon->fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); + daemon->publish_timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &publish_timeout, daemon); } @@ -716,10 +691,8 @@ download_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) void GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, struct GNUNET_TIME_Relative timeout, - uint32_t anonymity, - uint32_t seed, - const struct GNUNET_FS_Uri *uri, - unsigned int verbose, + uint32_t anonymity, uint32_t seed, + const struct GNUNET_FS_Uri *uri, unsigned int verbose, GNUNET_SCHEDULER_Task cont, void *cont_cls) { uint64_t size; @@ -730,18 +703,12 @@ GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, daemon->download_cont = cont; daemon->download_cont_cls = cont_cls; daemon->download_seed = seed; - daemon->download_context = GNUNET_FS_download_start (daemon->fs, - uri, - NULL, NULL, - NULL, - 0, - size, - anonymity, - GNUNET_FS_DOWNLOAD_OPTION_NONE, - NULL, NULL); - daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &download_timeout, - daemon); + daemon->download_context = + GNUNET_FS_download_start (daemon->fs, uri, NULL, NULL, NULL, 0, size, + anonymity, GNUNET_FS_DOWNLOAD_OPTION_NONE, NULL, + NULL); + daemon->download_timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &download_timeout, daemon); } /* end of test_fs_lib.c */ diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index 5584ad868..0a0db7a10 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c @@ -221,8 +221,8 @@ GNUNET_FS_tree_compute_iblock_size (unsigned int depth, uint64_t end_offset) * @return number of bytes stored in this node */ size_t -GNUNET_FS_tree_calculate_block_size (uint64_t fsize, - uint64_t offset, unsigned int depth) +GNUNET_FS_tree_calculate_block_size (uint64_t fsize, uint64_t offset, + unsigned int depth) { size_t ret; uint64_t rsize; @@ -268,10 +268,8 @@ GNUNET_FS_tree_calculate_block_size (uint64_t fsize, * @param cont function to call when done */ struct GNUNET_FS_TreeEncoder * -GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, - uint64_t size, - void *cls, - GNUNET_FS_DataReader reader, +GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size, + void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_Task cont) @@ -287,8 +285,9 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, te->progress = progress; te->cont = cont; te->chk_tree_depth = GNUNET_FS_compute_depth (size); - te->chk_tree = GNUNET_malloc (te->chk_tree_depth * - CHK_PER_INODE * sizeof (struct ContentHashKey)); + te->chk_tree = + GNUNET_malloc (te->chk_tree_depth * CHK_PER_INODE * + sizeof (struct ContentHashKey)); return te; } @@ -343,8 +342,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te) { off = CHK_PER_INODE * (te->chk_tree_depth - 1); #if DEBUG_TREE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "TE done, reading CHK `%s' from %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TE done, reading CHK `%s' from %u\n", GNUNET_h2s (&te->chk_tree[off].query), off); #endif te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); @@ -362,8 +360,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te) if (pt_size != te->reader (te->cls, te->publish_offset, pt_size, iob, &te->emsg)) { - GNUNET_SCHEDULER_add_continuation (te->cont, - te->cls, + GNUNET_SCHEDULER_add_continuation (te->cont, te->cls, GNUNET_SCHEDULER_REASON_TIMEOUT); te->in_next = GNUNET_NO; return; @@ -372,16 +369,17 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te) } else { - pt_size = GNUNET_FS_tree_compute_iblock_size (te->current_depth, - te->publish_offset); + pt_size = + GNUNET_FS_tree_compute_iblock_size (te->current_depth, + te->publish_offset); pt_block = &te->chk_tree[(te->current_depth - 1) * CHK_PER_INODE]; } off = compute_chk_offset (te->current_depth, te->publish_offset); #if DEBUG_TREE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TE is at offset %llu and depth %u with block size %u and target-CHK-offset %u\n", - (unsigned long long) te->publish_offset, - te->current_depth, (unsigned int) pt_size, (unsigned int) off); + (unsigned long long) te->publish_offset, te->current_depth, + (unsigned int) pt_size, (unsigned int) off); #endif mychk = &te->chk_tree[te->current_depth * CHK_PER_INODE + off]; GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key); @@ -395,16 +393,14 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te) te->current_depth * CHK_PER_INODE + off); #endif if (NULL != te->proc) - te->proc (te->cls, - mychk, - te->publish_offset, - te->current_depth, - (0 == te->current_depth) - ? GNUNET_BLOCK_TYPE_FS_DBLOCK - : GNUNET_BLOCK_TYPE_FS_IBLOCK, enc, pt_size); + te->proc (te->cls, mychk, te->publish_offset, te->current_depth, + (0 == + te-> + current_depth) ? GNUNET_BLOCK_TYPE_FS_DBLOCK : + GNUNET_BLOCK_TYPE_FS_IBLOCK, enc, pt_size); if (NULL != te->progress) - te->progress (te->cls, - te->publish_offset, pt_block, pt_size, te->current_depth); + te->progress (te->cls, te->publish_offset, pt_block, pt_size, + te->current_depth); if (0 == te->current_depth) { te->publish_offset += pt_size; diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 130b2eae2..a992c5ff6 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c @@ -84,8 +84,8 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, pi->value.unindex.cctx = uc->client_info; pi->value.unindex.filename = uc->filename; pi->value.unindex.size = uc->file_size; - pi->value.unindex.eta - = GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size); + pi->value.unindex.eta = + GNUNET_TIME_calculate_eta (uc->start_time, offset, uc->file_size); pi->value.unindex.duration = GNUNET_TIME_absolute_get_duration (uc->start_time); pi->value.unindex.completed = offset; @@ -105,9 +105,8 @@ GNUNET_FS_unindex_make_status_ (struct GNUNET_FS_ProgressInfo *pi, * @param depth depth of the block in the tree, 0 for DBLOCK */ static void -unindex_progress (void *cls, - uint64_t offset, - const void *pt_block, size_t pt_size, unsigned int depth) +unindex_progress (void *cls, uint64_t offset, const void *pt_block, + size_t pt_size, unsigned int depth) { struct GNUNET_FS_UnindexContext *uc = cls; struct GNUNET_FS_ProgressInfo pi; @@ -181,11 +180,8 @@ process_cont (void *cls, int success, const char *msg) * @param block_size size of block (in bytes) */ static void -unindex_process (void *cls, - const struct ContentHashKey *chk, - uint64_t offset, - unsigned int depth, - enum GNUNET_BLOCK_Type type, +unindex_process (void *cls, const struct ContentHashKey *chk, uint64_t offset, + unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size) { struct GNUNET_FS_UnindexContext *uc = cls; @@ -209,11 +205,7 @@ unindex_process (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending REMOVE request to DATASTORE service\n"); #endif - GNUNET_DATASTORE_remove (uc->dsh, - &chk->query, - size, - data, - -2, 1, + GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &process_cont, uc); } @@ -341,8 +333,9 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) signal_unindex_error (uc); return; } - uc->fh = GNUNET_DISK_file_open (uc->filename, - GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); + uc->fh = + GNUNET_DISK_file_open (uc->filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (NULL == uc->fh) { GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); @@ -353,12 +346,10 @@ GNUNET_FS_unindex_do_remove_ (struct GNUNET_FS_UnindexContext *uc) signal_unindex_error (uc); return; } - uc->tc = GNUNET_FS_tree_encoder_create (uc->h, - uc->file_size, - uc, - &unindex_reader, - &unindex_process, - &unindex_progress, &unindex_finish); + uc->tc = + GNUNET_FS_tree_encoder_create (uc->h, uc->file_size, uc, &unindex_reader, + &unindex_process, &unindex_progress, + &unindex_finish); GNUNET_FS_tree_encoder_next (uc->tc); } @@ -436,8 +427,8 @@ GNUNET_FS_unindex_signal_suspend_ (void *cls) GNUNET_FS_end_top (uc->h, uc->top); pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND; GNUNET_FS_unindex_make_status_ (&pi, uc, - (uc->state == UNINDEX_STATE_COMPLETE) - ? uc->file_size : 0); + (uc->state == + UNINDEX_STATE_COMPLETE) ? uc->file_size : 0); GNUNET_break (NULL == uc->client_info); GNUNET_free (uc->filename); GNUNET_free_non_null (uc->serialization); @@ -455,8 +446,8 @@ GNUNET_FS_unindex_signal_suspend_ (void *cls) * @return NULL on error, otherwise handle */ struct GNUNET_FS_UnindexContext * -GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, - const char *filename, void *cctx) +GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename, + void *cctx) { struct GNUNET_FS_UnindexContext *ret; struct GNUNET_FS_ProgressInfo pi; @@ -474,10 +465,10 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, pi.status = GNUNET_FS_STATUS_UNINDEX_START; pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; GNUNET_FS_unindex_make_status_ (&pi, ret, 0); - ret->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, - filename, - HASHING_BLOCKSIZE, - &GNUNET_FS_unindex_process_hash_, ret); + ret->fhc = + GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, filename, + HASHING_BLOCKSIZE, + &GNUNET_FS_unindex_process_hash_, ret); ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_unindex_signal_suspend_, ret); return ret; } @@ -529,8 +520,8 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc) pi.status = GNUNET_FS_STATUS_UNINDEX_STOPPED; pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO; GNUNET_FS_unindex_make_status_ (&pi, uc, - (uc->state == UNINDEX_STATE_COMPLETE) - ? uc->file_size : 0); + (uc->state == + UNINDEX_STATE_COMPLETE) ? uc->file_size : 0); GNUNET_break (NULL == uc->client_info); GNUNET_free (uc->filename); GNUNET_free (uc); diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 5d5d24ca8..22dab4955 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c @@ -419,15 +419,12 @@ uri_chk_parse (const char *s, char **emsg) } memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; - memcpy (h2, - &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], + memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; - if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, - &fi.chk.key)) || - (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, - &fi.chk.query)) || + if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, &fi.chk.key)) || + (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, &fi.chk.query)) || (1 != SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], "%llu", &flen))) @@ -567,15 +564,12 @@ uri_loc_parse (const char *s, char **emsg) } memcpy (h1, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); h1[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; - memcpy (h2, - &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], + memcpy (h2, &s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); h2[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0'; - if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, - &ass.fi.chk.key)) || - (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, - &ass.fi.chk.query)) || + if ((GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h1, &ass.fi.chk.key)) || + (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (h2, &ass.fi.chk.query)) || (1 != SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], "%llu", &flen))) @@ -594,9 +588,9 @@ uri_loc_parse (const char *s, char **emsg) goto ERR; } npos++; - ret = enc2bin (&s[npos], - &ass.peer, - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); + ret = + enc2bin (&s[npos], &ass.peer, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); if (ret == -1) { *emsg = @@ -769,8 +763,8 @@ GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri, * @param is_mandatory is this keyword mandatory? */ void -GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, - const char *keyword, int is_mandatory) +GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, const char *keyword, + int is_mandatory) { unsigned int i; const char *old; @@ -896,8 +890,8 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, if (baseUri->type != chk) return NULL; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "GNUNETD", "HOSTKEY", &keyfile)) + GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", + &keyfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Lacking key configuration settings.\n")); @@ -924,8 +918,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, uri->data.loc.expirationTime = expiration_time; uri->data.loc.peer = my_public_key; GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (my_private_key, - &ass.purpose, + GNUNET_CRYPTO_rsa_sign (my_private_key, &ass.purpose, &uri->data.loc.contentSignature)); GNUNET_CRYPTO_rsa_key_free (my_private_key); return uri; @@ -941,8 +934,8 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, * @return an FS URI for the given namespace and identifier */ struct GNUNET_FS_Uri * -GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, - const char *id, char **emsg) +GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id, + char **emsg) { struct GNUNET_FS_Uri *ns_uri; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; @@ -1166,8 +1159,8 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri) } if (ret->data.ksk.keywordCount > 0) { - ret->data.ksk.keywords - = GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *)); + ret->data.ksk.keywords = + GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *)); for (i = 0; i < ret->data.ksk.keywordCount; i++) ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]); } @@ -1315,8 +1308,7 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv) /* allow URI to be given as one and only keyword and * handle accordingly */ emsg = NULL; - if ((argc == 1) && - (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) && + if ((argc == 1) && (strlen (argv[0]) > strlen (GNUNET_FS_URI_PREFIX)) && (0 == strncmp (argv[0], GNUNET_FS_URI_PREFIX, strlen (GNUNET_FS_URI_PREFIX))) && (NULL != (uri = GNUNET_FS_uri_parse (argv[0], &emsg)))) @@ -1371,14 +1363,14 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, switch (u1->type) { case chk: - if (0 == memcmp (&u1->data.chk, - &u2->data.chk, sizeof (struct FileIdentifier))) + if (0 == + memcmp (&u1->data.chk, &u2->data.chk, sizeof (struct FileIdentifier))) return GNUNET_YES; return GNUNET_NO; case sks: - if ((0 == memcmp (&u1->data.sks.namespace, - &u2->data.sks.namespace, - sizeof (GNUNET_HashCode))) && + if ((0 == + memcmp (&u1->data.sks.namespace, &u2->data.sks.namespace, + sizeof (GNUNET_HashCode))) && (0 == strcmp (u1->data.sks.identifier, u2->data.sks.identifier))) return GNUNET_YES; @@ -1402,12 +1394,12 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, } return GNUNET_YES; case loc: - if (memcmp (&u1->data.loc, - &u2->data.loc, - sizeof (struct FileIdentifier) + - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + - sizeof (struct GNUNET_TIME_Absolute) + - sizeof (unsigned short) + sizeof (unsigned short)) != 0) + if (memcmp + (&u1->data.loc, &u2->data.loc, + sizeof (struct FileIdentifier) + + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + + sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) + + sizeof (unsigned short)) != 0) return GNUNET_NO; return GNUNET_YES; default: @@ -1584,10 +1576,8 @@ GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri) * @return 0 (always) */ static int -gather_uri_data (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, +gather_uri_data (void *cls, const char *plugin_name, + enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, const char *data_mime_type, const char *data, size_t data_len) { struct GNUNET_FS_Uri *uri = cls; @@ -1643,8 +1633,9 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData static int needs_percent (char c) { - return (!((isalnum ((unsigned char) c)) || - (c == '-') || (c == '_') || (c == '.') || (c == '~'))); + return (! + ((isalnum ((unsigned char) c)) || (c == '-') || (c == '_') || + (c == '.') || (c == '~'))); } @@ -1737,9 +1728,7 @@ uri_sks_to_string (const struct GNUNET_FS_Uri *uri) namespace = &uri->data.sks.namespace; identifier = uri->data.sks.identifier; GNUNET_CRYPTO_hash_to_enc (namespace, &ns); - GNUNET_asprintf (&ret, - "%s%s%s/%s", - GNUNET_FS_URI_PREFIX, + GNUNET_asprintf (&ret, "%s%s%s/%s", GNUNET_FS_URI_PREFIX, GNUNET_FS_URI_SKS_INFIX, (const char *) &ns, identifier); return ret; } @@ -1765,11 +1754,8 @@ uri_chk_to_string (const struct GNUNET_FS_Uri *uri) GNUNET_CRYPTO_hash_to_enc (&fi->chk.key, &keyhash); GNUNET_CRYPTO_hash_to_enc (&fi->chk.query, &queryhash); - GNUNET_asprintf (&ret, - "%s%s%s.%s.%llu", - GNUNET_FS_URI_PREFIX, - GNUNET_FS_URI_CHK_INFIX, - (const char *) &keyhash, + GNUNET_asprintf (&ret, "%s%s%s.%s.%llu", GNUNET_FS_URI_PREFIX, + GNUNET_FS_URI_CHK_INFIX, (const char *) &keyhash, (const char *) &queryhash, GNUNET_ntohll (fi->file_length)); return ret; } @@ -1839,18 +1825,17 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri) GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.key, &keyhash); GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash); - peerId = bin2enc (&uri->data.loc.peer, - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - peerSig = bin2enc (&uri->data.loc.contentSignature, - sizeof (struct GNUNET_CRYPTO_RsaSignature)); - GNUNET_asprintf (&ret, - "%s%s%s.%s.%llu.%s.%s.%llu", - GNUNET_FS_URI_PREFIX, - GNUNET_FS_URI_LOC_INFIX, - (const char *) &keyhash, + peerId = + bin2enc (&uri->data.loc.peer, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); + peerSig = + bin2enc (&uri->data.loc.contentSignature, + sizeof (struct GNUNET_CRYPTO_RsaSignature)); + GNUNET_asprintf (&ret, "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX, + GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash, (const char *) &queryhash, - (unsigned long long) GNUNET_ntohll (uri->data.loc. - fi.file_length), peerId, + (unsigned long long) GNUNET_ntohll (uri->data.loc.fi. + file_length), peerId, peerSig, (unsigned long long) uri->data.loc.expirationTime.abs_value); GNUNET_free (peerSig); diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c index a6fa42664..f2b99f48d 100644 --- a/src/fs/gnunet-directory.c +++ b/src/fs/gnunet-directory.c @@ -40,11 +40,9 @@ static int ret; * @return always 0 (to continue iterating) */ static int -item_printer (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, const char *data, size_t data_size) +item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, const char *data_mime_type, + const char *data, size_t data_size) { if (type == EXTRACTOR_METATYPE_GNUNET_FULL_DATA) { @@ -81,17 +79,16 @@ item_printer (void *cls, * @param data data available for the file (length bytes) */ static void -print_entry (void *cls, - const char *filename, - const struct GNUNET_FS_Uri *uri, - const struct GNUNET_CONTAINER_MetaData *meta, - size_t length, const void *data) +print_entry (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, + const struct GNUNET_CONTAINER_MetaData *meta, size_t length, + const void *data) { char *string; char *name; - name = GNUNET_CONTAINER_meta_data_get_by_type (meta, - EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); + name = + GNUNET_CONTAINER_meta_data_get_by_type (meta, + EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); if (uri == NULL) { printf (_("Directory `%s' meta data:\n"), name); @@ -119,9 +116,8 @@ print_entry (void *cls, * @param cfg configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_DISK_MapHandle *map; struct GNUNET_DISK_FileHandle *h; @@ -140,16 +136,14 @@ run (void *cls, i = 0; while (NULL != (filename = args[i++])) { - if ((GNUNET_OK != - GNUNET_DISK_file_size (filename, - &size, - GNUNET_YES)) || - (NULL == (h = GNUNET_DISK_file_open (filename, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE)))) + if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES)) || + (NULL == + (h = + GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE)))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to read directory `%s'\n"), filename); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to read directory `%s'\n"), + filename); ret = 1; continue; } @@ -177,9 +171,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-directory [OPTIONS] FILENAME", + GNUNET_PROGRAM_run (argc, argv, "gnunet-directory [OPTIONS] FILENAME", gettext_noop ("Display contents of a GNUnet directory"), options, &run, NULL)) ? ret : 1; diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index fc0b768d9..9f18cb99c 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c @@ -97,8 +97,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) { case GNUNET_FS_STATUS_DOWNLOAD_START: if (verbose > 1) - fprintf (stderr, - _("Starting download `%s'.\n"), info->value.download.filename); + fprintf (stderr, _("Starting download `%s'.\n"), + info->value.download.filename); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: if (verbose) @@ -106,8 +106,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta); t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000LL / - (info->value.download. - duration.rel_value + 1)); + (info->value.download.duration. + rel_value + 1)); fprintf (stdout, _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"), info->value.download.filename, @@ -118,15 +118,14 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) } break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: - fprintf (stderr, - _("Error downloading: %s.\n"), + fprintf (stderr, _("Error downloading: %s.\n"), info->value.download.specifics.error.message); GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 / - (info->value.download. - duration.rel_value + 1)); + (info->value.download.duration. + rel_value + 1)); fprintf (stdout, _("Downloading `%s' done (%s/s).\n"), info->value.download.filename, s); GNUNET_free (s); @@ -135,8 +134,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: if (info->value.download.dc == dc) - GNUNET_SCHEDULER_add_continuation (&cleanup_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: @@ -159,9 +157,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_FS_Uri *uri; char *emsg; @@ -195,15 +192,12 @@ run (void *cls, return; } cfg = c; - ctx = GNUNET_FS_start (cfg, - "gnunet-download", - &progress_cb, - NULL, - GNUNET_FS_FLAGS_NONE, - GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, - parallelism, - GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, - request_parallelism, GNUNET_FS_OPTIONS_END); + ctx = + GNUNET_FS_start (cfg, "gnunet-download", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, + GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, parallelism, + GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, + request_parallelism, GNUNET_FS_OPTIONS_END); if (NULL == ctx) { fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); @@ -216,11 +210,7 @@ run (void *cls, options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; if (local_only) options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY; - dc = GNUNET_FS_download_start (ctx, - uri, - NULL, - filename, NULL, - 0, + dc = GNUNET_FS_download_start (ctx, uri, NULL, filename, NULL, 0, GNUNET_FS_uri_chk_get_file_size (uri), anonymity, options, NULL, NULL); GNUNET_FS_uri_destroy (uri); @@ -230,8 +220,8 @@ run (void *cls, ctx = NULL; return; } - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); } @@ -275,9 +265,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-download [OPTIONS] URI", + GNUNET_PROGRAM_run (argc, argv, "gnunet-download [OPTIONS] URI", gettext_noop ("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"), options, &run, NULL)) ? ret : 1; diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c index 742111c4e..ce0d24506 100644 --- a/src/fs/gnunet-pseudonym.c +++ b/src/fs/gnunet-pseudonym.c @@ -105,9 +105,7 @@ ns_printer (void *cls, const char *name, const GNUNET_HashCode * id) static int -pseudo_printer (void *cls, - const GNUNET_HashCode * - pseudonym, +pseudo_printer (void *cls, const GNUNET_HashCode * pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating) { char *id; @@ -150,8 +148,8 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) set++; if (*set != ':') { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid argument `%s'\n"), rating_change); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid argument `%s'\n"), + rating_change); } else { @@ -164,8 +162,8 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) } else { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Namespace `%s' unknown.\n"), rating_change); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namespace `%s' unknown.\n"), + rating_change); } } GNUNET_free (rating_change); @@ -192,17 +190,14 @@ post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { char *emsg; cfg = c; - h = GNUNET_FS_start (cfg, - "gnunet-pseudonym", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + h = GNUNET_FS_start (cfg, "gnunet-pseudonym", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); if (NULL != delete_ns) { ns = GNUNET_FS_namespace_create (h, delete_ns); @@ -234,13 +229,9 @@ run (void *cls, ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); GNUNET_assert (NULL == emsg); } - GNUNET_FS_namespace_advertise (h, - ksk_uri, - ns, - adv_metadata, - &bo, - root_identifier, - &post_advertising, NULL); + GNUNET_FS_namespace_advertise (h, ksk_uri, ns, adv_metadata, &bo, + root_identifier, &post_advertising, + NULL); return; } else @@ -284,9 +275,8 @@ main (int argc, char *const *argv) gettext_noop ("delete namespace NAME "), 1, &GNUNET_GETOPT_set_string, &delete_ns}, {'k', "keyword", "VALUE", - gettext_noop - ("add an additional keyword for the advertisment" - " (this option can be specified multiple times)"), + gettext_noop ("add an additional keyword for the advertisment" + " (this option can be specified multiple times)"), 1, &GNUNET_FS_getopt_set_keywords, &ksk_uri}, {'m', "meta", "TYPE:VALUE", gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 326fed3c6..a67886f7d 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -112,8 +112,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) if (verbose) { s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta); - fprintf (stdout, - _("Publishing `%s' at %llu/%llu (%s remaining)\n"), + fprintf (stdout, _("Publishing `%s' at %llu/%llu (%s remaining)\n"), info->value.publish.filename, (unsigned long long) info->value.publish.completed, (unsigned long long) info->value.publish.size, s); @@ -121,23 +120,21 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) } break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - _("Error publishing: %s.\n"), + fprintf (stderr, _("Error publishing: %s.\n"), info->value.publish.specifics.error.message); if (kill_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (kill_task); kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (&do_stop_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&do_stop_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: - fprintf (stdout, - _("Publishing `%s' done.\n"), info->value.publish.filename); - s = GNUNET_FS_uri_to_string (info->value.publish.specifics. - completed.chk_uri); + fprintf (stdout, _("Publishing `%s' done.\n"), + info->value.publish.filename); + s = GNUNET_FS_uri_to_string (info->value.publish.specifics.completed. + chk_uri); fprintf (stdout, _("URI is `%s'.\n"), s); GNUNET_free (s); if (info->value.publish.pctx == NULL) @@ -147,8 +144,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) GNUNET_SCHEDULER_cancel (kill_task); kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_SCHEDULER_add_continuation (&do_stop_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&do_stop_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } break; @@ -177,11 +173,9 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) * @return always 0 */ static int -meta_printer (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, const char *data, size_t data_size) +meta_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, const char *data_mime_type, + const char *data, size_t data_size) { if ((format != EXTRACTOR_METAFORMAT_UTF8) && (format != EXTRACTOR_METAFORMAT_C_STRING)) @@ -228,13 +222,11 @@ keyword_printer (void *cls, const char *keyword, int is_mandatory) * to abort the iteration */ static int -publish_inspector (void *cls, - struct GNUNET_FS_FileInformation *fi, - uint64_t length, - struct GNUNET_CONTAINER_MetaData *m, +publish_inspector (void *cls, struct GNUNET_FS_FileInformation *fi, + uint64_t length, struct GNUNET_CONTAINER_MetaData *m, struct GNUNET_FS_Uri **uri, - struct GNUNET_FS_BlockOptions *bo, - int *do_index, void **client_info) + struct GNUNET_FS_BlockOptions *bo, int *do_index, + void **client_info) { char *fn; char *fs; @@ -286,8 +278,8 @@ publish_inspector (void *cls, static void -uri_sks_continuation (void *cls, - const struct GNUNET_FS_Uri *ksk_uri, const char *emsg) +uri_sks_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri, + const char *emsg) { if (emsg != NULL) { @@ -302,8 +294,8 @@ uri_sks_continuation (void *cls, static void -uri_ksk_continuation (void *cls, - const struct GNUNET_FS_Uri *ksk_uri, const char *emsg) +uri_ksk_continuation (void *cls, const struct GNUNET_FS_Uri *ksk_uri, + const char *emsg) { struct GNUNET_FS_Namespace *ns; @@ -322,13 +314,7 @@ uri_ksk_continuation (void *cls, } else { - GNUNET_FS_publish_sks (ctx, - ns, - this_id, - next_id, - meta, - uri, - &bo, + GNUNET_FS_publish_sks (ctx, ns, this_id, next_id, meta, uri, &bo, GNUNET_FS_PUBLISH_OPTION_NONE, uri_sks_continuation, NULL); GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_NO)); @@ -351,9 +337,8 @@ uri_ksk_continuation (void *cls, * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_FS_FileInformation *fi; struct GNUNET_FS_Namespace *namespace; @@ -370,8 +355,8 @@ run (void *cls, ret = -1; return; } - if (((uri_string == NULL) || (extract_only)) - && ((args[0] == NULL) || (args[1] != NULL))) + if (((uri_string == NULL) || (extract_only)) && + ((args[0] == NULL) || (args[1] != NULL))) { printf (_("You must specify one and only one filename for insertion.\n")); ret = -1; @@ -387,8 +372,7 @@ run (void *cls, { if (NULL == this_id) { - fprintf (stderr, - _("Option `%s' is required when using option `%s'.\n"), + fprintf (stderr, _("Option `%s' is required when using option `%s'.\n"), "-t", "-P"); ret = -1; return; @@ -398,26 +382,23 @@ run (void *cls, { /* ordinary insertion checks */ if (NULL != next_id) { - fprintf (stderr, - _("Option `%s' makes no sense without option `%s'.\n"), + fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"), "-N", "-P"); ret = -1; return; } if (NULL != this_id) { - fprintf (stderr, - _("Option `%s' makes no sense without option `%s'.\n"), + fprintf (stderr, _("Option `%s' makes no sense without option `%s'.\n"), "-t", "-P"); ret = -1; return; } } cfg = c; - ctx = GNUNET_FS_start (cfg, - "gnunet-publish", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + ctx = + GNUNET_FS_start (cfg, "gnunet-publish", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); if (NULL == ctx) { fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); @@ -450,13 +431,9 @@ run (void *cls, ret = 1; return; } - GNUNET_FS_publish_ksk (ctx, - topKeywords, - meta, - uri, - &bo, - GNUNET_FS_PUBLISH_OPTION_NONE, - &uri_ksk_continuation, NULL); + GNUNET_FS_publish_ksk (ctx, topKeywords, meta, uri, &bo, + GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation, + NULL); if (namespace != NULL) GNUNET_FS_namespace_delete (namespace, GNUNET_NO); return; @@ -484,12 +461,9 @@ run (void *cls, } else if (S_ISDIR (sbuf.st_mode)) { - fi = GNUNET_FS_file_information_create_from_directory (ctx, - NULL, - args[0], + fi = GNUNET_FS_file_information_create_from_directory (ctx, NULL, args[0], &GNUNET_FS_directory_scanner_default, - plugins, - !do_insert, + plugins, !do_insert, &bo, &emsg); } else @@ -498,11 +472,9 @@ run (void *cls, meta = GNUNET_CONTAINER_meta_data_create (); GNUNET_FS_meta_data_extract_from_file (meta, args[0], plugins); keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); - fi = GNUNET_FS_file_information_create_from_file (ctx, - NULL, - args[0], - keywords, - NULL, !do_insert, &bo); + fi = GNUNET_FS_file_information_create_from_file (ctx, NULL, args[0], + keywords, NULL, + !do_insert, &bo); GNUNET_break (fi != NULL); GNUNET_FS_uri_destroy (keywords); } @@ -526,14 +498,10 @@ run (void *cls, GNUNET_FS_stop (ctx); return; } - pc = GNUNET_FS_publish_start (ctx, - fi, - namespace, - this_id, - next_id, - (do_simulate) - ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY - : GNUNET_FS_PUBLISH_OPTION_NONE); + pc = GNUNET_FS_publish_start (ctx, fi, namespace, this_id, next_id, + (do_simulate) ? + GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY : + GNUNET_FS_PUBLISH_OPTION_NONE); if (NULL == pc) { fprintf (stderr, _("Could not start publishing.\n")); @@ -541,8 +509,9 @@ run (void *cls, ret = 1; return; } - kill_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &do_stop_task, NULL); + kill_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task, + NULL); } diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index 8a3e2ed6a..c82a0794c 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c @@ -70,11 +70,9 @@ static int local_only; * @return 0 to continue extracting, 1 to abort */ static int -item_printer (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, const char *data, size_t data_size) +item_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, const char *data_mime_type, + const char *data, size_t data_size) { if ((format != EXTRACTOR_METAFORMAT_UTF8) && (format != EXTRACTOR_METAFORMAT_C_STRING)) @@ -105,9 +103,7 @@ clean_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } if (dsize != - GNUNET_DISK_fn_write (output_filename, - ddata, - dsize, + GNUNET_DISK_fn_write (output_filename, ddata, dsize, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) { @@ -154,8 +150,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri); printf ("#%u:\n", cnt++); filename = - GNUNET_CONTAINER_meta_data_get_by_type (info->value.search. - specifics.result.meta, + GNUNET_CONTAINER_meta_data_get_by_type (info->value.search.specifics. + result.meta, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); if (filename != NULL) { @@ -166,8 +162,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) else printf ("gnunet-download %s\n", uri); if (verbose) - GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics. - result.meta, &item_printer, NULL); + GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics.result. + meta, &item_printer, NULL); printf ("\n"); fflush (stdout); GNUNET_free_non_null (filename); @@ -182,14 +178,12 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) /* ignore */ break; case GNUNET_FS_STATUS_SEARCH_ERROR: - fprintf (stderr, - _("Error searching: %s.\n"), + fprintf (stderr, _("Error searching: %s.\n"), info->value.search.specifics.error.message); GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_SEARCH_STOPPED: - GNUNET_SCHEDULER_add_continuation (&clean_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&clean_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -220,9 +214,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_FS_Uri *uri; unsigned int argc; @@ -240,10 +233,9 @@ run (void *cls, return; } cfg = c; - ctx = GNUNET_FS_start (cfg, - "gnunet-search", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + ctx = + GNUNET_FS_start (cfg, "gnunet-search", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); if (NULL == ctx) { fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); @@ -272,8 +264,8 @@ run (void *cls, } else { - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); } } @@ -311,9 +303,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-search [OPTIONS] KEYWORD", + GNUNET_PROGRAM_run (argc, argv, "gnunet-search [OPTIONS] KEYWORD", gettext_noop ("Search GNUnet for files that were published on GNUnet"), options, &run, NULL)) ? ret : 1; diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 4d12b8bfd..0457607d5 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -166,8 +166,9 @@ age_cover_counters (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; - cover_age_task = GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, - &age_cover_counters, NULL); + cover_age_task = + GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters, + NULL); } @@ -223,8 +224,7 @@ GSF_test_get_load_too_high_ (uint32_t priority) * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_p2p_put (void *cls, - const struct GNUNET_PeerIdentity *other, +handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -273,8 +273,7 @@ consider_request_for_forwarding (void *cls, * @param result final datastore lookup result */ static void -consider_forwarding (void *cls, - struct GSF_PendingRequest *pr, +consider_forwarding (void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result) { if (GNUNET_BLOCK_EVALUATION_OK_LAST == result) @@ -295,8 +294,7 @@ consider_forwarding (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_p2p_get (void *cls, - const struct GNUNET_PeerIdentity *other, +handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -321,8 +319,7 @@ handle_p2p_get (void *cls, * @param result final datastore lookup result */ static void -start_p2p_processing (void *cls, - struct GSF_PendingRequest *pr, +start_p2p_processing (void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result) { struct GNUNET_SERVER_Client *client = cls; @@ -355,8 +352,7 @@ start_p2p_processing (void *cls, * @param message the actual message */ static void -handle_start_search (void *cls, - struct GNUNET_SERVER_Client *client, +handle_start_search (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GSF_PendingRequest *pr; @@ -424,8 +420,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return GNUNET_YES to continue to iterate */ static int -consider_peer_for_forwarding (void *cls, - const GNUNET_HashCode * key, +consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key, struct GSF_PendingRequest *pr) { struct GSF_ConnectedPeer *cp = cls; @@ -443,8 +438,7 @@ consider_peer_for_forwarding (void *cls, * @param atsi performance information */ static void -peer_connect_handler (void *cls, - const struct GNUNET_PeerIdentity *peer, +peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct GSF_ConnectedPeer *cp; @@ -471,11 +465,10 @@ peer_connect_handler (void *cls, * @param publicKey public key of this peer, NULL if we failed */ static void -peer_init_handler (void *cls, - struct GNUNET_CORE_Handle *server, +peer_init_handler (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, - const struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) + const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded + *publicKey) { my_id = *my_identity; } @@ -515,12 +508,10 @@ main_init (struct GNUNET_SERVER_Handle *server, }; GSF_core = GNUNET_CORE_connect (GSF_cfg, 2, /* larger? */ - NULL, - &peer_init_handler, + NULL, &peer_init_handler, &peer_connect_handler, &GSF_peer_disconnect_handler_, - &GSF_peer_status_handler_, - NULL, GNUNET_NO, + &GSF_peer_status_handler_, NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers); if (NULL == GSF_core) { @@ -528,14 +519,15 @@ main_init (struct GNUNET_SERVER_Handle *server, _("Failed to connect to `%s' service.\n"), "core"); return GNUNET_SYSERR; } - GNUNET_SERVER_disconnect_notify (server, - &GSF_client_disconnect_handler_, NULL); + GNUNET_SERVER_disconnect_notify (server, &GSF_client_disconnect_handler_, + NULL); GNUNET_SERVER_add_handlers (server, handlers); - cover_age_task = GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, - &age_cover_counters, NULL); + cover_age_task = + GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters, + NULL); datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); return GNUNET_OK; } @@ -548,8 +540,7 @@ main_init (struct GNUNET_SERVER_Handle *server, * @param cfg configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { GSF_cfg = cfg; @@ -594,10 +585,8 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "fs", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, argv, "fs", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } /* end of gnunet-service-fs.c */ diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 4e57455b2..1e93a475e 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -400,13 +400,12 @@ static size_t peer_transmit_ready_cb (void *cls, size_t size, void *buf); * long should the client wait until re-trying? * @param preference current traffic preference for the given peer */ -static void -core_reserve_callback (void *cls, - const struct GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - int32_t amount, - struct GNUNET_TIME_Relative res_delay, - uint64_t preference); +static void core_reserve_callback (void *cls, + const struct GNUNET_PeerIdentity *peer, + struct GNUNET_BANDWIDTH_Value32NBO + bandwidth_out, int32_t amount, + struct GNUNET_TIME_Relative res_delay, + uint64_t preference); /** @@ -437,23 +436,20 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth) pth->was_reserved = GNUNET_YES; ip = cp->inc_preference; cp->inc_preference = 0; - cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, - &target, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BANDWIDTH_VALUE_MAX, - DBLOCK_SIZE, - ip, - &core_reserve_callback, cp); + cp->irc = + GNUNET_CORE_peer_change_preference (GSF_core, &target, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BANDWIDTH_VALUE_MAX, + DBLOCK_SIZE, ip, + &core_reserve_callback, cp); } GNUNET_assert (pth->cth == NULL); pth->cth_in_progress++; - pth->cth = GNUNET_CORE_notify_transmit_ready (GSF_core, - GNUNET_YES, - pth->priority, - GNUNET_TIME_absolute_get_remaining - (pth->timeout), &target, - pth->size, - &peer_transmit_ready_cb, pth); + pth->cth = + GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority, + GNUNET_TIME_absolute_get_remaining + (pth->timeout), &target, pth->size, + &peer_transmit_ready_cb, pth); GNUNET_assert (0 < pth->cth_in_progress--); } @@ -495,8 +491,9 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf) GNUNET_assert (0 < cp->ppd.pending_replies--); } GNUNET_LOAD_update (cp->ppd.transmission_delay, - GNUNET_TIME_absolute_get_duration - (pth->transmission_request_start_time).rel_value); + GNUNET_TIME_absolute_get_duration (pth-> + transmission_request_start_time). + rel_value); ret = pth->gmc (pth->gmc_cls, size, buf); GNUNET_assert (NULL == pth->cth); for (pos = cp->pth_head; pos != NULL; pos = pos->next) @@ -528,12 +525,12 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cp->irc_delay_task = GNUNET_SCHEDULER_NO_TASK; ip = cp->inc_preference; cp->inc_preference = 0; - cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, - &target, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BANDWIDTH_VALUE_MAX, - DBLOCK_SIZE, - ip, &core_reserve_callback, cp); + cp->irc = + GNUNET_CORE_peer_change_preference (GSF_core, &target, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BANDWIDTH_VALUE_MAX, + DBLOCK_SIZE, ip, + &core_reserve_callback, cp); } @@ -550,11 +547,9 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param preference current traffic preference for the given peer */ static void -core_reserve_callback (void *cls, - const struct GNUNET_PeerIdentity *peer, +core_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - int32_t amount, - struct GNUNET_TIME_Relative res_delay, + int32_t amount, struct GNUNET_TIME_Relative res_delay, uint64_t preference) { struct GSF_ConnectedPeer *cp = cls; @@ -563,8 +558,8 @@ core_reserve_callback (void *cls, cp->irc = NULL; if (0 == amount) { - cp->irc_delay_task = GNUNET_SCHEDULER_add_delayed (res_delay, - &retry_reservation, cp); + cp->irc_delay_task = + GNUNET_SCHEDULER_add_delayed (res_delay, &retry_reservation, cp); return; } cp->did_reserve = GNUNET_YES; @@ -573,13 +568,11 @@ core_reserve_callback (void *cls, { /* reservation success, try transmission now! */ pth->cth_in_progress++; - pth->cth = GNUNET_CORE_notify_transmit_ready (GSF_core, - GNUNET_YES, - pth->priority, - GNUNET_TIME_absolute_get_remaining - (pth->timeout), peer, - pth->size, - &peer_transmit_ready_cb, pth); + pth->cth = + GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority, + GNUNET_TIME_absolute_get_remaining + (pth->timeout), peer, pth->size, + &peer_transmit_ready_cb, pth); GNUNET_assert (0 < pth->cth_in_progress--); } } @@ -604,12 +597,12 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); cp->ppd.pid = GNUNET_PEER_intern (peer); cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); - cp->irc = GNUNET_CORE_peer_change_preference (GSF_core, - peer, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BANDWIDTH_VALUE_MAX, - DBLOCK_SIZE, - 0, &core_reserve_callback, cp); + cp->irc = + GNUNET_CORE_peer_change_preference (GSF_core, peer, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BANDWIDTH_VALUE_MAX, + DBLOCK_SIZE, 0, + &core_reserve_callback, cp); fn = get_trust_filename (peer); if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) @@ -617,8 +610,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, GNUNET_free (fn); cp->request_map = GNUNET_CONTAINER_multihashmap_create (128); GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (cp_map, - &peer->hashPubKey, + GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey, cp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); update_atsi (cp, atsi); @@ -645,8 +637,8 @@ revive_migration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (0 != bt.rel_value) { /* still time left... */ - cp->mig_revive_task - = GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); + cp->mig_revive_task = + GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); return; } GSF_push_start_ (cp); @@ -705,8 +697,8 @@ GSF_handle_p2p_migration_stop_ (void *cls, if (cp->mig_revive_task == GNUNET_SCHEDULER_NO_TASK) { GSF_push_stop_ (cp); - cp->mig_revive_task - = GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); + cp->mig_revive_task = + GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); } update_atsi (cp, atsi); return GNUNET_OK; @@ -740,8 +732,8 @@ copy_reply (void *cls, size_t buf_size, void *buf) else { size = 0; - GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# replies dropped"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# replies dropped"), 1, + GNUNET_NO); } GNUNET_free (pm); return size; @@ -769,8 +761,7 @@ cancel_pending_request (void *cls, const GNUNET_HashCode * query, void *value) GNUNET_SCHEDULER_cancel (peerreq->kill_task); peerreq->kill_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# P2P searches active"), + GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"), -1, GNUNET_NO); prd = GSF_pending_request_get_data_ (pr); GNUNET_break (GNUNET_YES == @@ -820,9 +811,8 @@ transmit_delayed_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (dh); return; } - (void) GSF_peer_transmit_ (cp, GNUNET_NO, - UINT32_MAX, - REPLY_TIMEOUT, dh->msize, ©_reply, dh->pm); + (void) GSF_peer_transmit_ (cp, GNUNET_NO, UINT32_MAX, REPLY_TIMEOUT, + dh->msize, ©_reply, dh->pm); GNUNET_free (dh); } @@ -838,9 +828,10 @@ get_randomized_delay () struct GNUNET_TIME_Relative ret; /* FIXME: replace 5000 with something relating to current observed P2P message latency */ - ret = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, 5000)); + ret = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, + GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, 5000)); GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# artificial delays introduced (ms)"), @@ -868,13 +859,11 @@ get_randomized_delay () * @param data_len number of bytes in data */ static void -handle_p2p_reply (void *cls, - enum GNUNET_BLOCK_EvaluationResult eval, - struct GSF_PendingRequest *pr, - uint32_t reply_anonymity_level, +handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval, + struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, - enum GNUNET_BLOCK_Type type, - const void *data, size_t data_len) + enum GNUNET_BLOCK_Type type, const void *data, + size_t data_len) { struct PeerRequest *peerreq = cls; struct GSF_ConnectedPeer *cp = peerreq->cp; @@ -888,8 +877,7 @@ handle_p2p_reply (void *cls, prd = GSF_pending_request_get_data_ (pr); if (NULL == data) { - GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# P2P searches active"), + GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"), -1, GNUNET_NO); GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (cp->request_map, @@ -936,8 +924,7 @@ handle_p2p_reply (void *cls, pm->type = htonl (type); pm->expiration = GNUNET_TIME_absolute_hton (expiration); memcpy (&pm[1], data, data_len); - if ((reply_anonymity_level != UINT32_MAX) && - (reply_anonymity_level != 0) && + if ((reply_anonymity_level != UINT32_MAX) && (reply_anonymity_level != 0) && (GSF_enable_randomized_delays == GNUNET_YES)) { struct GSF_DelayedHandle *dh; @@ -947,14 +934,14 @@ handle_p2p_reply (void *cls, dh->pm = pm; dh->msize = msize; GNUNET_CONTAINER_DLL_insert (cp->delayed_head, cp->delayed_tail, dh); - dh->delay_task = GNUNET_SCHEDULER_add_delayed (get_randomized_delay (), - &transmit_delayed_now, dh); + dh->delay_task = + GNUNET_SCHEDULER_add_delayed (get_randomized_delay (), + &transmit_delayed_now, dh); } else { - (void) GSF_peer_transmit_ (cp, GNUNET_NO, - UINT32_MAX, - REPLY_TIMEOUT, msize, ©_reply, pm); + (void) GSF_peer_transmit_ (cp, GNUNET_NO, UINT32_MAX, REPLY_TIMEOUT, msize, + ©_reply, pm); } if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST) return; @@ -1220,8 +1207,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received request for `%s' of type %u from peer `%4s' with flags %u\n", - GNUNET_h2s (&gm->query), - (unsigned int) type, GNUNET_i2s (other), (unsigned int) bm); + GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other), + (unsigned int) bm); #endif namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL; if ((type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && (namespace == NULL)) @@ -1254,8 +1241,9 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, } ttl = bound_ttl (ntohl (gm->ttl), priority); /* decrement ttl (always) */ - ttl_decrement = 2 * TTL_DECREMENT + - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, TTL_DECREMENT); + ttl_decrement = + 2 * TTL_DECREMENT + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + TTL_DECREMENT); if ((ttl < 0) && (((int32_t) (ttl - ttl_decrement)) > 0)) { #if DEBUG_FS @@ -1299,8 +1287,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, } /* existing request has lower TTL, drop old one! */ GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# P2P searches active"), - -1, GNUNET_NO); + gettext_noop ("# P2P searches active"), -1, + GNUNET_NO); priority += prd->priority; GSF_pending_request_cancel_ (pr, GNUNET_YES); GNUNET_assert (GNUNET_YES == @@ -1318,10 +1306,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, peerreq = GNUNET_malloc (sizeof (struct PeerRequest)); peerreq->cp = cp; - pr = GSF_pending_request_create_ (options, - type, - &gm->query, - namespace, + pr = GSF_pending_request_create_ (options, type, &gm->query, namespace, target, (bfsize > 0) ? (const char *) &opt[bits] : NULL, @@ -1332,8 +1317,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, GNUNET_assert (NULL != pr); peerreq->pr = pr; GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (cp->request_map, - &gm->query, + GNUNET_CONTAINER_multihashmap_put (cp->request_map, &gm->query, peerreq, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); GNUNET_STATISTICS_update (GSF_stats, @@ -1397,10 +1381,8 @@ peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return handle to cancel request */ struct GSF_PeerTransmitHandle * -GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, - int is_query, - uint32_t priority, - struct GNUNET_TIME_Relative timeout, +GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, + uint32_t priority, struct GNUNET_TIME_Relative timeout, size_t size, GSF_GetMessageCallback gmc, void *gmc_cls) { struct GSF_PeerTransmitHandle *pth; @@ -1432,9 +1414,8 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, cp->ppd.pending_queries++; else if (GNUNET_NO == is_query) cp->ppd.pending_replies++; - pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &peer_transmit_timeout, - pth); + pth->timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &peer_transmit_timeout, pth); schedule_transmission (pth); return pth; } @@ -1544,8 +1525,7 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, * @param atsi status information */ void -GSF_peer_status_handler_ (void *cls, - const struct GNUNET_PeerIdentity *peer, +GSF_peer_status_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_TIME_Absolute timeout, @@ -1752,27 +1732,24 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, #if DEBUG_FS && 0 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Migration already blocked for another %llu ms\n", - (unsigned long long) - GNUNET_TIME_absolute_get_remaining - (cp->last_migration_block).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_remaining (cp-> + last_migration_block). + rel_value); #endif return; /* already blocked */ } #if DEBUG_FS && 0 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asking to stop migration for %llu ms\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %llu ms\n", (unsigned long long) block_time.rel_value); #endif cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time); if (cp->migration_pth != NULL) GSF_peer_transmit_cancel_ (cp->migration_pth); - cp->migration_pth - = GSF_peer_transmit_ (cp, - GNUNET_SYSERR, - UINT32_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, - sizeof (struct MigrationStopMessage), - &create_migration_stop_message, cp); + cp->migration_pth = + GSF_peer_transmit_ (cp, GNUNET_SYSERR, UINT32_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + sizeof (struct MigrationStopMessage), + &create_migration_stop_message, cp); } @@ -1806,12 +1783,12 @@ flush_trust (void *cls, const GNUNET_HashCode * key, void *value) else { trust = htonl (cp->ppd.trust); - if (sizeof (uint32_t) == GNUNET_DISK_fn_write (fn, &trust, - sizeof (uint32_t), - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE | - GNUNET_DISK_PERM_GROUP_READ | - GNUNET_DISK_PERM_OTHER_READ)) + if (sizeof (uint32_t) == + GNUNET_DISK_fn_write (fn, &trust, sizeof (uint32_t), + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE | + GNUNET_DISK_PERM_GROUP_READ | + GNUNET_DISK_PERM_OTHER_READ)) cp->disk_trust = cp->ppd.trust; } GNUNET_free (fn); @@ -1865,8 +1842,7 @@ GSF_connected_peer_init_ () { cp_map = GNUNET_CONTAINER_multihashmap_create (128); GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, - "fs", + GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", "TRUST", &trustDirectory)); GNUNET_DISK_directory_create (trustDirectory); @@ -1939,8 +1915,8 @@ GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc) { if (NULL == cp_map) return; /* already cleaned up */ - GNUNET_CONTAINER_multihashmap_iterate (cp_map, - &clean_local_client, (void *) lc); + GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_local_client, + (void *) lc); } diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 4bf02adb0..c7bff3a9d 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c @@ -126,9 +126,7 @@ write_index_list () while (pos != NULL) { if ((GNUNET_OK != - GNUNET_BIO_write (wh, - &pos->file_id, - sizeof (GNUNET_HashCode))) || + GNUNET_BIO_write (wh, &pos->file_id, sizeof (GNUNET_HashCode))) || (GNUNET_OK != GNUNET_BIO_write_string (wh, pos->filename))) break; pos = pos->next; @@ -181,14 +179,11 @@ read_index_list () return; } while ((GNUNET_OK == - GNUNET_BIO_read (rh, - "Hash of indexed file", - &hc, + GNUNET_BIO_read (rh, "Hash of indexed file", &hc, sizeof (GNUNET_HashCode))) && (GNUNET_OK == - GNUNET_BIO_read_string (rh, - "Name of indexed file", - &fname, 1024 * 16)) && (fname != NULL)) + GNUNET_BIO_read_string (rh, "Name of indexed file", &fname, + 1024 * 16)) && (fname != NULL)) { slen = strlen (fname) + 1; pos = GNUNET_malloc (sizeof (struct IndexInfo) + slen); @@ -196,9 +191,7 @@ read_index_list () pos->filename = (const char *) &pos[1]; memcpy (&pos[1], fname, slen); if (GNUNET_SYSERR == - GNUNET_CONTAINER_multihashmap_put (ifm, - &hc, - (void *) pos->filename, + GNUNET_CONTAINER_multihashmap_put (ifm, &hc, (void *) pos->filename, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) { GNUNET_free (pos); @@ -226,8 +219,7 @@ static void signal_index_ok (struct IndexInfo *ii) { if (GNUNET_SYSERR == - GNUNET_CONTAINER_multihashmap_put (ifm, - &ii->file_id, + GNUNET_CONTAINER_multihashmap_put (ifm, &ii->file_id, (void *) ii->filename, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) { @@ -236,7 +228,8 @@ signal_index_ok (struct IndexInfo *ii) ("Index request received for file `%s' is already indexed as `%s'. Permitting anyway.\n"), ii->filename, (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, - &ii->file_id)); + &ii-> + file_id)); GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0, GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK); GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES); @@ -246,8 +239,7 @@ signal_index_ok (struct IndexInfo *ii) ii->next = indexed_files; indexed_files = ii; write_index_list (); - GNUNET_SERVER_transmit_context_append_data (ii->tc, - NULL, 0, + GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0, GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK); GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES); ii->tc = NULL; @@ -275,11 +267,10 @@ hash_for_index_val (void *cls, const GNUNET_HashCode * res) ("Hash mismatch trying to index file `%s' which has hash `%s'\n"), ii->filename, GNUNET_h2s (res)); #if DEBUG_FS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Wanted `%s'\n", GNUNET_h2s (&ii->file_id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Wanted `%s'\n", + GNUNET_h2s (&ii->file_id)); #endif - GNUNET_SERVER_transmit_context_append_data (ii->tc, - NULL, 0, + GNUNET_SERVER_transmit_context_append_data (ii->tc, NULL, 0, GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED); GNUNET_SERVER_transmit_context_run (ii->tc, GNUNET_TIME_UNIT_MINUTES); GNUNET_free (ii); @@ -297,8 +288,7 @@ hash_for_index_val (void *cls, const GNUNET_HashCode * res) * @param message the actual message */ void -GNUNET_FS_handle_index_start (void *cls, - struct GNUNET_SERVER_Client *client, +GNUNET_FS_handle_index_start (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct IndexStartMessage *ism; @@ -341,19 +331,15 @@ GNUNET_FS_handle_index_start (void *cls, memcpy (&ii[1], fn, slen); ii->file_id = ism->file_id; #if DEBUG_FS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' message for file `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for file `%s'\n", "START_INDEX", ii->filename); #endif ii->tc = GNUNET_SERVER_transmit_context_create (client); mydev = 0; myino = 0; - if (((dev != 0) || - (ino != 0)) && - (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn, - &mydev, - &myino)) && + if (((dev != 0) || (ino != 0)) && + (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn, &mydev, &myino)) && ((dev == mydev) && (ino == myino))) { /* fast validation OK! */ @@ -364,15 +350,13 @@ GNUNET_FS_handle_index_start (void *cls, #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n", - (unsigned long long) ino, - (unsigned long long) myino, + (unsigned long long) ino, (unsigned long long) myino, (unsigned int) dev, (unsigned int) mydev); #endif /* slow validation, need to hash full file (again) */ - ii->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, - fn, - HASHING_BLOCKSIZE, - &hash_for_index_val, ii); + ii->fhc = + GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, fn, + HASHING_BLOCKSIZE, &hash_for_index_val, ii); if (ii->fhc == NULL) hash_for_index_val (ii, NULL); GNUNET_free (fn); @@ -387,8 +371,7 @@ GNUNET_FS_handle_index_start (void *cls, * @param message the actual message */ void -GNUNET_FS_handle_index_list_get (void *cls, - struct GNUNET_SERVER_Client *client, +GNUNET_FS_handle_index_list_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_SERVER_TransmitContext *tc; @@ -419,8 +402,7 @@ GNUNET_FS_handle_index_list_get (void *cls, GNUNET_SERVER_transmit_context_append_message (tc, &iim->header); pos = pos->next; } - GNUNET_SERVER_transmit_context_append_data (tc, - NULL, 0, + GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_END); GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES); } @@ -434,8 +416,7 @@ GNUNET_FS_handle_index_list_get (void *cls, * @param message the actual message */ void -GNUNET_FS_handle_unindex (void *cls, - struct GNUNET_SERVER_Client *client, +GNUNET_FS_handle_unindex (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct UnindexMessage *um; @@ -465,10 +446,9 @@ GNUNET_FS_handle_unindex (void *cls, else prev->next = next; GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_remove (ifm, - &pos->file_id, - (void *) - pos->filename)); + GNUNET_CONTAINER_multihashmap_remove (ifm, &pos->file_id, + (void *) pos-> + filename)); GNUNET_free (pos); found = GNUNET_YES; } @@ -486,8 +466,7 @@ GNUNET_FS_handle_unindex (void *cls, if (GNUNET_YES == found) write_index_list (); tc = GNUNET_SERVER_transmit_context_create (client); - GNUNET_SERVER_transmit_context_append_data (tc, - NULL, 0, + GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK); GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_MINUTES); } @@ -530,14 +509,11 @@ remove_cont (void *cls, int success, const char *msg) * @return GNUNET_OK on success */ int -GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, - uint32_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, - struct GNUNET_TIME_Absolute - expiration, uint64_t uid, +GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, uint32_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, + struct GNUNET_TIME_Absolute expiration, + uint64_t uid, GNUNET_DATASTORE_DatumProcessor cont, void *cont_cls) { @@ -556,11 +532,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, if (size != sizeof (struct OnDemandBlock)) { GNUNET_break (0); - GNUNET_DATASTORE_remove (dsh, - key, - size, - data, - -1, -1, + GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); return GNUNET_SYSERR; } @@ -569,13 +541,11 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id); fh = NULL; if ((NULL == fn) || - (NULL == (fh = GNUNET_DISK_file_open (fn, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE))) || - (off != - GNUNET_DISK_file_seek (fh, - off, - GNUNET_DISK_SEEK_SET)) || + (NULL == + (fh = + GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE))) || + (off != GNUNET_DISK_file_seek (fh, off, GNUNET_DISK_SEEK_SET)) || (-1 == (nsize = GNUNET_DISK_file_read (fh, ndata, sizeof (ndata))))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -585,11 +555,7 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, (fn == NULL) ? _("not indexed") : STRERROR (errno)); if (fh != NULL) GNUNET_DISK_file_close (fh); - GNUNET_DATASTORE_remove (dsh, - key, - size, - data, - -1, -1, + GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); return GNUNET_SYSERR; } @@ -601,13 +567,9 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, if (0 != memcmp (&query, key, sizeof (GNUNET_HashCode))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Indexed file `%s' changed at offset %llu\n"), - fn, (unsigned long long) off); - GNUNET_DATASTORE_remove (dsh, - key, - size, - data, - -1, -1, + _("Indexed file `%s' changed at offset %llu\n"), fn, + (unsigned long long) off); + GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); return GNUNET_SYSERR; } @@ -615,11 +577,8 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "On-demand encoded block for query `%s'\n", GNUNET_h2s (key)); #endif - cont (cont_cls, - key, - nsize, - edata, - GNUNET_BLOCK_TYPE_FS_DBLOCK, priority, anonymity, expiration, uid); + cont (cont_cls, key, nsize, edata, GNUNET_BLOCK_TYPE_FS_DBLOCK, priority, + anonymity, expiration, uid); return GNUNET_OK; } diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index aa6569387..6460d4f13 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c @@ -199,8 +199,8 @@ client_request_destroy (void *cls, GNUNET_CONTAINER_DLL_remove (lc->cr_head, lc->cr_tail, cr); GSF_pending_request_cancel_ (cr->pr, GNUNET_NO); GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# client searches active"), - -1, GNUNET_NO); + gettext_noop ("# client searches active"), -1, + GNUNET_NO); GNUNET_free (cr); } @@ -223,13 +223,12 @@ client_request_destroy (void *cls, * @param data_len number of bytes in data */ static void -client_response_handler (void *cls, - enum GNUNET_BLOCK_EvaluationResult eval, +client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval, struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, - enum GNUNET_BLOCK_Type type, - const void *data, size_t data_len) + enum GNUNET_BLOCK_Type type, const void *data, + size_t data_len) { struct ClientRequest *cr = cls; struct GSF_LocalClient *lc; @@ -310,8 +309,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, return NULL; } GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# client searches received"), - 1, GNUNET_NO); + gettext_noop ("# client searches received"), 1, + GNUNET_NO); sc = (msize - sizeof (struct SearchMessage)) / sizeof (GNUNET_HashCode); sm = (const struct SearchMessage *) message; type = ntohl (sm->type); @@ -334,9 +333,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, while (cr != NULL) { prd = GSF_pending_request_get_data_ (cr->pr); - if ((0 != memcmp (&prd->query, - &sm->query, - sizeof (GNUNET_HashCode))) && (prd->type == type)) + if ((0 != memcmp (&prd->query, &sm->query, sizeof (GNUNET_HashCode))) && + (prd->type == type)) break; cr = cr->next; } @@ -346,8 +344,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have existing request, merging content-seen lists.\n"); #endif - GSF_pending_request_update_ (cr->pr, - (const GNUNET_HashCode *) &sm[1], sc); + GSF_pending_request_update_ (cr->pr, (const GNUNET_HashCode *) &sm[1], + sc); GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# client searches updated (merged content seen list)"), @@ -358,8 +356,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, } GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# client searches active"), - 1, GNUNET_NO); + gettext_noop ("# client searches active"), 1, + GNUNET_NO); cr = GNUNET_malloc (sizeof (struct ClientRequest)); cr->lc = lc; GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr); @@ -368,9 +366,9 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, options |= GSF_PRO_LOCAL_ONLY; cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */ : NULL, - (0 != memcmp (&sm->target, - &all_zeros, - sizeof (GNUNET_HashCode))) + (0 != + memcmp (&sm->target, &all_zeros, + sizeof (GNUNET_HashCode))) ? (const struct GNUNET_PeerIdentity *) &sm->target : NULL, NULL, 0, 0 /* bf */ , @@ -418,10 +416,10 @@ transmit_to_client (void *cls, size_t size, void *buf) GNUNET_free (res); } if (NULL != res) - lc->th = GNUNET_SERVER_notify_transmit_ready (lc->client, - res->msize, - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_client, lc); + lc->th = + GNUNET_SERVER_notify_transmit_ready (lc->client, res->msize, + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_client, lc); return msize; } @@ -448,10 +446,10 @@ GSF_local_client_transmit_ (struct GSF_LocalClient *lc, memcpy (&res[1], msg, msize); GNUNET_CONTAINER_DLL_insert_tail (lc->res_head, lc->res_tail, res); if (NULL == lc->th) - lc->th = GNUNET_SERVER_notify_transmit_ready (lc->client, - msize, - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_client, lc); + lc->th = + GNUNET_SERVER_notify_transmit_ready (lc->client, msize, + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_client, lc); } @@ -479,8 +477,8 @@ GSF_client_disconnect_handler_ (void *cls, struct GNUNET_SERVER_Client *client) GNUNET_CONTAINER_DLL_remove (pos->cr_head, pos->cr_tail, cr); GSF_pending_request_cancel_ (cr->pr, GNUNET_NO); GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# client searches active"), - -1, GNUNET_NO); + gettext_noop ("# client searches active"), -1, + GNUNET_NO); if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task) GNUNET_SCHEDULER_cancel (cr->kill_task); GNUNET_free (cr); diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index d3ab5026b..58fb11cee 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -207,9 +207,9 @@ static unsigned long long plan_count; * @param cls the 'struct GSF_ConnectedPeer' for transmission * @param tc scheduler context */ -static void -schedule_peer_transmission (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void schedule_peer_transmission (void *cls, + const struct + GNUNET_SCHEDULER_TaskContext *tc); /** @@ -230,8 +230,9 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) prd = GSF_pending_request_get_data_ (rp->prl_head->pr); // FIXME: calculate 'rp->priority'! if (rp->transmission_counter < 32) - delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - 1LL << rp->transmission_counter); + delay = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + 1LL << rp->transmission_counter); else delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX); rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); @@ -242,13 +243,13 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) #endif GNUNET_assert (rp->hn == NULL); - if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value - == 0) + if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission). + rel_value == 0) rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); else - rp->hn = GNUNET_CONTAINER_heap_insert (pp->delay_heap, - rp, - rp->earliest_transmission.abs_value); + rp->hn = + GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp, + rp->earliest_transmission.abs_value); if (GNUNET_SCHEDULER_NO_TASK != pp->task) GNUNET_SCHEDULER_cancel (pp->task); pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); @@ -358,8 +359,8 @@ schedule_peer_transmission (void *cls, } /* move ready requests to priority queue */ while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && - (GNUNET_TIME_absolute_get_remaining - (rp->earliest_transmission).rel_value == 0)) + (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission). + rel_value == 0)) { GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)); rp->hn = GNUNET_CONTAINER_heap_insert (pp->priority_heap, rp, rp->priority); @@ -371,17 +372,17 @@ schedule_peer_transmission (void *cls, if (NULL == rp) { #if DEBUG_FS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "No active requests for plan %p.\n", pp); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No active requests for plan %p.\n", + pp); #endif return; /* both queues empty */ } #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sleeping for %llu ms before retrying requests on plan %p.\n", - (unsigned long long) - GNUNET_TIME_absolute_get_remaining - (rp->earliest_transmission).rel_value, pp); + (unsigned long long) GNUNET_TIME_absolute_get_remaining (rp-> + earliest_transmission). + rel_value, pp); #endif pp->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining @@ -396,11 +397,10 @@ schedule_peer_transmission (void *cls, #endif GNUNET_assert (NULL != rp); msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL); - pp->pth = GSF_peer_transmit_ (pp->cp, - GNUNET_YES, - rp->priority, - GNUNET_TIME_UNIT_FOREVER_REL, - msize, &transmit_message_callback, pp); + pp->pth = + GSF_peer_transmit_ (pp->cp, GNUNET_YES, rp->priority, + GNUNET_TIME_UNIT_FOREVER_REL, msize, + &transmit_message_callback, pp); GNUNET_assert (NULL != pp->pth); } @@ -430,9 +430,8 @@ struct MergeContext * GNUNET_NO if not (merge success) */ static int -merge_pr (void *cls, - struct GNUNET_CONTAINER_HeapNode *node, - void *element, GNUNET_CONTAINER_HeapCostType cost) +merge_pr (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, + GNUNET_CONTAINER_HeapCostType cost) { struct MergeContext *mpr = cls; struct GSF_RequestPlan *rp = element; @@ -455,14 +454,13 @@ merge_pr (void *cls, GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr); GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); mpr->merged = GNUNET_YES; - GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# requests merged"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests merged"), 1, + GNUNET_NO); latest = get_latest (rp); if (GSF_pending_request_get_data_ (latest)->ttl.abs_value < prd->ttl.abs_value) { - GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# requests refreshed"), + GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests refreshed"), 1, GNUNET_NO); rp->transmission_counter = 0; /* reset */ } @@ -498,9 +496,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) pp->delay_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); pp->cp = cp; - GNUNET_CONTAINER_multihashmap_put (plans, - &id.hashPubKey, - pp, + GNUNET_CONTAINER_multihashmap_put (plans, &id.hashPubKey, pp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } mpc.merged = GNUNET_NO; @@ -512,9 +508,8 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) if (mpc.merged != GNUNET_NO) return; plan_count++; - GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# query plan entries"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plan entries"), 1, + GNUNET_NO); prd = GSF_pending_request_get_data_ (pr); #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -554,8 +549,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) if (NULL == pp) return; /* nothing was ever planned for this peer */ GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (plans, - &id.hashPubKey, pp)); + GNUNET_CONTAINER_multihashmap_remove (plans, &id.hashPubKey, + pp)); if (NULL != pp->pth) GSF_peer_transmit_cancel_ (pp->pth); if (GNUNET_SCHEDULER_NO_TASK != pp->task) @@ -588,8 +583,7 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) } GNUNET_free (rp); } - GNUNET_STATISTICS_set (GSF_stats, - gettext_noop ("# query plan entries"), + GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# query plan entries"), plan_count, GNUNET_NO); GNUNET_CONTAINER_heap_destroy (pp->delay_heap); @@ -625,8 +619,7 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr) GNUNET_free (rp); } } - GNUNET_STATISTICS_set (GSF_stats, - gettext_noop ("# query plan entries"), + GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# query plan entries"), plan_count, GNUNET_NO); } diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index e637be664..7b6290bbb 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -241,8 +241,8 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr) return GNUNET_NO; /* size not changed */ if (pr->bf != NULL) GNUNET_CONTAINER_bloomfilter_free (pr->bf); - pr->mingle = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX); + pr->mingle = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); pr->bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize, BLOOMFILTER_K); for (i = 0; i < pr->replies_seen_count; i++) { @@ -280,12 +280,9 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, const GNUNET_HashCode * query, const GNUNET_HashCode * namespace, const struct GNUNET_PeerIdentity *target, - const char *bf_data, - size_t bf_size, - uint32_t mingle, - uint32_t anonymity_level, - uint32_t priority, - int32_t ttl, + const char *bf_data, size_t bf_size, + uint32_t mingle, uint32_t anonymity_level, + uint32_t priority, int32_t ttl, GNUNET_PEER_Id sender_pid, const GNUNET_HashCode * replies_seen, unsigned int replies_seen_count, @@ -300,8 +297,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, GNUNET_h2s (query), type); #endif GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Pending requests created"), - 1, GNUNET_NO); + gettext_noop ("# Pending requests created"), 1, + GNUNET_NO); pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest)); pr->local_result_offset = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); @@ -348,8 +345,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, } if (NULL != bf_data) { - pr->bf = GNUNET_CONTAINER_bloomfilter_init (bf_data, - bf_size, BLOOMFILTER_K); + pr->bf = + GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, BLOOMFILTER_K); pr->mingle = mingle; } else if ((replies_seen_count > 0) && @@ -357,15 +354,13 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, { GNUNET_assert (GNUNET_YES == refresh_bloomfilter (pr)); } - GNUNET_CONTAINER_multihashmap_put (pr_map, - query, - pr, + GNUNET_CONTAINER_multihashmap_put (pr_map, query, pr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); if (0 != (options & GSF_PRO_REQUEST_EXPIRES)) { - pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, - pr, - pr->public_data.ttl.abs_value); + pr->hnode = + GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr, + pr->public_data.ttl.abs_value); /* make sure we don't track too many requests */ while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) > max_pending_requests) @@ -374,17 +369,15 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, GNUNET_assert (dpr != NULL); if (pr == dpr) break; /* let the request live briefly... */ - dpr->rh (dpr->rh_cls, - GNUNET_BLOCK_EVALUATION_REQUEST_VALID, - dpr, - UINT32_MAX, - GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_BLOCK_TYPE_ANY, NULL, 0); + dpr->rh (dpr->rh_cls, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, dpr, + UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_BLOCK_TYPE_ANY, + NULL, 0); GSF_pending_request_cancel_ (dpr, GNUNET_YES); } } GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Pending requests active"), - 1, GNUNET_NO); + gettext_noop ("# Pending requests active"), 1, + GNUNET_NO); return pr; } @@ -416,12 +409,13 @@ GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra, struct GSF_PendingRequest *prb) { if ((pra->public_data.type != prb->public_data.type) || - (0 != memcmp (&pra->public_data.query, - &prb->public_data.query, - sizeof (GNUNET_HashCode))) || + (0 != + memcmp (&pra->public_data.query, &prb->public_data.query, + sizeof (GNUNET_HashCode))) || ((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && - (0 != memcmp (&pra->public_data.namespace, - &prb->public_data.namespace, sizeof (GNUNET_HashCode))))) + (0 != + memcmp (&pra->public_data.namespace, &prb->public_data.namespace, + sizeof (GNUNET_HashCode))))) return GNUNET_NO; return GNUNET_OK; } @@ -450,11 +444,10 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr, { /* we're responsible for the BF, full refresh */ if (replies_seen_count + pr->replies_seen_count > pr->replies_seen_size) - GNUNET_array_grow (pr->replies_seen, - pr->replies_seen_size, + GNUNET_array_grow (pr->replies_seen, pr->replies_seen_size, replies_seen_count + pr->replies_seen_count); - memcpy (&pr->replies_seen[pr->replies_seen_count], - replies_seen, sizeof (GNUNET_HashCode) * replies_seen_count); + memcpy (&pr->replies_seen[pr->replies_seen_count], replies_seen, + sizeof (GNUNET_HashCode) * replies_seen_count); pr->replies_seen_count += replies_seen_count; if (GNUNET_NO == refresh_bloomfilter (pr)) { @@ -472,12 +465,13 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr, { /* we're not the initiator, but the initiator did not give us * any bloom-filter, so we need to create one on-the-fly */ - pr->mingle = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT32_MAX); - pr->bf = GNUNET_CONTAINER_bloomfilter_init (NULL, - compute_bloomfilter_size - (replies_seen_count), - BLOOMFILTER_K); + pr->mingle = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); + pr->bf = + GNUNET_CONTAINER_bloomfilter_init (NULL, + compute_bloomfilter_size + (replies_seen_count), + BLOOMFILTER_K); } for (i = 0; i < pr->replies_seen_count; i++) { @@ -552,8 +546,9 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr, gm->header.size = htons (msize); gm->type = htonl (pr->public_data.type); if (do_route) - prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - pr->public_data.priority + 1); + prio = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + pr->public_data.priority + 1); else prio = 0; pr->public_data.priority -= prio; @@ -640,8 +635,8 @@ clean_request (void *cls, const GNUNET_HashCode * key, void *value) &pr->public_data.query, pr)); GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Pending requests active"), - -1, GNUNET_NO); + gettext_noop ("# Pending requests active"), -1, + GNUNET_NO); GNUNET_free (pr); return GNUNET_YES; } @@ -776,8 +771,8 @@ update_request_performance_data (struct ProcessReplyClosure *prq, { if (prq->sender == NULL) return; - GSF_peer_update_performance_ (prq->sender, - pr->public_data.start_time, prq->priority); + GSF_peer_update_performance_ (prq->sender, pr->public_data.start_time, + prq->priority); } @@ -804,18 +799,15 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) (unsigned int) prq->type, GNUNET_h2s (key)); #endif GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# replies received and matched"), - 1, GNUNET_NO); - prq->eval = GNUNET_BLOCK_evaluate (GSF_block_ctx, - prq->type, - key, - &pr->bf, - pr->mingle, - &pr->public_data.namespace, - (prq->type == - GNUNET_BLOCK_TYPE_FS_SBLOCK) ? - sizeof (GNUNET_HashCode) : 0, prq->data, - prq->size); + gettext_noop ("# replies received and matched"), 1, + GNUNET_NO); + prq->eval = + GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle, + &pr->public_data.namespace, + (prq->type == + GNUNET_BLOCK_TYPE_FS_SBLOCK) ? + sizeof (GNUNET_HashCode) : 0, prq->data, + prq->size); switch (prq->eval) { case GNUNET_BLOCK_EVALUATION_OK_MORE: @@ -825,14 +817,12 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) /* short cut: stop processing early, no BF-update, etc. */ update_request_performance_data (prq, pr); GNUNET_LOAD_update (GSF_rt_entry_lifetime, - GNUNET_TIME_absolute_get_duration (pr-> - public_data.start_time).rel_value); + GNUNET_TIME_absolute_get_duration (pr->public_data. + start_time). + rel_value); /* pass on to other peers / local clients */ - pr->rh (pr->rh_cls, - prq->eval, - pr, - prq->anonymity_level, - prq->expiration, prq->type, prq->data, prq->size); + pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration, + prq->type, prq->data, prq->size); return GNUNET_YES; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: GNUNET_STATISTICS_update (GSF_stats, @@ -853,8 +843,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_break (0); return GNUNET_YES; case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Unsupported block type %u\n"), prq->type); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Unsupported block type %u\n"), + prq->type); return GNUNET_NO; } /* update bloomfilter */ @@ -868,8 +858,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_h2s (key)); #endif GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# results found locally"), - 1, GNUNET_NO); + gettext_noop ("# results found locally"), 1, + GNUNET_NO); } else { @@ -881,11 +871,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value) pr->public_data.results_found++; prq->request_found = GNUNET_YES; /* finally, pass on to other peer / local client */ - pr->rh (pr->rh_cls, - prq->eval, - pr, - prq->anonymity_level, - prq->expiration, prq->type, prq->data, prq->size); + pr->rh (pr->rh_cls, prq->eval, pr, prq->anonymity_level, prq->expiration, + prq->type, prq->data, prq->size); return GNUNET_YES; } @@ -940,12 +927,11 @@ put_migration_continuation (void *cls, int success, const char *msg) { ppd = GSF_get_peer_performance_data_ (cp); ppd->migration_duplication++; - block_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, - 5 * - ppd->migration_duplication + - GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, - 5)); + block_time = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, + 5 * ppd->migration_duplication + + GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, 5)); GSF_block_peer_migration_ (cp, block_time); } } @@ -964,8 +950,8 @@ put_migration_continuation (void *cls, int success, const char *msg) if (GNUNET_OK == success) return; GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Datastore `PUT' failures"), - 1, GNUNET_NO); + gettext_noop ("# Datastore `PUT' failures"), 1, + GNUNET_NO); } @@ -1013,8 +999,7 @@ test_put_load_too_high (uint32_t priority) * @param data pointer to the result data */ static void -handle_dht_reply (void *cls, - struct GNUNET_TIME_Absolute exp, +handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, @@ -1025,8 +1010,8 @@ handle_dht_reply (void *cls, struct PutMigrationContext *pmc; GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Replies received from DHT"), - 1, GNUNET_NO); + gettext_noop ("# Replies received from DHT"), 1, + GNUNET_NO); memset (&prq, 0, sizeof (prq)); prq.data = data; prq.expiration = exp; @@ -1045,12 +1030,10 @@ handle_dht_reply (void *cls, pmc->start = GNUNET_TIME_absolute_get (); pmc->requested = GNUNET_YES; if (NULL == - GNUNET_DATASTORE_put (GSF_dsh, - 0, key, size, data, - type, prq.priority, 1 /* anonymity */ , + GNUNET_DATASTORE_put (GSF_dsh, 0, key, size, data, type, prq.priority, + 1 /* anonymity */ , 0 /* replication */ , - exp, - 1 + prq.priority, MAX_DATASTORE_QUEUE, + exp, 1 + prq.priority, MAX_DATASTORE_QUEUE, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &put_migration_continuation, pmc)) { @@ -1095,15 +1078,13 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr) memcpy (&buf[xquery_size], &pi, sizeof (struct GNUNET_PeerIdentity)); xquery_size += sizeof (struct GNUNET_PeerIdentity); } - pr->gh = GNUNET_DHT_get_start (GSF_dht, - GNUNET_TIME_UNIT_FOREVER_REL, - pr->public_data.type, - &pr->public_data.query, - DEFAULT_GET_REPLICATION, - GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, - pr->bf, - pr->mingle, - xquery, xquery_size, &handle_dht_reply, pr); + pr->gh = + GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL, + pr->public_data.type, &pr->public_data.query, + DEFAULT_GET_REPLICATION, + GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, pr->bf, + pr->mingle, xquery, xquery_size, &handle_dht_reply, + pr); } @@ -1120,8 +1101,9 @@ warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Datastore lookup already took %llu ms!\n"), - (unsigned long long) - GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_duration (pr-> + qe_start). + rel_value); pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task, pr); @@ -1141,8 +1123,9 @@ odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("On-demand lookup already took %llu ms!\n"), - (unsigned long long) - GNUNET_TIME_absolute_get_duration (pr->qe_start).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_duration (pr-> + qe_start). + rel_value); pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &odc_warn_delay_task, pr); @@ -1167,13 +1150,9 @@ odc_warn_delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * maybe 0 if no unique identifier is available */ static void -process_local_reply (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct GSF_PendingRequest *pr = cls; @@ -1250,8 +1229,9 @@ process_local_reply (void *cls, ("# on-demand blocks matched requests"), 1, GNUNET_NO); pr->qe_start = GNUNET_TIME_absolute_get (); - pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &odc_warn_delay_task, pr); + pr->warn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &odc_warn_delay_task, pr); if (GNUNET_OK == GNUNET_FS_handle_on_demand_block (key, size, data, type, priority, anonymity, expiration, uid, @@ -1264,30 +1244,28 @@ process_local_reply (void *cls, return; /* we're done */ } GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# on-demand lookups failed"), - 1, GNUNET_NO); + gettext_noop ("# on-demand lookups failed"), 1, + GNUNET_NO); GNUNET_SCHEDULER_cancel (pr->warn_task); - pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &warn_delay_task, pr); - pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, - pr->local_result_offset - 1, - &pr->public_data.query, - pr->public_data.type == - GNUNET_BLOCK_TYPE_FS_DBLOCK ? - GNUNET_BLOCK_TYPE_ANY : pr-> - public_data.type, - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data. - options)) ? UINT_MAX : 1 - /* queue priority */ , - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data.options)) ? UINT_MAX : - 1 - /* max queue size */ , - GNUNET_TIME_UNIT_FOREVER_REL, - &process_local_reply, pr); + pr->warn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &warn_delay_task, pr); + pr->qe = + GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1, + &pr->public_data.query, + pr->public_data.type == + GNUNET_BLOCK_TYPE_FS_DBLOCK ? + GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr-> + public_data.options)) ? UINT_MAX : 1 + /* queue priority */ , + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr-> + public_data.options)) ? UINT_MAX : 1 + /* max queue size */ , + GNUNET_TIME_UNIT_FOREVER_REL, + &process_local_reply, pr); if (NULL != pr->qe) { GNUNET_STATISTICS_update (GSF_stats, @@ -1307,32 +1285,28 @@ process_local_reply (void *cls, GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query)) { GNUNET_break (0); - GNUNET_DATASTORE_remove (GSF_dsh, - key, - size, data, - -1, -1, GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL); + GNUNET_DATASTORE_remove (GSF_dsh, key, size, data, -1, -1, + GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL); pr->qe_start = GNUNET_TIME_absolute_get (); - pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &warn_delay_task, pr); - pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, - pr->local_result_offset - 1, - &pr->public_data.query, - pr->public_data.type == - GNUNET_BLOCK_TYPE_FS_DBLOCK ? - GNUNET_BLOCK_TYPE_ANY : pr-> - public_data.type, - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data. - options)) ? UINT_MAX : 1 - /* queue priority */ , - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data.options)) ? UINT_MAX : - 1 - /* max queue size */ , - GNUNET_TIME_UNIT_FOREVER_REL, - &process_local_reply, pr); + pr->warn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &warn_delay_task, pr); + pr->qe = + GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1, + &pr->public_data.query, + pr->public_data.type == + GNUNET_BLOCK_TYPE_FS_DBLOCK ? + GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr-> + public_data.options)) ? UINT_MAX : 1 + /* queue priority */ , + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr-> + public_data.options)) ? UINT_MAX : 1 + /* max queue size */ , + GNUNET_TIME_UNIT_FOREVER_REL, + &process_local_reply, pr); if (pr->qe == NULL) { GNUNET_STATISTICS_update (GSF_stats, @@ -1373,25 +1347,25 @@ process_local_reply (void *cls, goto check_error_and_continue; } pr->qe_start = GNUNET_TIME_absolute_get (); - pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &warn_delay_task, pr); - pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, - pr->local_result_offset++, - &pr->public_data.query, - pr->public_data.type == - GNUNET_BLOCK_TYPE_FS_DBLOCK ? - GNUNET_BLOCK_TYPE_ANY : pr-> - public_data.type, - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data.options)) ? UINT_MAX : 1 - /* queue priority */ , - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data.options)) ? UINT_MAX : 1 - /* max queue size */ , - GNUNET_TIME_UNIT_FOREVER_REL, - &process_local_reply, pr); + pr->warn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task, + pr); + pr->qe = + GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++, + &pr->public_data.query, + pr->public_data.type == + GNUNET_BLOCK_TYPE_FS_DBLOCK ? + GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data. + options)) ? UINT_MAX : 1 + /* queue priority */ , + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data. + options)) ? UINT_MAX : 1 + /* max queue size */ , + GNUNET_TIME_UNIT_FOREVER_REL, + &process_local_reply, pr); /* check if we successfully queued another datastore request; * if so, return, otherwise call our continuation (if we have * any) */ @@ -1426,28 +1400,28 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr, pr->llc_cont = cont; pr->llc_cont_cls = cont_cls; pr->qe_start = GNUNET_TIME_absolute_get (); - pr->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &warn_delay_task, pr); + pr->warn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &warn_delay_task, + pr); GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# Datastore lookups initiated"), - 1, GNUNET_NO); - pr->qe = GNUNET_DATASTORE_get_key (GSF_dsh, - pr->local_result_offset++, - &pr->public_data.query, - pr->public_data.type == - GNUNET_BLOCK_TYPE_FS_DBLOCK ? - GNUNET_BLOCK_TYPE_ANY : pr-> - public_data.type, - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data.options)) ? UINT_MAX : 1 - /* queue priority */ , - (0 != - (GSF_PRO_PRIORITY_UNLIMITED & - pr->public_data.options)) ? UINT_MAX : 1 - /* max queue size */ , - GNUNET_TIME_UNIT_FOREVER_REL, - &process_local_reply, pr); + gettext_noop ("# Datastore lookups initiated"), 1, + GNUNET_NO); + pr->qe = + GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++, + &pr->public_data.query, + pr->public_data.type == + GNUNET_BLOCK_TYPE_FS_DBLOCK ? + GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data. + options)) ? UINT_MAX : 1 + /* queue priority */ , + (0 != + (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data. + options)) ? UINT_MAX : 1 + /* max queue size */ , + GNUNET_TIME_UNIT_FOREVER_REL, + &process_local_reply, pr); if (NULL != pr->qe) { GNUNET_STATISTICS_update (GSF_stats, @@ -1513,8 +1487,8 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, return GNUNET_SYSERR; } GNUNET_STATISTICS_update (GSF_stats, - gettext_noop ("# GAP PUT messages received"), - 1, GNUNET_NO); + gettext_noop ("# GAP PUT messages received"), 1, + GNUNET_NO); /* now, lookup 'query' */ prq.data = (const void *) &put[1]; if (NULL != cp) @@ -1527,8 +1501,8 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, prq.priority = 0; prq.anonymity_level = UINT32_MAX; prq.request_found = GNUNET_NO; - GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, - &query, &process_reply, &prq); + GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, &query, &process_reply, + &prq); if (NULL != cp) { GSF_connected_peer_change_preference_ (cp, @@ -1551,12 +1525,10 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, GNUNET_PEER_resolve (GSF_get_peer_performance_data_ (cp)->pid, &pmc->origin); if (NULL == - GNUNET_DATASTORE_put (GSF_dsh, - 0, &query, dsize, &put[1], - type, prq.priority, 1 /* anonymity */ , + GNUNET_DATASTORE_put (GSF_dsh, 0, &query, dsize, &put[1], type, + prq.priority, 1 /* anonymity */ , 0 /* replication */ , - expiration, - 1 + prq.priority, MAX_DATASTORE_QUEUE, + expiration, 1 + prq.priority, MAX_DATASTORE_QUEUE, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &put_migration_continuation, pmc)) { @@ -1568,24 +1540,23 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Choosing not to keep content `%s' (%d/%d)\n", - GNUNET_h2s (&query), - active_to_migration, test_put_load_too_high (prq.priority)); + GNUNET_h2s (&query), active_to_migration, + test_put_load_too_high (prq.priority)); #endif } putl = GNUNET_LOAD_get_load (datastore_put_load); - if ((NULL != (cp = prq.sender)) && - (GNUNET_NO == prq.request_found) && + if ((NULL != (cp = prq.sender)) && (GNUNET_NO == prq.request_found) && ((GNUNET_YES != active_to_migration) || (putl > 2.5 * (1 + prq.priority)))) { if (GNUNET_YES != active_to_migration) putl = 1.0 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 5); - block_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, - 5000 + - GNUNET_CRYPTO_random_u32 - (GNUNET_CRYPTO_QUALITY_WEAK, - (unsigned int) (60000 * putl * - putl))); + block_time = + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, + 5000 + + GNUNET_CRYPTO_random_u32 + (GNUNET_CRYPTO_QUALITY_WEAK, + (unsigned int) (60000 * putl * putl))); GSF_block_peer_migration_ (cp, block_time); } return GNUNET_OK; @@ -1599,8 +1570,7 @@ void GSF_pending_request_init_ () { if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (GSF_cfg, - "fs", + GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "fs", "MAX_PENDING_REQUESTS", &max_pending_requests)) { @@ -1609,9 +1579,8 @@ GSF_pending_request_init_ () ("Configuration fails to specify `%s', assuming default value."), "MAX_PENDING_REQUESTS"); } - active_to_migration = GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, - "FS", - "CONTENT_CACHING"); + active_to_migration = + GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING"); datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); pr_map = GNUNET_CONTAINER_multihashmap_create (32 * 1024); requests_by_expiration_heap = diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c index 108fce5fc..6d8c05999 100644 --- a/src/fs/gnunet-service-fs_push.c +++ b/src/fs/gnunet-service-fs_push.c @@ -227,8 +227,8 @@ transmit_message (void *cls, size_t buf_size, void *buf) memcpy (buf, msg, msize); GNUNET_free (msg); #if DEBUG_FS_MIGRATION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Pushing %u bytes to another peer\n", msize); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pushing %u bytes to another peer\n", + msize); #endif find_content (peer); return msize; @@ -285,8 +285,8 @@ transmit_content (struct MigrationReadyPeer *peer, "Asking for transmission of %u bytes for migration\n", msize); #endif peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */ , - GNUNET_TIME_UNIT_FOREVER_REL, - msize, &transmit_message, peer); + GNUNET_TIME_UNIT_FOREVER_REL, msize, + &transmit_message, peer); return ret; } @@ -421,9 +421,9 @@ find_content (struct MigrationReadyPeer *mrp) * @param cls unused * @param tc scheduler context (also unused) */ -static void -gather_migration_blocks (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void gather_migration_blocks (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** @@ -450,8 +450,8 @@ consider_gathering () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling gathering task (queue size: %u)\n", mig_size); #endif - mig_task = GNUNET_SCHEDULER_add_delayed (delay, - &gather_migration_blocks, NULL); + mig_task = + GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL); } @@ -470,13 +470,9 @@ consider_gathering () * maybe 0 if no unique identifier is available */ static void -process_migration_content (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +process_migration_content (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct MigrationReadyBlock *mb; @@ -501,9 +497,8 @@ process_migration_content (void *cls, if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND) { if (GNUNET_OK != - GNUNET_FS_handle_on_demand_block (key, size, data, - type, priority, anonymity, - expiration, uid, + GNUNET_FS_handle_on_demand_block (key, size, data, type, priority, + anonymity, expiration, uid, &process_migration_content, NULL)) consider_gathering (); return; @@ -560,11 +555,10 @@ gather_migration_blocks (void *cls, "Asking datastore for content for replication (queue size: %u)\n", mig_size); #endif - mig_qe = GNUNET_DATASTORE_get_for_replication (GSF_dsh, - 0, UINT_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, - &process_migration_content, - NULL); + mig_qe = + GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + &process_migration_content, NULL); if (NULL == mig_qe) consider_gathering (); } @@ -632,15 +626,13 @@ GSF_push_stop_ (struct GSF_ConnectedPeer *peer) void GSF_push_init_ () { - enabled = GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, - "FS", "CONTENT_PUSHING"); + enabled = + GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_PUSHING"); if (GNUNET_YES != enabled) return; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (GSF_cfg, - "fs", - "MIN_MIGRATION_DELAY", + GNUNET_CONFIGURATION_get_value_time (GSF_cfg, "fs", "MIN_MIGRATION_DELAY", &min_migration_delay)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index e67bf0c04..ec2344b37 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c @@ -86,9 +86,9 @@ static struct PutOperator operators[] = { * @param cls type of blocks to gather * @param tc scheduler context (unused) */ -static void -gather_dht_put_blocks (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void gather_dht_put_blocks (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** @@ -108,8 +108,9 @@ delay_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; if (po->zero_anonymity_count_estimate > 0) { - delay = GNUNET_TIME_relative_divide (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, - po->zero_anonymity_count_estimate); + delay = + GNUNET_TIME_relative_divide (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY, + po->zero_anonymity_count_estimate); delay = GNUNET_TIME_relative_min (delay, MAX_DHT_PUT_FREQ); } else @@ -118,8 +119,8 @@ delay_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * (hopefully) appear */ delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); } - po->dht_task = GNUNET_SCHEDULER_add_delayed (delay, - &gather_dht_put_blocks, po); + po->dht_task = + GNUNET_SCHEDULER_add_delayed (delay, &gather_dht_put_blocks, po); } @@ -138,13 +139,9 @@ delay_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * maybe 0 if no unique identifier is available */ static void -process_dht_put_content (void *cls, - const GNUNET_HashCode * key, - size_t size, - const void *data, - enum GNUNET_BLOCK_Type type, - uint32_t priority, - uint32_t anonymity, +process_dht_put_content (void *cls, const GNUNET_HashCode * key, size_t size, + const void *data, enum GNUNET_BLOCK_Type type, + uint32_t priority, uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, uint64_t uid) { struct PutOperator *po = cls; @@ -157,22 +154,16 @@ process_dht_put_content (void *cls, po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_blocks, po); return; } - po->zero_anonymity_count_estimate = GNUNET_MAX (po->current_offset, - po->zero_anonymity_count_estimate); + po->zero_anonymity_count_estimate = + GNUNET_MAX (po->current_offset, po->zero_anonymity_count_estimate); #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Retrieved block `%s' of type %u for DHT PUT\n", - GNUNET_h2s (key), type); + "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), + type); #endif - GNUNET_DHT_put (GSF_dht, - key, - DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_NONE, - type, - size, - data, - expiration, - GNUNET_TIME_UNIT_FOREVER_REL, &delay_dht_put_blocks, po); + GNUNET_DHT_put (GSF_dht, key, DEFAULT_PUT_REPLICATION, GNUNET_DHT_RO_NONE, + type, size, data, expiration, GNUNET_TIME_UNIT_FOREVER_REL, + &delay_dht_put_blocks, po); } @@ -190,13 +181,12 @@ gather_dht_put_blocks (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) po->dht_task = GNUNET_SCHEDULER_NO_TASK; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; - po->dht_qe = GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, - po->current_offset++, - 0, UINT_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, - po->dht_put_type, - &process_dht_put_content, - po); + po->dht_qe = + GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0, + UINT_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + po->dht_put_type, + &process_dht_put_content, po); if (NULL == po->dht_qe) po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_blocks, po); } diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index a4aad4568..d52956a75 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c @@ -86,16 +86,14 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) if (verbose) { s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta); - fprintf (stdout, - _("Unindexing at %llu/%llu (%s remaining)\n"), + fprintf (stdout, _("Unindexing at %llu/%llu (%s remaining)\n"), (unsigned long long) info->value.unindex.completed, (unsigned long long) info->value.unindex.size, s); GNUNET_free (s); } break; case GNUNET_FS_STATUS_UNINDEX_ERROR: - fprintf (stderr, - _("Error unindexing: %s.\n"), + fprintf (stderr, _("Error unindexing: %s.\n"), info->value.unindex.specifics.error.message); GNUNET_SCHEDULER_shutdown (); break; @@ -104,8 +102,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: - GNUNET_SCHEDULER_add_continuation (&cleanup_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -125,9 +122,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { /* check arguments */ if ((args[0] == NULL) || (args[1] != NULL)) @@ -137,10 +133,9 @@ run (void *cls, return; } cfg = c; - ctx = GNUNET_FS_start (cfg, - "gnunet-unindex", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + ctx = + GNUNET_FS_start (cfg, "gnunet-unindex", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); if (NULL == ctx) { fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); @@ -154,8 +149,8 @@ run (void *cls, GNUNET_FS_stop (ctx); return; } - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); } @@ -176,9 +171,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-unindex [OPTIONS] FILENAME", + GNUNET_PROGRAM_run (argc, argv, "gnunet-unindex [OPTIONS] FILENAME", gettext_noop ("Unindex a file that was previously indexed with gnunet-publish."), options, &run, NULL)) ? ret : 1; diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c index 92441e901..0737ea949 100644 --- a/src/fs/perf_gnunet_service_fs_p2p.c +++ b/src/fs/perf_gnunet_service_fs_p2p.c @@ -115,15 +115,13 @@ static struct StatValues stats[] = { * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -print_stat (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { struct StatMaster *sm = cls; - fprintf (stderr, - "Peer %2u: %12s/%50s = %12llu\n", - sm->daemon, subsystem, name, (unsigned long long) value); + fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, + name, (unsigned long long) value); return GNUNET_OK; } @@ -164,8 +162,8 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #else stats[sm->value].subsystem, stats[sm->value].name, #endif - GNUNET_TIME_UNIT_FOREVER_REL, - &get_done, &print_stat, sm); + GNUNET_TIME_UNIT_FOREVER_REL, &get_done, &print_stat, + sm); return; } GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); @@ -177,9 +175,10 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_now (&do_stop, NULL); return; } - sm->stat = GNUNET_STATISTICS_create ("", - GNUNET_FS_TEST_get_configuration - (daemons, sm->daemon)); + sm->stat = + GNUNET_STATISTICS_create ("", + GNUNET_FS_TEST_get_configuration (daemons, + sm->daemon)); GNUNET_SCHEDULER_add_now (&stat_run, sm); } @@ -201,13 +200,14 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1000LL / del.rel_value); fprintf (stdout, "Download speed was %s/s\n", fancy); GNUNET_free (fancy); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Finished download, shutting down\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", (unsigned long long) FILESIZE); sm = GNUNET_malloc (sizeof (struct StatMaster)); - sm->stat = GNUNET_STATISTICS_create ("", - GNUNET_FS_TEST_get_configuration - (daemons, sm->daemon)); + sm->stat = + GNUNET_STATISTICS_create ("", + GNUNET_FS_TEST_get_configuration (daemons, + sm-> + daemon)); GNUNET_SCHEDULER_add_now (&stat_run, sm); } else @@ -233,16 +233,15 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Downloading %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); if (NULL != strstr (progname, "dht")) anonymity = 0; else anonymity = 1; - GNUNET_FS_TEST_download (daemons[0], - TIMEOUT, - anonymity, SEED, uri, VERBOSE, &do_report, NULL); + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE, + &do_report, NULL); } @@ -259,8 +258,8 @@ do_publish (void *cls, const char *emsg) ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + (unsigned long long) FILESIZE); if (NULL != strstr (progname, "index")) do_index = GNUNET_YES; else @@ -270,11 +269,9 @@ do_publish (void *cls, const char *emsg) else anonymity = 1; - GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], - TIMEOUT, - anonymity, - do_index, FILESIZE, SEED, - VERBOSE, &do_download, NULL); + GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, + do_index, FILESIZE, SEED, VERBOSE, &do_download, + NULL); } @@ -287,27 +284,22 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); pg = GNUNET_FS_TEST_get_group (daemons); - GNUNET_break ((NUM_DAEMONS - 1) * 2 - == (GNUNET_TESTING_create_topology (pg, - GNUNET_TESTING_TOPOLOGY_LINE, - GNUNET_TESTING_TOPOLOGY_NONE, - NULL))); - GNUNET_TESTING_connect_topology (pg, - GNUNET_TESTING_TOPOLOGY_LINE, - GNUNET_TESTING_TOPOLOGY_OPTION_NONE, - 0.0, + GNUNET_break ((NUM_DAEMONS - 1) * 2 == + (GNUNET_TESTING_create_topology + (pg, GNUNET_TESTING_TOPOLOGY_LINE, + GNUNET_TESTING_TOPOLOGY_NONE, NULL))); + GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE, + GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 0.0, TIMEOUT, NUM_DAEMONS, &do_publish, NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", - TIMEOUT, - NUM_DAEMONS, daemons, &do_connect, NULL); + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, + daemons, &do_connect, NULL); } @@ -335,9 +327,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "perf-gnunet-service-fs-p2p-index", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "perf-gnunet-service-fs-p2p-index", "nohelp", options, + &run, NULL); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); return ok; } diff --git a/src/fs/perf_gnunet_service_fs_p2p_trust.c b/src/fs/perf_gnunet_service_fs_p2p_trust.c index a78ff0571..5a8d4242a 100644 --- a/src/fs/perf_gnunet_service_fs_p2p_trust.c +++ b/src/fs/perf_gnunet_service_fs_p2p_trust.c @@ -148,15 +148,13 @@ static struct StatValues stats[] = { * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -print_stat (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { struct StatMaster *sm = cls; - fprintf (stderr, - "Peer %2u: %12s/%50s = %12llu\n", - sm->daemon, subsystem, name, (unsigned long long) value); + fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, + name, (unsigned long long) value); return GNUNET_OK; } @@ -197,8 +195,8 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #else stats[sm->value].subsystem, stats[sm->value].name, #endif - GNUNET_TIME_UNIT_FOREVER_REL, - &get_done, &print_stat, sm); + GNUNET_TIME_UNIT_FOREVER_REL, &get_done, &print_stat, + sm); return; } GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); @@ -210,9 +208,10 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_now (&do_stop, NULL); return; } - sm->stat = GNUNET_STATISTICS_create ("", - GNUNET_FS_TEST_get_configuration - (daemons, sm->daemon)); + sm->stat = + GNUNET_STATISTICS_create ("", + GNUNET_FS_TEST_get_configuration (daemons, + sm->daemon)); GNUNET_SCHEDULER_add_now (&stat_run, sm); } @@ -242,9 +241,11 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Finished all downloads, shutting down\n", (unsigned long long) FILESIZE); sm = GNUNET_malloc (sizeof (struct StatMaster)); - sm->stat = GNUNET_STATISTICS_create ("", - GNUNET_FS_TEST_get_configuration - (daemons, sm->daemon)); + sm->stat = + GNUNET_STATISTICS_create ("", + GNUNET_FS_TEST_get_configuration (daemons, + sm-> + daemon)); GNUNET_SCHEDULER_add_now (&stat_run, sm); } else @@ -273,8 +274,8 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2) return; } uri2 = GNUNET_FS_uri_dup (u2); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Downloading %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); if (NULL != strstr (progname, "dht")) anonymity = 0; @@ -284,21 +285,15 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2) * these peers do participate in sharing, they just * don't have to offer anything *initially*. */ for (i = 0; i < NUM_DAEMONS - 2; i++) - GNUNET_FS_TEST_download (daemons[i], - TIMEOUT, - anonymity, + GNUNET_FS_TEST_download (daemons[i], TIMEOUT, anonymity, 0 == (i % 2) ? SEED1 : SEED2, - 0 == (i % 2) ? uri1 : uri2, - VERBOSE, &do_report, "leach"); + 0 == (i % 2) ? uri1 : uri2, VERBOSE, &do_report, + "leach"); /* mutual downloads of (primary) sharing peers */ - GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], - TIMEOUT, - anonymity, SEED1, uri1, - VERBOSE, &do_report, "seeder 2"); - GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1], - TIMEOUT, - anonymity, SEED2, uri2, - VERBOSE, &do_report, "seeder 1"); + GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, SEED1, + uri1, VERBOSE, &do_report, "seeder 2"); + GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, SEED2, + uri2, VERBOSE, &do_report, "seeder 1"); } @@ -317,8 +312,8 @@ do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1) return; } uri1 = GNUNET_FS_uri_dup (u1); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + (unsigned long long) FILESIZE); if (NULL != strstr (progname, "index")) do_index = GNUNET_YES; else @@ -328,11 +323,9 @@ do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1) else anonymity = 1; - GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], - TIMEOUT, - anonymity, - do_index, FILESIZE, SEED2, - VERBOSE, &do_downloads, NULL); + GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, + do_index, FILESIZE, SEED2, VERBOSE, &do_downloads, + NULL); } static void @@ -348,8 +341,8 @@ do_publish1 (void *cls, const char *emsg) ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + (unsigned long long) FILESIZE); if (NULL != strstr (progname, "index")) do_index = GNUNET_YES; else @@ -359,11 +352,9 @@ do_publish1 (void *cls, const char *emsg) else anonymity = 1; - GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], - TIMEOUT, - anonymity, - do_index, FILESIZE, SEED1, - VERBOSE, &do_publish2, NULL); + GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, + do_index, FILESIZE, SEED1, VERBOSE, &do_publish2, + NULL); } @@ -376,25 +367,20 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); pg = GNUNET_FS_TEST_get_group (daemons); - GNUNET_TESTING_create_topology (pg, - GNUNET_TESTING_TOPOLOGY_CLIQUE, + GNUNET_TESTING_create_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, GNUNET_TESTING_TOPOLOGY_NONE, NULL); - GNUNET_TESTING_connect_topology (pg, - GNUNET_TESTING_TOPOLOGY_CLIQUE, - GNUNET_TESTING_TOPOLOGY_OPTION_NONE, - 0.0, + GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, + GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 0.0, TIMEOUT, NUM_DAEMONS, &do_publish1, NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", - TIMEOUT, - NUM_DAEMONS, daemons, &do_connect, NULL); + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, + daemons, &do_connect, NULL); } @@ -422,9 +408,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "perf-gnunet-service-fs-p2p-trust", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "perf-gnunet-service-fs-p2p-trust", "nohelp", options, + &run, NULL); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); return ok; } diff --git a/src/fs/test_fs.c b/src/fs/test_fs.c index b936c3199..9aee89e85 100644 --- a/src/fs/test_fs.c +++ b/src/fs/test_fs.c @@ -40,8 +40,8 @@ makeName (unsigned int i) fn = GNUNET_malloc (strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") + 14); GNUNET_snprintf (fn, - strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") + - 14, "/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST%u", i); + strlen ("/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST") + 14, + "/tmp/gnunet-basic_fsui_test/BASIC_FSUI_TEST%u", i); GNUNET_disk_directory_create_for_file (NULL, fn); return fn; } @@ -143,9 +143,8 @@ main (int argc, char *argv[]) &eventCallback, NULL); CHECK (ctx != NULL); filename = makeName (42); - GNUNET_disk_file_write (NULL, - filename, - "foo bar test!", strlen ("foo bar test!"), "600"); + GNUNET_disk_file_write (NULL, filename, "foo bar test!", + strlen ("foo bar test!"), "600"); meta = GNUNET_meta_data_create (); kuri = GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, @@ -153,11 +152,9 @@ main (int argc, char *argv[]) /* upload */ upload = GNUNET_FSUI_upload_start (ctx, filename, (GNUNET_FSUI_DirectoryScanCallback) & GNUNET_disk_directory_scan, NULL, 0, /* anonymity */ 0, /* priority */ - GNUNET_YES, - GNUNET_NO, - GNUNET_NO, - GNUNET_get_time () + - 5 * GNUNET_CRON_HOURS, meta, kuri, kuri); + GNUNET_YES, GNUNET_NO, GNUNET_NO, + GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, + meta, kuri, kuri); CHECK (upload != NULL); GNUNET_ECRS_uri_destroy (kuri); GNUNET_meta_data_destroy (meta); @@ -190,11 +187,9 @@ main (int argc, char *argv[]) /* download */ fn = makeName (43); - download = GNUNET_FSUI_download_start (ctx, - 0, - GNUNET_NO, - search_uri, - search_meta, fn, NULL, NULL); + download = + GNUNET_FSUI_download_start (ctx, 0, GNUNET_NO, search_uri, search_meta, + fn, NULL, NULL); GNUNET_free (fn); prog = 0; while (lastEvent != GNUNET_FSUI_download_completed) diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c index d8a9c63b6..ac581bd6f 100644 --- a/src/fs/test_fs_directory.c +++ b/src/fs/test_fs_directory.c @@ -41,11 +41,9 @@ struct PCLS }; static void -processor (void *cls, - const char *filename, - const struct GNUNET_FS_Uri *uri, - const struct GNUNET_CONTAINER_MetaData *md, - size_t length, const void *data) +processor (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, + const struct GNUNET_CONTAINER_MetaData *md, size_t length, + const void *data) { struct PCLS *p = cls; int i; @@ -54,8 +52,7 @@ processor (void *cls, return; /* ignore directory's meta data */ for (i = 0; i < p->max; i++) { - if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i], - md) && + if (GNUNET_CONTAINER_meta_data_test_equal (p->md[i], md) && GNUNET_FS_uri_test_equal (p->uri[i], uri)) { p->pos++; @@ -88,17 +85,12 @@ testDirectory (unsigned int i) uris = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri *) * i); mds = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_MetaData *) * i); meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (meta, - "", - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "A title", strlen ("A title") + 1); - GNUNET_CONTAINER_meta_data_insert (meta, - "", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_AUTHOR_NAME, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "An author", strlen ("An author") + 1); for (p = 0; p < i; p++) { @@ -106,14 +98,12 @@ testDirectory (unsigned int i) for (q = 0; q <= p; q++) { GNUNET_snprintf (txt, sizeof (txt), "%u -- %u\n", p, q); - GNUNET_CONTAINER_meta_data_insert (mds[p], - "", + GNUNET_CONTAINER_meta_data_insert (mds[p], "", q % EXTRACTOR_metatype_get_max (), EXTRACTOR_METAFORMAT_UTF8, "text/plain", txt, strlen (txt) + 1); } - GNUNET_snprintf (uri, - sizeof (uri), + GNUNET_snprintf (uri, sizeof (uri), "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u", p); emsg = NULL; diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index d37b94c03..34625ff2e 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -140,42 +140,42 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kb/s.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL)); GAUGER ("FS", "Publishing speed (insertion)", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL), "kb/s"); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL), "kb/s"); fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); start = GNUNET_TIME_absolute_get (); - download = GNUNET_FS_download_start (fs, - event->value.publish. - specifics.completed.chk_uri, NULL, fn, - NULL, 0, FILESIZE, 1, - GNUNET_FS_DOWNLOAD_OPTION_NONE, - "download", NULL); + download = + GNUNET_FS_download_start (fs, + event->value.publish.specifics.completed. + chk_uri, NULL, fn, NULL, 0, FILESIZE, 1, + GNUNET_FS_DOWNLOAD_OPTION_NONE, "download", + NULL); GNUNET_assert (download != NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: printf ("Download complete, %llu kb/s.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL)); GAUGER ("FS", "Local download speed (inserted)", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL), "kb/s"); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL), "kb/s"); GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: @@ -185,22 +185,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.download.completed, (unsigned long long) event->value.download.size, event->value.download.specifics.progress.depth, - (unsigned long long) event->value.download.specifics. - progress.offset); + (unsigned long long) event->value.download.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: - fprintf (stderr, - "Error downloading file: %s\n", + fprintf (stderr, "Error downloading file: %s\n", event->value.download.specifics.error.message); GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; @@ -231,8 +228,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -248,12 +244,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -269,8 +266,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -281,9 +277,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -297,10 +292,8 @@ run (void *cls, struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_download_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-download", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-download", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) @@ -311,21 +304,18 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_data (fs, - "publish-context", - FILESIZE, - buf, - kuri, meta, GNUNET_NO, &bo); + fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", + FILESIZE, buf, kuri, meta, + GNUNET_NO, &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); - timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &timeout_kill_task, NULL); + timeout_kill = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -353,8 +343,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-download", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-download", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/"); return err; diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c index 86933352a..5b1752e63 100644 --- a/src/fs/test_fs_download_indexed.c +++ b/src/fs/test_fs_download_indexed.c @@ -141,42 +141,42 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL)); GAUGER ("FS", "Publishing speed (indexing)", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL), "kb/s"); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL), "kb/s"); fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); start = GNUNET_TIME_absolute_get (); - download = GNUNET_FS_download_start (fs, - event->value.publish. - specifics.completed.chk_uri, NULL, fn, - NULL, 0, FILESIZE, 1, - GNUNET_FS_DOWNLOAD_OPTION_NONE, - "download", NULL); + download = + GNUNET_FS_download_start (fs, + event->value.publish.specifics.completed. + chk_uri, NULL, fn, NULL, 0, FILESIZE, 1, + GNUNET_FS_DOWNLOAD_OPTION_NONE, "download", + NULL); GNUNET_assert (download != NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: printf ("Download complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL)); GAUGER ("FS", "Local download speed (indexed)", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL), "kb/s"); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL), "kb/s"); GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: @@ -186,22 +186,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.download.completed, (unsigned long long) event->value.download.size, event->value.download.specifics.progress.depth, - (unsigned long long) event->value.download.specifics. - progress.offset); + (unsigned long long) event->value.download.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: - fprintf (stderr, - "Error downloading file: %s\n", + fprintf (stderr, "Error downloading file: %s\n", event->value.download.specifics.error.message); GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; @@ -232,8 +229,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -249,12 +245,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -270,8 +267,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -282,9 +278,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -298,10 +293,8 @@ run (void *cls, size_t i; setup_peer (&p1, "test_fs_download_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-download-indexed", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-download-indexed", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); fn1 = GNUNET_DISK_mktemp ("gnunet-download-indexed-test"); @@ -309,9 +302,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn1, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn1, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -321,21 +312,18 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_file (fs, - "publish-context", - fn1, - kuri, - meta, GNUNET_YES, &bo); + fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn1, + kuri, meta, GNUNET_YES, + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); - timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &timeout_kill_task, NULL); + timeout_kill = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -363,9 +351,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-download-indexed", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-download-indexed", "nohelp", options, &run, + NULL); stop_arm (&p1); if (fn1 != NULL) { diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index d484f9587..5b2a53f80 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c @@ -132,10 +132,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting FS.\n"); GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (cfg, - "test-fs-download-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-download-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); } @@ -174,26 +171,22 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL)); fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); start = GNUNET_TIME_absolute_get (); GNUNET_assert (download == NULL); GNUNET_FS_download_start (fs, event->value.publish.specifics.completed.chk_uri, - NULL, - fn, NULL, - 0, - FILESIZE, - 1, + NULL, fn, NULL, 0, FILESIZE, 1, GNUNET_FS_DOWNLOAD_OPTION_NONE, "download", NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: @@ -201,8 +194,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) printf ("Download complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024LL)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024LL)); GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: @@ -213,22 +206,19 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.download.completed, (unsigned long long) event->value.download.size, event->value.download.specifics.progress.depth, - (unsigned long long) event->value.download.specifics. - progress.offset); + (unsigned long long) event->value.download.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_DOWNLOAD_ERROR: - fprintf (stderr, - "Error downloading file: %s\n", + fprintf (stderr, "Error downloading file: %s\n", event->value.download.specifics.error.message); GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); break; @@ -287,8 +277,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: GNUNET_assert (download == event->value.download.dc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); download = NULL; break; @@ -305,12 +294,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -326,8 +316,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -338,9 +327,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { const char *keywords[] = { "down_foo", @@ -355,10 +343,7 @@ run (void *cls, cfg = c; setup_peer (&p1, "test_fs_download_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-download-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-download-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); @@ -370,21 +355,18 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_data (fs, - "publish-context", - FILESIZE, - buf, - kuri, meta, GNUNET_NO, &bo); + fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", + FILESIZE, buf, kuri, meta, + GNUNET_NO, &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); - timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &timeout_kill_task, NULL); + timeout_kill = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -412,9 +394,9 @@ main (int argc, char *argv[]) #endif NULL); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/"); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-download-persistence", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-download-persistence", "nohelp", options, &run, + NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/"); return err; diff --git a/src/fs/test_fs_download_recursive.c b/src/fs/test_fs_download_recursive.c index c3e0ea440..d350dcae8 100644 --- a/src/fs/test_fs_download_recursive.c +++ b/src/fs/test_fs_download_recursive.c @@ -50,9 +50,9 @@ makeName (unsigned int i) ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST") + 15); GNUNET_snprintf (fn, - strlen - ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST") + 15, - "/tmp/gnunet-fsui-recursive_download_test/FSUITEST%u/", i); + strlen ("/tmp/gnunet-fsui-recursive_download_test/FSUITEST") + + 15, "/tmp/gnunet-fsui-recursive_download_test/FSUITEST%u/", + i); return fn; } @@ -142,8 +142,9 @@ checkHierarchy (unsigned int i, const char *tree) GNUNET_free (fn); return GNUNET_SYSERR; } - res = ((makeHierarchyHelper (fn, tree, 0, 1) == -1) ? - GNUNET_SYSERR : GNUNET_OK); + res = + ((makeHierarchyHelper (fn, tree, 0, 1) == + -1) ? GNUNET_SYSERR : GNUNET_OK); GNUNET_free (fn); return res; } @@ -287,9 +288,9 @@ main (int argc, char *argv[]) GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */ /* ACTUAL TEST CODE */ #endif - ctx = GNUNET_FSUI_start (NULL, - cfg, "fsuirecursive_download_test", 32, GNUNET_YES, - &eventCallback, NULL); + ctx = + GNUNET_FSUI_start (NULL, cfg, "fsuirecursive_download_test", 32, + GNUNET_YES, &eventCallback, NULL); CHECK (ctx != NULL); fn = makeHierarchy (42, DIRECTORY_TREE_SPEC); meta = GNUNET_meta_data_create (); @@ -298,13 +299,13 @@ main (int argc, char *argv[]) (const char **) keywords); fprintf (stderr, "Uploading...\n"); waitForEvent = GNUNET_FSUI_upload_completed; - upload = GNUNET_FSUI_upload_start (ctx, - fn, - (GNUNET_FSUI_DirectoryScanCallback) & - GNUNET_disk_directory_scan, NULL, 0, 0, - GNUNET_YES, GNUNET_NO, GNUNET_NO, - GNUNET_get_time () + - 5 * GNUNET_CRON_HOURS, meta, kuri, kuri); + upload = + GNUNET_FSUI_upload_start (ctx, fn, + (GNUNET_FSUI_DirectoryScanCallback) & + GNUNET_disk_directory_scan, NULL, 0, 0, + GNUNET_YES, GNUNET_NO, GNUNET_NO, + GNUNET_get_time () + 5 * GNUNET_CRON_HOURS, + meta, kuri, kuri); CHECK (upload != NULL); GNUNET_ECRS_uri_destroy (kuri); kuri = NULL; @@ -324,10 +325,9 @@ main (int argc, char *argv[]) fprintf (stderr, "Downloading...\n"); waitForEvent = GNUNET_FSUI_download_completed; fn43 = makeName (43); - download = GNUNET_FSUI_download_start (ctx, - 0, - GNUNET_YES, - upURI, meta, fn43, NULL, NULL); + download = + GNUNET_FSUI_download_start (ctx, 0, GNUNET_YES, upURI, meta, fn43, NULL, + NULL); CHECK (download != NULL); GNUNET_free (fn43); fn43 = NULL; diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c index 97a63062e..db5a8448a 100644 --- a/src/fs/test_fs_file_information.c +++ b/src/fs/test_fs_file_information.c @@ -50,11 +50,8 @@ static int -mycleaner (void *cls, - struct GNUNET_FS_FileInformation *fi, - uint64_t length, - struct GNUNET_CONTAINER_MetaData *meta, - struct GNUNET_FS_Uri **uri, +mycleaner (void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, + struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { return GNUNET_OK; @@ -62,9 +59,8 @@ mycleaner (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -89,9 +85,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn1, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn1, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -101,9 +95,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn2, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn2, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -114,21 +106,22 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi1 = GNUNET_FS_file_information_create_from_file (fs, - "file_information-context1", - fn1, - kuri, - meta, GNUNET_YES, &bo); + fi1 = + GNUNET_FS_file_information_create_from_file (fs, + "file_information-context1", + fn1, kuri, meta, GNUNET_YES, + &bo); GNUNET_assert (fi1 != NULL); - fi2 = GNUNET_FS_file_information_create_from_file (fs, - "file_information-context2", - fn2, - kuri, - meta, GNUNET_YES, &bo); + fi2 = + GNUNET_FS_file_information_create_from_file (fs, + "file_information-context2", + fn2, kuri, meta, GNUNET_YES, + &bo); GNUNET_assert (fi2 != NULL); - fidir = GNUNET_FS_file_information_create_empty_directory (fs, - "file_information-context-dir", - kuri, meta, &bo); + fidir = + GNUNET_FS_file_information_create_empty_directory (fs, + "file_information-context-dir", + kuri, meta, &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); @@ -165,9 +158,10 @@ testThumbnail () ex = EXTRACTOR_plugin_add_config (ex, "mime", EXTRACTOR_OPTION_DEFAULT_POLICY); m = GNUNET_CONTAINER_meta_data_create (); - if (3 != GNUNET_FS_meta_data_extract_from_file (m, - "test_fs_file_information_meta_data_image.jpg", - ex)) + if (3 != + GNUNET_FS_meta_data_extract_from_file (m, + "test_fs_file_information_meta_data_image.jpg", + ex)) { GNUNET_break (0); EXTRACTOR_plugin_remove_all (ex); @@ -187,8 +181,9 @@ testThumbnail () } GNUNET_free (thumb); GNUNET_CONTAINER_meta_data_add_publication_date (d); - date = GNUNET_CONTAINER_meta_data_get_by_type (d, - EXTRACTOR_METATYPE_PUBLICATION_DATE); + date = + GNUNET_CONTAINER_meta_data_get_by_type (d, + EXTRACTOR_METATYPE_PUBLICATION_DATE); if (date == NULL) { GNUNET_break (0); @@ -227,9 +222,9 @@ main (int argc, char *argv[]) NULL); if (0 != testThumbnail ()) return 1; - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-file_information", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-file_information", "nohelp", options, &run, + NULL); return 0; } diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index e3330f3ba..87afa12e1 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c @@ -92,8 +92,8 @@ static void list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, + GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -110,11 +110,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) printf ("Publish complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (&list_indexed_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -126,41 +125,41 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_ERROR: ret = event->value.publish.cctx; - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); err = 1; if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_START: ret = event->value.publish.cctx; if (0 == strcmp ("list_indexed-context1", event->value.publish.cctx)) { - GNUNET_assert (0 == strcmp ("list_indexed-context-dir", - event->value.publish.pctx)); + GNUNET_assert (0 == + strcmp ("list_indexed-context-dir", + event->value.publish.pctx)); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (1 == event->value.publish.anonymity); } else if (0 == strcmp ("list_indexed-context2", event->value.publish.cctx)) { - GNUNET_assert (0 == strcmp ("list_indexed-context-dir", - event->value.publish.pctx)); + GNUNET_assert (0 == + strcmp ("list_indexed-context-dir", + event->value.publish.pctx)); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (2 == event->value.publish.anonymity); } - else if (0 == strcmp ("list_indexed-context-dir", - event->value.publish.cctx)) + else if (0 == + strcmp ("list_indexed-context-dir", event->value.publish.cctx)) { GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (3 == event->value.publish.anonymity); @@ -188,12 +187,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -209,8 +209,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -221,9 +220,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -239,19 +237,15 @@ run (void *cls, struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_list_indexed_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-list_indexed", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-list_indexed", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); fn1 = GNUNET_DISK_mktemp ("gnunet-list_indexed-test-dst"); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn1, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn1, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -261,9 +255,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn2, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn2, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -274,33 +266,31 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi1 = GNUNET_FS_file_information_create_from_file (fs, - "list_indexed-context1", - fn1, - kuri, - meta, GNUNET_YES, &bo); + fi1 = + GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context1", + fn1, kuri, meta, GNUNET_YES, + &bo); GNUNET_assert (NULL != fi1); bo.anonymity_level = 2; - fi2 = GNUNET_FS_file_information_create_from_file (fs, - "list_indexed-context2", - fn2, - kuri, - meta, GNUNET_YES, &bo); + fi2 = + GNUNET_FS_file_information_create_from_file (fs, "list_indexed-context2", + fn2, kuri, meta, GNUNET_YES, + &bo); GNUNET_assert (NULL != fi2); bo.anonymity_level = 3; - fidir = GNUNET_FS_file_information_create_empty_directory (fs, - "list_indexed-context-dir", - kuri, meta, &bo); + fidir = + GNUNET_FS_file_information_create_empty_directory (fs, + "list_indexed-context-dir", + kuri, meta, &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fidir); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fidir, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -328,9 +318,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-list_indexed", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-list_indexed", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-list-indexed/"); if (fn1 != NULL) diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index 96caa8dfa..ae2f77806 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c @@ -66,12 +66,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -87,8 +88,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -155,8 +155,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) case GNUNET_FS_STATUS_SEARCH_RESULT: if (sks_search == event->value.search.sc) { - if (!GNUNET_FS_uri_test_equal (sks_expect_uri, - event->value.search.specifics.result.uri)) + if (!GNUNET_FS_uri_test_equal + (sks_expect_uri, event->value.search.specifics.result.uri)) { fprintf (stderr, "Wrong result for sks search!\n"); err = 1; @@ -167,14 +167,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) } else if (ksk_search == event->value.search.sc) { - if (!GNUNET_FS_uri_test_equal (ksk_expect_uri, - event->value.search.specifics.result.uri)) + if (!GNUNET_FS_uri_test_equal + (ksk_expect_uri, event->value.search.specifics.result.uri)) { fprintf (stderr, "Wrong result for ksk search!\n"); err = 1; } - GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } else @@ -184,16 +183,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) } break; case GNUNET_FS_STATUS_SEARCH_ERROR: - fprintf (stderr, - "Error searching file: %s\n", + fprintf (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); if (sks_search == event->value.search.sc) - GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); else if (ksk_search == event->value.search.sc) - GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); else GNUNET_break (0); @@ -365,15 +361,12 @@ testNamespace () static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { setup_peer (&p1, "test_fs_namespace_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-namespace", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); testNamespace (); } @@ -401,9 +394,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-namespace", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-namespace", "nohelp", options, &run, NULL); stop_arm (&p1); if (GNUNET_YES != update_started) { diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c index dc8673e21..1ad2fb5ac 100644 --- a/src/fs/test_fs_namespace_list_updateable.c +++ b/src/fs/test_fs_namespace_list_updateable.c @@ -70,12 +70,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -91,8 +92,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -112,8 +112,7 @@ stop_arm (struct PeerContext *p) static void -check_next (void *cls, - const char *last_id, +check_next (void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_CONTAINER_MetaData *last_meta, const char *next_id) @@ -125,8 +124,7 @@ check_next (void *cls, static void -check_this_next (void *cls, - const char *last_id, +check_this_next (void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_CONTAINER_MetaData *last_meta, const char *next_id) @@ -150,8 +148,7 @@ sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) static void -check_this (void *cls, - const char *last_id, +check_this (void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_CONTAINER_MetaData *last_meta, const char *next_id) @@ -169,13 +166,7 @@ sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) GNUNET_assert (NULL == emsg); err = 1; GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this, NULL); - GNUNET_FS_publish_sks (fs, - ns, - "next", - "future", - meta, - uri_next, - &bo, + GNUNET_FS_publish_sks (fs, ns, "next", "future", meta, uri_next, &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont_next, NULL); } @@ -209,15 +200,12 @@ testNamespace () static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { setup_peer (&p1, "test_fs_namespace_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-namespace", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); testNamespace (); } @@ -245,9 +233,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-namespace", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-namespace", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/"); return err; diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c index d53b5b0ae..797c4c9a8 100644 --- a/src/fs/test_fs_publish.c +++ b/src/fs/test_fs_publish.c @@ -98,11 +98,10 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) printf ("Publish complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_PROGRESS: @@ -113,22 +112,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_ERROR: ret = event->value.publish.cctx; - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); err = 1; if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) { fprintf (stderr, "Scheduling abort task for error on `%s'\n", (const char *) event->value.publish.cctx); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } break; @@ -136,16 +133,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) ret = event->value.publish.cctx; if (0 == strcmp ("publish-context1", event->value.publish.cctx)) { - GNUNET_assert (0 == strcmp ("publish-context-dir", - event->value.publish.pctx)); + GNUNET_assert (0 == + strcmp ("publish-context-dir", event->value.publish.pctx)); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (1 == event->value.publish.anonymity); } else if (0 == strcmp ("publish-context2", event->value.publish.cctx)) { - GNUNET_assert (0 == strcmp ("publish-context-dir", - event->value.publish.pctx)); + GNUNET_assert (0 == + strcmp ("publish-context-dir", event->value.publish.pctx)); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (2 == event->value.publish.anonymity); @@ -175,12 +172,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -196,8 +194,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -208,9 +205,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -226,19 +222,15 @@ run (void *cls, struct GNUNET_FS_BlockOptions bo; setup_peer (&p1, "test_fs_publish_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-publish", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-publish", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); fn1 = GNUNET_DISK_mktemp ("gnunet-publish-test-dst"); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn1, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn1, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -248,9 +240,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn2, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn2, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -262,34 +252,30 @@ run (void *cls, bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi1 = GNUNET_FS_file_information_create_from_file (fs, - "publish-context1", - fn1, - kuri, - meta, GNUNET_YES, &bo); + fi1 = + GNUNET_FS_file_information_create_from_file (fs, "publish-context1", fn1, + kuri, meta, GNUNET_YES, &bo); GNUNET_assert (NULL != fi1); bo.anonymity_level = 2; - fi2 = GNUNET_FS_file_information_create_from_file (fs, - "publish-context2", - fn2, - kuri, - meta, GNUNET_YES, &bo); + fi2 = + GNUNET_FS_file_information_create_from_file (fs, "publish-context2", fn2, + kuri, meta, GNUNET_YES, &bo); GNUNET_assert (NULL != fi2); bo.anonymity_level = 3; - fidir = GNUNET_FS_file_information_create_empty_directory (fs, - "publish-context-dir", - kuri, meta, &bo); + fidir = + GNUNET_FS_file_information_create_empty_directory (fs, + "publish-context-dir", + kuri, meta, &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fidir); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fidir, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -317,8 +303,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-publish", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-publish", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/"); if (fn1 != NULL) diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c index 4dcf10965..f69ac5d9a 100644 --- a/src/fs/test_fs_publish_persistence.c +++ b/src/fs/test_fs_publish_persistence.c @@ -106,10 +106,7 @@ restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { rtask = GNUNET_SCHEDULER_NO_TASK; GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (cfg, - "test-fs-publish-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); } @@ -132,8 +129,9 @@ consider_restart (int ev) if (prev[i] == ev) return; prev[off++] = ev; - rtask = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, - &restart_fs_task, NULL); + rtask = + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, + &restart_fs_task, NULL); } @@ -151,8 +149,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) printf ("Publish complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000LL / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); if (0 == strcmp ("publish-context-dir", event->value.publish.cctx)) GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); break; @@ -165,8 +163,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_SUSPEND: @@ -177,17 +175,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) if (NULL == publish) { GNUNET_assert (GNUNET_YES == - GNUNET_FS_file_information_is_directory (event-> - value.publish. - fi)); + GNUNET_FS_file_information_is_directory (event->value. + publish.fi)); publish = event->value.publish.pc; return "publish-context-dir"; } break; case GNUNET_FS_STATUS_PUBLISH_ERROR: ret = event->value.publish.cctx; - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); err = 1; GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); @@ -198,16 +194,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) ret = event->value.publish.cctx; if (0 == strcmp ("publish-context1", event->value.publish.cctx)) { - GNUNET_assert (0 == strcmp ("publish-context-dir", - event->value.publish.pctx)); + GNUNET_assert (0 == + strcmp ("publish-context-dir", event->value.publish.pctx)); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (1 == event->value.publish.anonymity); } else if (0 == strcmp ("publish-context2", event->value.publish.cctx)) { - GNUNET_assert (0 == strcmp ("publish-context-dir", - event->value.publish.pctx)); + GNUNET_assert (0 == + strcmp ("publish-context-dir", event->value.publish.pctx)); GNUNET_assert (FILESIZE == event->value.publish.size); GNUNET_assert (0 == event->value.publish.completed); GNUNET_assert (2 == event->value.publish.anonymity); @@ -238,12 +234,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -259,8 +256,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -271,9 +267,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { const char *keywords[] = { "down_foo", @@ -290,10 +285,7 @@ run (void *cls, cfg = c; setup_peer (&p1, "test_fs_publish_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-publish-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-publish-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); fn1 = GNUNET_DISK_mktemp ("gnunet-publish-test-dst"); @@ -301,9 +293,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn1, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn1, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -313,9 +303,7 @@ run (void *cls, for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn2, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn2, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -326,32 +314,28 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi1 = GNUNET_FS_file_information_create_from_file (fs, - "publish-context1", - fn1, - kuri, - meta, GNUNET_YES, &bo); + fi1 = + GNUNET_FS_file_information_create_from_file (fs, "publish-context1", fn1, + kuri, meta, GNUNET_YES, &bo); GNUNET_assert (NULL != fi1); bo.anonymity_level = 2; - fi2 = GNUNET_FS_file_information_create_from_file (fs, - "publish-context2", - fn2, - kuri, - meta, GNUNET_YES, &bo); + fi2 = + GNUNET_FS_file_information_create_from_file (fs, "publish-context2", fn2, + kuri, meta, GNUNET_YES, &bo); GNUNET_assert (NULL != fi2); bo.anonymity_level = 3; - fidir = GNUNET_FS_file_information_create_empty_directory (fs, - "publish-context-dir", - kuri, meta, &bo); + fidir = + GNUNET_FS_file_information_create_empty_directory (fs, + "publish-context-dir", + kuri, meta, &bo); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi1)); GNUNET_assert (GNUNET_OK == GNUNET_FS_file_information_add (fidir, fi2)); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fidir); start = GNUNET_TIME_absolute_get (); - GNUNET_FS_publish_start (fs, - fidir, - NULL, NULL, NULL, GNUNET_FS_PUBLISH_OPTION_NONE); + GNUNET_FS_publish_start (fs, fidir, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -379,8 +363,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-publish", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-publish", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-publish/"); if (fn1 != NULL) diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c index 878624c73..3961017cf 100644 --- a/src/fs/test_fs_search.c +++ b/src/fs/test_fs_search.c @@ -101,16 +101,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); start = GNUNET_TIME_absolute_get (); - search = GNUNET_FS_search_start (fs, - kuri, - 1, GNUNET_FS_SEARCH_OPTION_NONE, "search"); + search = + GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, + "search"); GNUNET_FS_uri_destroy (kuri); GNUNET_assert (search != NULL); break; @@ -118,25 +118,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) #if VERBOSE printf ("Search complete.\n"); #endif - GNUNET_SCHEDULER_add_continuation (&abort_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_SEARCH_ERROR: - fprintf (stderr, - "Error searching file: %s\n", + fprintf (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_START: @@ -162,8 +157,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -179,12 +173,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -200,8 +195,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -212,9 +206,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -228,10 +221,8 @@ run (void *cls, size_t i; setup_peer (&p1, "test_fs_search_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-search", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) @@ -242,19 +233,16 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_data (fs, - "publish-context", - FILESIZE, - buf, - kuri, meta, GNUNET_NO, &bo); + fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", + FILESIZE, buf, kuri, meta, + GNUNET_NO, &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -282,8 +270,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-search", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-search", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); return 0; diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index eceb4d1d5..5c5a6f140 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c @@ -94,10 +94,7 @@ static void restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (cfg, - "test-fs-search-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); } @@ -143,15 +140,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); start = GNUNET_TIME_absolute_get (); - GNUNET_FS_search_start (fs, - kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, "search"); + GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, + "search"); GNUNET_FS_uri_destroy (kuri); GNUNET_assert (search != NULL); break; @@ -169,25 +166,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) #if VERBOSE printf ("Search complete.\n"); #endif - GNUNET_SCHEDULER_add_continuation (&abort_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_SEARCH_ERROR: - fprintf (stderr, - "Error searching file: %s\n", + fprintf (stderr, "Error searching file: %s\n", event->value.search.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_search_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_SEARCH_SUSPEND: @@ -226,8 +218,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_assert (search == event->value.search.sc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); search = NULL; break; @@ -244,12 +235,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -265,8 +257,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -277,9 +268,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { const char *keywords[] = { "down_foo", @@ -294,10 +284,7 @@ run (void *cls, cfg = c; setup_peer (&p1, "test_fs_search_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-search-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); @@ -309,19 +296,16 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_data (fs, - "publish-context", - FILESIZE, - buf, - kuri, meta, GNUNET_NO, &bo); + fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", + FILESIZE, buf, kuri, meta, + GNUNET_NO, &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -350,9 +334,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-search-persistence", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-search-persistence", "nohelp", options, &run, + NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); return 0; diff --git a/src/fs/test_fs_search_ranking.c b/src/fs/test_fs_search_ranking.c index b19ff97bf..53522c6fe 100644 --- a/src/fs/test_fs_search_ranking.c +++ b/src/fs/test_fs_search_ranking.c @@ -38,8 +38,7 @@ makeName (unsigned int i) char *fn; fn = GNUNET_malloc (strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14); - GNUNET_snprintf (fn, - strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14, + GNUNET_snprintf (fn, strlen ("/tmp/gnunet-fsui-searchranktest/FSUITEST") + 14, "/tmp/gnunet-fsui-searchranktest/FSUITEST%u", i); GNUNET_disk_directory_create_for_file (NULL, fn); return fn; @@ -159,22 +158,21 @@ main (int argc, char *argv[]) GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to start */ /* ACTUAL TEST CODE */ #endif - ctx = GNUNET_FSUI_start (NULL, - cfg, "fsuisearchranktest", 32, GNUNET_YES, - &eventCallback, NULL); + ctx = + GNUNET_FSUI_start (NULL, cfg, "fsuisearchranktest", 32, GNUNET_YES, + &eventCallback, NULL); CHECK (ctx != NULL); /* upload */ fn = makeName (42); - GNUNET_disk_file_write (NULL, - fn, "foo bar test!", strlen ("foo bar test!"), "600"); + GNUNET_disk_file_write (NULL, fn, "foo bar test!", strlen ("foo bar test!"), + "600"); meta = GNUNET_meta_data_create (); kuri = GNUNET_ECRS_keyword_command_line_to_uri (NULL, 2, (const char **) keywords); waitForEvent = GNUNET_FSUI_upload_completed; upload = - GNUNET_FSUI_upload_start (ctx, - fn, + GNUNET_FSUI_upload_start (ctx, fn, (GNUNET_FSUI_DirectoryScanCallback) & GNUNET_disk_directory_scan, NULL, 0, 0, GNUNET_YES, GNUNET_NO, GNUNET_NO, @@ -191,8 +189,8 @@ main (int argc, char *argv[]) prog++; if (prog == 10000) { - fprintf (stderr, - "Upload failed to complete -- last event: %u\n", lastEvent); + fprintf (stderr, "Upload failed to complete -- last event: %u\n", + lastEvent); } CHECK (prog < 10000); GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS); @@ -211,9 +209,8 @@ main (int argc, char *argv[]) CHECK (NULL != search); GNUNET_FSUI_search_pause (search); GNUNET_FSUI_search_restart (search); - while ((uri == NULL) && - (availability < 3) && - (rank != 2) && (GNUNET_shutdown_test () != GNUNET_YES)) + while ((uri == NULL) && (availability < 3) && (rank != 2) && + (GNUNET_shutdown_test () != GNUNET_YES)) { prog++; CHECK (prog < 10000); diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c index e38a4b965..c65ad2fc1 100644 --- a/src/fs/test_fs_start_stop.c +++ b/src/fs/test_fs_start_stop.c @@ -56,12 +56,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -77,8 +78,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -89,17 +89,14 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_FS_Handle *fs; setup_peer (&p1, "test_fs_data.conf"); - fs = GNUNET_FS_start (cfg, - "test-fs-start-stop", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); GNUNET_FS_stop (fs); } @@ -128,9 +125,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-start-stop", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-start-stop", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/"); return 0; diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index 9aa7b2ee3..458d4606b 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.c @@ -56,8 +56,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } else { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Finished download, shutting down\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", (unsigned long long) FILESIZE); } GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); @@ -74,10 +73,10 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) ret = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Downloading %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_download (daemons[0], - TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + (unsigned long long) FILESIZE); + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, + NULL); } @@ -91,11 +90,9 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_now (&do_stop, NULL); return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_publish (daemons[0], - TIMEOUT, - 1, GNUNET_NO, FILESIZE, SEED, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + (unsigned long long) FILESIZE); + GNUNET_FS_TEST_publish (daemons[0], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, &do_download, NULL); } @@ -112,19 +109,17 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (daemons[0], - daemons[1], TIMEOUT, &do_publish, NULL); + GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, + NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", - TIMEOUT, - NUM_DAEMONS, daemons, &do_connect, NULL); + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, + daemons, &do_connect, NULL); } @@ -152,8 +147,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-test-lib", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-test-lib", "nohelp", options, &run, NULL); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); return ret; } diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index 70a9e0bcf..177b687ca 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c @@ -100,16 +100,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); start = GNUNET_TIME_absolute_get (); unindex = GNUNET_FS_unindex_start (fs, fn, "unindex"); GNUNET_assert (unindex != NULL); @@ -118,8 +118,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) printf ("Unindex complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -130,25 +130,21 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.unindex.completed, (unsigned long long) event->value.unindex.size, event->value.unindex.specifics.progress.depth, - (unsigned long long) event->value.unindex.specifics. - progress.offset); + (unsigned long long) event->value.unindex.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_UNINDEX_ERROR: - fprintf (stderr, - "Error unindexing file: %s\n", + fprintf (stderr, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_START: @@ -174,8 +170,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -191,12 +186,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -212,8 +208,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -224,9 +219,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { const char *keywords[] = { "down_foo", @@ -241,18 +235,14 @@ run (void *cls, setup_peer (&p1, "test_fs_unindex_data.conf"); fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); - fs = GNUNET_FS_start (cfg, - "test-fs-unindex", - &progress_cb, - NULL, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); + fs = GNUNET_FS_start (cfg, "test-fs-unindex", &progress_cb, NULL, + GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -262,19 +252,16 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_file (fs, - "publish-context", - fn, - kuri, - meta, GNUNET_YES, &bo); + fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn, + kuri, meta, GNUNET_YES, + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -302,8 +289,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-unindex", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-unindex", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); if (NULL != fn) diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index 191dec57d..4fcd1445f 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c @@ -102,10 +102,7 @@ static void restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_FS_stop (fs); - fs = GNUNET_FS_start (cfg, - "test-fs-unindex-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); } @@ -144,16 +141,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.publish.completed, (unsigned long long) event->value.publish.size, event->value.publish.specifics.progress.depth, - (unsigned long long) event->value.publish.specifics. - progress.offset); + (unsigned long long) event->value.publish.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: printf ("Publishing complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); start = GNUNET_TIME_absolute_get (); unindex = GNUNET_FS_unindex_start (fs, fn, "unindex"); GNUNET_assert (unindex != NULL); @@ -162,8 +159,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) printf ("Unindex complete, %llu kbps.\n", (unsigned long long) (FILESIZE * 1000 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value) / 1024)); + GNUNET_TIME_absolute_get_duration (start). + rel_value) / 1024)); GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; @@ -175,8 +172,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) (unsigned long long) event->value.unindex.completed, (unsigned long long) event->value.unindex.size, event->value.unindex.specifics.progress.depth, - (unsigned long long) event->value.unindex.specifics. - progress.offset); + (unsigned long long) event->value.unindex.specifics.progress. + offset); #endif break; case GNUNET_FS_STATUS_PUBLISH_SUSPEND: @@ -199,20 +196,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) unindex = event->value.unindex.uc; return "unindex"; case GNUNET_FS_STATUS_PUBLISH_ERROR: - fprintf (stderr, - "Error publishing file: %s\n", + fprintf (stderr, "Error publishing file: %s\n", event->value.publish.specifics.error.message); GNUNET_break (0); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_UNINDEX_ERROR: - fprintf (stderr, - "Error unindexing file: %s\n", + fprintf (stderr, "Error unindexing file: %s\n", event->value.unindex.specifics.error.message); - GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; case GNUNET_FS_STATUS_PUBLISH_START: @@ -239,8 +232,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) break; case GNUNET_FS_STATUS_UNINDEX_STOPPED: GNUNET_assert (unindex == event->value.unindex.uc); - GNUNET_SCHEDULER_add_continuation (&abort_publish_task, - NULL, + GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); break; default: @@ -256,12 +248,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); } @@ -277,8 +270,7 @@ stop_arm (struct PeerContext *p) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -289,9 +281,8 @@ stop_arm (struct PeerContext *p) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { const char *keywords[] = { "down_foo", @@ -307,19 +298,14 @@ run (void *cls, cfg = c; setup_peer (&p1, "test_fs_unindex_data.conf"); fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); - fs = GNUNET_FS_start (cfg, - "test-fs-unindex-persistence", - &progress_cb, - NULL, + fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); GNUNET_assert (NULL != fs); buf = GNUNET_malloc (FILESIZE); for (i = 0; i < FILESIZE; i++) buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); GNUNET_assert (FILESIZE == - GNUNET_DISK_fn_write (fn, - buf, - FILESIZE, + GNUNET_DISK_fn_write (fn, buf, FILESIZE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_free (buf); @@ -329,19 +315,16 @@ run (void *cls, bo.anonymity_level = 1; bo.replication_level = 0; bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); - fi = GNUNET_FS_file_information_create_from_file (fs, - "publish-context", - fn, - kuri, - meta, GNUNET_YES, &bo); + fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn, + kuri, meta, GNUNET_YES, + &bo); GNUNET_FS_uri_destroy (kuri); GNUNET_CONTAINER_meta_data_destroy (meta); GNUNET_assert (NULL != fi); start = GNUNET_TIME_absolute_get (); - publish = GNUNET_FS_publish_start (fs, - fi, - NULL, NULL, NULL, - GNUNET_FS_PUBLISH_OPTION_NONE); + publish = + GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, + GNUNET_FS_PUBLISH_OPTION_NONE); GNUNET_assert (publish != NULL); } @@ -369,8 +352,8 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-fs-unindex", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-fs-unindex", "nohelp", options, &run, NULL); stop_arm (&p1); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); if (NULL != fn) diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c index e8f6ed70f..d226147f9 100644 --- a/src/fs/test_fs_uri.c +++ b/src/fs/test_fs_uri.c @@ -209,8 +209,9 @@ testNamespace (int i) } uri = GNUNET_FS_uri_to_string (ret); - if (0 != strcmp (uri, - "gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test")) + if (0 != + strcmp (uri, + "gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test")) { GNUNET_FS_uri_destroy (ret); GNUNET_free (uri); @@ -284,8 +285,9 @@ testFile (int i) } uri = GNUNET_FS_uri_to_string (ret); - if (0 != strcmp (uri, - "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42")) + if (0 != + strcmp (uri, + "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42")) { GNUNET_free (uri); GNUNET_FS_uri_destroy (ret); diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index 9a209521f..a5570e1d4 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c @@ -69,8 +69,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1000LL / del.rel_value); fprintf (stdout, "Download speed was %s/s\n", fancy); GNUNET_free (fancy); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Finished download, shutting down\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", (unsigned long long) FILESIZE); } else @@ -90,17 +89,17 @@ do_download (void *cls, const char *emsg) if (emsg != NULL) { GNUNET_FS_TEST_daemons_stop (2, daemons); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Failed to stop source daemon: %s\n", emsg); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n", + emsg); GNUNET_FS_uri_destroy (uri); ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Downloading %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); - GNUNET_FS_TEST_download (daemons[0], - TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, + NULL); GNUNET_FS_uri_destroy (uri); } @@ -147,11 +146,9 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_publish (daemons[1], - TIMEOUT, - 1, GNUNET_NO, FILESIZE, SEED, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + (unsigned long long) FILESIZE); + GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, &do_wait, NULL); } @@ -168,15 +165,14 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (daemons[0], - daemons[1], TIMEOUT, &do_publish, NULL); + GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, + NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_FS_TEST_daemons_start ("test_gnunet_service_fs_migration_data.conf", TIMEOUT, 2, daemons, &do_connect, NULL); @@ -207,9 +203,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-gnunet-service-fs-migration", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-gnunet-service-fs-migration", "nohelp", options, + &run, NULL); GNUNET_DISK_directory_remove ("/tmp/test-gnunet-service-fs-migration/"); return ok; } diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index c48f98666..aece0e80a 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -65,8 +65,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1000LL / del.rel_value); fprintf (stdout, "Download speed was %s/s\n", fancy); GNUNET_free (fancy); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Finished download, shutting down\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", (unsigned long long) FILESIZE); } else @@ -89,11 +88,11 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Downloading %llu bytes\n", (unsigned long long) FILESIZE); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", + (unsigned long long) FILESIZE); start_time = GNUNET_TIME_absolute_get (); - GNUNET_FS_TEST_download (daemons[0], - TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, NULL); + GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, + NULL); } @@ -108,11 +107,9 @@ do_publish (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ok = 1; return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Publishing %llu bytes\n", (unsigned long long) FILESIZE); - GNUNET_FS_TEST_publish (daemons[1], - TIMEOUT, - 1, GNUNET_NO, FILESIZE, SEED, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", + (unsigned long long) FILESIZE); + GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, VERBOSE, &do_download, NULL); } @@ -123,19 +120,17 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - GNUNET_FS_TEST_daemons_connect (daemons[0], - daemons[1], TIMEOUT, &do_publish, NULL); + GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, + NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", - TIMEOUT, - NUM_DAEMONS, daemons, &do_connect, NULL); + GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, + daemons, &do_connect, NULL); } @@ -163,9 +158,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, - argvx, "test-gnunet-service-fs-p2p", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, + "test-gnunet-service-fs-p2p", "nohelp", options, &run, + NULL); GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); return ok; } diff --git a/src/hello/hello.c b/src/hello/hello.c index 0df888c21..5d64d8f5a 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -77,8 +77,8 @@ struct GNUNET_HELLO_Message size_t GNUNET_HELLO_add_address (const char *tname, struct GNUNET_TIME_Absolute expiration, - const void *addr, - uint16_t addr_len, char *target, size_t max) + const void *addr, uint16_t addr_len, char *target, + size_t max) { uint16_t alen; size_t slen; @@ -245,9 +245,9 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, memcpy (&expire, &inptr[esize - alen - sizeof (struct GNUNET_TIME_AbsoluteNBO)], sizeof (struct GNUNET_TIME_AbsoluteNBO)); - iret = it (it_cls, - inptr, - GNUNET_TIME_absolute_ntoh (expire), &inptr[esize - alen], alen); + iret = + it (it_cls, inptr, GNUNET_TIME_absolute_ntoh (expire), + &inptr[esize - alen], alen); if (iret == GNUNET_SYSERR) { if (ret != NULL) @@ -280,15 +280,13 @@ struct ExpireContext static int -get_match_exp (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +get_match_exp (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct ExpireContext *ec = cls; - if ((addrlen == ec->addrlen) && - (0 == memcmp (addr, ec->addr, addrlen)) && + if ((addrlen == ec->addrlen) && (0 == memcmp (addr, ec->addr, addrlen)) && (0 == strcmp (tname, ec->tname))) { ec->found = GNUNET_YES; @@ -313,10 +311,9 @@ struct MergeContext static int -copy_latest (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +copy_latest (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct MergeContext *mc = cls; struct ExpireContext ec; @@ -331,11 +328,9 @@ copy_latest (void *cls, ((ec.expiration.abs_value == expiration.abs_value) && (mc->take_equal == GNUNET_YES))) { - mc->ret += GNUNET_HELLO_add_address (tname, - expiration, - addr, - addrlen, - &mc->buf[mc->ret], mc->max - mc->ret); + mc->ret += + GNUNET_HELLO_add_address (tname, expiration, addr, addrlen, + &mc->buf[mc->ret], mc->max - mc->ret); } return GNUNET_OK; } @@ -394,10 +389,9 @@ struct DeltaContext static int -delta_match (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +delta_match (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct DeltaContext *dc = cls; int ret; @@ -407,8 +401,8 @@ delta_match (void *cls, ec.addrlen = addrlen; ec.found = GNUNET_NO; ec.tname = tname; - GNUNET_HELLO_iterate_addresses (dc->old_hello, - GNUNET_NO, &get_match_exp, &ec); + GNUNET_HELLO_iterate_addresses (dc->old_hello, GNUNET_NO, &get_match_exp, + &ec); if ((ec.found == GNUNET_YES) && ((ec.expiration.abs_value > expiration.abs_value) || (ec.expiration.abs_value >= dc->expiration_limit.abs_value))) @@ -553,18 +547,16 @@ struct EqualsContext static int -find_other_matching (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +find_other_matching (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct EqualsContext *ec = cls; if (expiration.abs_value < ec->expiration_limit.abs_value) return GNUNET_YES; - if ((addrlen == ec->addrlen) && - (0 == strcmp (tname, - ec->tname)) && (0 == memcmp (addr, ec->addr, addrlen))) + if ((addrlen == ec->addrlen) && (0 == strcmp (tname, ec->tname)) && + (0 == memcmp (addr, ec->addr, addrlen))) { ec->found = GNUNET_YES; if (expiration.abs_value < ec->expiration.abs_value) @@ -576,10 +568,9 @@ find_other_matching (void *cls, static int -find_matching (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +find_matching (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct EqualsContext *ec = cls; @@ -616,16 +607,15 @@ find_matching (void *cls, * do not match at all */ struct GNUNET_TIME_Absolute -GNUNET_HELLO_equals (const struct - GNUNET_HELLO_Message *h1, - const struct - GNUNET_HELLO_Message *h2, struct GNUNET_TIME_Absolute now) +GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, + const struct GNUNET_HELLO_Message *h2, + struct GNUNET_TIME_Absolute now) { struct EqualsContext ec; - if (0 != memcmp (&h1->publicKey, - &h2->publicKey, - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) + if (0 != + memcmp (&h1->publicKey, &h2->publicKey, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) return GNUNET_TIME_UNIT_ZERO_ABS; ec.expiration_limit = now; ec.result = GNUNET_TIME_UNIT_FOREVER_ABS; diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c index b6a9dc681..c9bf96791 100644 --- a/src/hello/test_hello.c +++ b/src/hello/test_hello.c @@ -41,19 +41,18 @@ my_addr_gen (void *cls, size_t max, void *buf) #endif if (0 == *i) return 0; - ret = GNUNET_HELLO_add_address ("test", - GNUNET_TIME_absolute_get (), - "address_information", *i, buf, max); + ret = + GNUNET_HELLO_add_address ("test", GNUNET_TIME_absolute_get (), + "address_information", *i, buf, max); (*i)--; return ret; } static int -check_addr (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +check_addr (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { unsigned int *i = cls; @@ -71,10 +70,9 @@ check_addr (void *cls, static int -remove_some (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +remove_some (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { unsigned int *i = cls; @@ -118,8 +116,8 @@ main (int argc, char *argv[]) fprintf (stderr, "Testing address iteration (empty set)...\n"); #endif GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (msg1, - GNUNET_NO, &check_addr, &i)); + GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr, + &i)); #if VERBOSE fprintf (stderr, "Testing HELLO creation (with one address)...\n"); @@ -134,8 +132,8 @@ main (int argc, char *argv[]) #endif i = 1; GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (msg2, - GNUNET_NO, &check_addr, &i)); + GNUNET_HELLO_iterate_addresses (msg2, GNUNET_NO, &check_addr, + &i)); GNUNET_assert (i == 0); #if VERBOSE @@ -158,8 +156,8 @@ main (int argc, char *argv[]) #endif i = 3; GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (msg3, - GNUNET_NO, &check_addr, &i)); + GNUNET_HELLO_iterate_addresses (msg3, GNUNET_NO, &check_addr, + &i)); GNUNET_assert (i == 0); #if VERBOSE @@ -170,8 +168,8 @@ main (int argc, char *argv[]) i = 3; GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (msg1, - GNUNET_NO, &check_addr, &i)); + GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr, + &i)); GNUNET_assert (i == 0); GNUNET_free (msg1); @@ -184,8 +182,8 @@ main (int argc, char *argv[]) GNUNET_assert (i == 0); i = 1; GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (msg1, - GNUNET_NO, &check_addr, &i)); + GNUNET_HELLO_iterate_addresses (msg1, GNUNET_NO, &check_addr, + &i)); GNUNET_assert (i == 0); GNUNET_free (msg1); @@ -193,8 +191,8 @@ main (int argc, char *argv[]) fprintf (stderr, "Testing delta address iteration...\n"); #endif i = 2; - GNUNET_HELLO_iterate_new_addresses (msg3, - msg2, startup_time, &check_addr, &i); + GNUNET_HELLO_iterate_new_addresses (msg3, msg2, startup_time, &check_addr, + &i); GNUNET_assert (i == 0); GNUNET_free (msg2); GNUNET_free (msg3); diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index c49aec765..9d47dfa9c 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -128,8 +128,7 @@ struct GNUNET_HOSTLIST_ADV_Message static struct GNUNET_PeerIdentity me; static void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -140,8 +139,7 @@ core_init (void *cls, * Core handler for p2p hostlist advertisements */ static int -advertisement_handler (void *cls, - const struct GNUNET_PeerIdentity *peer, +advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -158,9 +156,7 @@ advertisement_handler (void *cls, * @param atsi performance data */ static void -connect_handler (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity))) @@ -236,9 +232,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param cfg configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { static const struct GNUNET_CORE_MessageHandler learn_handlers[] = { {&advertisement_handler, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0}, @@ -263,20 +258,16 @@ run (void *cls, stats = GNUNET_STATISTICS_create ("hostlist", cfg); - core = GNUNET_CORE_connect (cfg, - 1, - NULL, - &core_init, - &connect_handler, &disconnect_handler, NULL, - NULL, GNUNET_NO, - NULL, GNUNET_NO, - learning ? learn_handlers : no_learn_handlers); + core = + GNUNET_CORE_connect (cfg, 1, NULL, &core_init, &connect_handler, + &disconnect_handler, NULL, NULL, GNUNET_NO, NULL, + GNUNET_NO, + learning ? learn_handlers : no_learn_handlers); if (bootstrapping) { - GNUNET_HOSTLIST_client_start (cfg, stats, - &client_ch, &client_dh, &client_adv_handler, - learning); + GNUNET_HOSTLIST_client_start (cfg, stats, &client_ch, &client_dh, + &client_adv_handler, learning); } #if HAVE_MHD @@ -286,8 +277,8 @@ run (void *cls, advertising); } #endif - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleaning_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, + NULL); if (NULL == core) { @@ -333,12 +324,11 @@ main (int argc, char *const *argv) int ret; GNUNET_log_setup ("hostlist", "WARNING", NULL); - ret = (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "hostlist", - _("GNUnet hostlist server and client"), - options, &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_PROGRAM_run (argc, argv, "hostlist", + _("GNUnet hostlist server and client"), options, + &run, NULL)) ? 0 : 1; return ret; } diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 422855f0e..c049dceea 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -366,8 +366,8 @@ get_bootstrap_server () size_t pos; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "HOSTLIST", "SERVERS", &servers)) + GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "SERVERS", + &servers)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -453,8 +453,8 @@ download_get_url () current_hostlist = NULL; return get_bootstrap_server (); } - index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - linked_list_size); + index = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, linked_list_size); counter = 0; pos = linked_list_head; while (counter < index) @@ -462,8 +462,8 @@ download_get_url () pos = pos->next; counter++; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Using learned hostlist `%s'\n", pos->hostlist_uri); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using learned hostlist `%s'\n", + pos->hostlist_uri); current_hostlist = pos; return strdup (pos->hostlist_uri); } @@ -585,11 +585,10 @@ insert_hostlist () linked_list_size--; GNUNET_free (lowest_quality); } - GNUNET_CONTAINER_DLL_insert (linked_list_head, - linked_list_tail, hostlist_to_test); + GNUNET_CONTAINER_DLL_insert (linked_list_head, linked_list_tail, + hostlist_to_test); linked_list_size++; - GNUNET_STATISTICS_set (stats, - gettext_noop ("# advertised hostlist URIs"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# advertised hostlist URIs"), linked_list_size, GNUNET_NO); stat_testing_hostlist = GNUNET_NO; } @@ -679,15 +678,13 @@ clean_up () mret = curl_multi_remove_handle (multi, curl); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_remove_handle", __FILE__, __LINE__, curl_multi_strerror (mret)); } mret = curl_multi_cleanup (multi); if (mret != CURLM_OK) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_cleanup", __FILE__, __LINE__, curl_multi_strerror (mret)); multi = NULL; @@ -711,8 +708,8 @@ clean_up () * @param cls closure, unused * @param tc task context, unused */ -static void -task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void task_download (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -739,8 +736,7 @@ download_prepare () mret = curl_multi_fdset (multi, &rs, &ws, &es, &max); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_fdset", __FILE__, __LINE__, curl_multi_strerror (mret)); clean_up (); @@ -749,8 +745,7 @@ download_prepare () mret = curl_multi_timeout (multi, &timeout); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_timeout", __FILE__, __LINE__, curl_multi_strerror (mret)); clean_up (); @@ -768,10 +763,10 @@ download_prepare () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling task for hostlist download using cURL\n"); #endif - ti_download - = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, - rtime, grs, gws, &task_download, multi); + ti_download = + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_NO_TASK, rtime, grs, gws, + &task_download, multi); GNUNET_NETWORK_fdset_destroy (gws); GNUNET_NETWORK_fdset_destroy (grs); } @@ -844,10 +839,8 @@ task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (msg->data.result != CURLE_GOT_NOTHING)) GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%s failed for `%s' at %s:%d: `%s'\n"), - "curl_multi_perform", - current_url, - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); + "curl_multi_perform", current_url, __FILE__, __LINE__, + curl_easy_strerror (msg->data.result)); else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -880,8 +873,7 @@ task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%s failed at %s:%d: `%s'\n"), "curl_multi_perform", __FILE__, __LINE__, curl_multi_strerror (mret)); clean_up (); @@ -921,8 +913,8 @@ download_hostlist () stat_bytes_downloaded = 0; GNUNET_STATISTICS_update (stats, - gettext_noop ("# hostlist downloads initiated"), - 1, GNUNET_NO); + gettext_noop ("# hostlist downloads initiated"), 1, + GNUNET_NO); if (proxy != NULL) CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy); download_pos = 0; @@ -971,14 +963,12 @@ download_hostlist () mret = curl_multi_add_handle (multi, curl); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_add_handle", __FILE__, __LINE__, curl_multi_strerror (mret)); mret = curl_multi_cleanup (multi); if (mret != CURLM_OK) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_cleanup", __FILE__, __LINE__, curl_multi_strerror (mret)); multi = NULL; @@ -1104,8 +1094,9 @@ task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlists will be saved to file again in %llums\n"), (unsigned long long) SAVING_INTERVALL.rel_value); - ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, - &task_hostlist_saving, NULL); + ti_saving_task = + GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, + NULL); } @@ -1117,16 +1108,13 @@ task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param atsi performance data */ static void -handler_connect (void *cls, - const struct - GNUNET_PeerIdentity *peer, +handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { GNUNET_assert (stat_connection_count < UINT_MAX); stat_connection_count++; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# active connections"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), 1, + GNUNET_NO); } @@ -1141,9 +1129,8 @@ handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) { GNUNET_assert (stat_connection_count > 0); stat_connection_count--; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# active connections"), - -1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# active connections"), -1, + GNUNET_NO); } @@ -1158,8 +1145,7 @@ handler_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) * GNUNET_SYSERR to close it (signal serious error) */ static int -handler_advertisement (void *cls, - const struct GNUNET_PeerIdentity *peer, +handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1217,9 +1203,9 @@ handler_advertisement (void *cls, stat_testing_hostlist = GNUNET_YES; stat_testing_allowed = GNUNET_NO; - ti_testing_intervall_task = GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL, - &task_testing_intervall_reset, - NULL); + ti_testing_intervall_task = + GNUNET_SCHEDULER_add_delayed (TESTING_INTERVAL, + &task_testing_intervall_reset, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing new hostlist advertisements is locked for the next %u ms\n", @@ -1255,9 +1241,8 @@ primary_task (void *cls, int success) static int -process_stat (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +process_stat (void *cls, const char *subsystem, const char *name, + uint64_t value, int is_persistent) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Initial time between hostlist downloads is %llums\n"), @@ -1286,9 +1271,8 @@ load_hostlist_file () uint32_t counter; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "HOSTLIST", - "HOSTLISTFILE", &filename)) + GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", + &filename)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -1321,9 +1305,8 @@ load_hostlist_file () counter = 0; while ((GNUNET_OK == GNUNET_BIO_read_string (rh, "url", &uri, MAX_URL_LEN)) && - (NULL != uri) && - (GNUNET_OK == GNUNET_BIO_read_int32 (rh, ×_used)) && - (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &quality)) && + (NULL != uri) && (GNUNET_OK == GNUNET_BIO_read_int32 (rh, ×_used)) + && (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &quality)) && (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &last_used)) && (GNUNET_OK == GNUNET_BIO_read_int64 (rh, &created)) && (GNUNET_OK == GNUNET_BIO_read_int32 (rh, &hellos_returned))) @@ -1347,13 +1330,11 @@ load_hostlist_file () break; } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("%u hostlist URIs loaded from file\n"), counter); - GNUNET_STATISTICS_set (stats, - gettext_noop ("# hostlist URIs read from file"), + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("%u hostlist URIs loaded from file\n"), + counter); + GNUNET_STATISTICS_set (stats, gettext_noop ("# hostlist URIs read from file"), counter, GNUNET_YES); - GNUNET_STATISTICS_set (stats, - gettext_noop ("# advertised hostlist URIs"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# advertised hostlist URIs"), linked_list_size, GNUNET_NO); GNUNET_free_non_null (uri); @@ -1379,9 +1360,8 @@ save_hostlist_file (int shutdown) uint32_t counter; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "HOSTLIST", - "HOSTLISTFILE", &filename)) + GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE", + &filename)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -1404,8 +1384,7 @@ save_hostlist_file (int shutdown) GNUNET_free (filename); return; } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Writing %u hostlist URIs to `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Writing %u hostlist URIs to `%s'\n"), linked_list_size, filename); /* add code to write hostlists to file using bio */ ok = GNUNET_YES; @@ -1419,12 +1398,9 @@ save_hostlist_file (int shutdown) } if (GNUNET_YES == ok) { - if ((GNUNET_OK != - GNUNET_BIO_write_string (wh, pos->hostlist_uri)) || - (GNUNET_OK != - GNUNET_BIO_write_int32 (wh, pos->times_used)) || - (GNUNET_OK != - GNUNET_BIO_write_int64 (wh, pos->quality)) || + if ((GNUNET_OK != GNUNET_BIO_write_string (wh, pos->hostlist_uri)) || + (GNUNET_OK != GNUNET_BIO_write_int32 (wh, pos->times_used)) || + (GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->quality)) || (GNUNET_OK != GNUNET_BIO_write_int64 (wh, pos->time_last_usage.abs_value)) || (GNUNET_OK != @@ -1480,8 +1456,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, cfg = c; stats = st; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "HOSTLIST", "HTTP-PROXY", &proxy)) + GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "HTTP-PROXY", + &proxy)) proxy = NULL; stat_learning = learn; *ch = &handler_connect; @@ -1501,18 +1477,18 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlists will be saved to file again in %llums\n"), (unsigned long long) SAVING_INTERVALL.rel_value); - ti_saving_task = GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, - &task_hostlist_saving, NULL); + ti_saving_task = + GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving, + NULL); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Learning is not enabled on this peer\n")); *msgh = NULL; - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, - "HOSTLIST", - "HOSTLISTFILE", - &filename)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", + "HOSTLISTFILE", &filename)) { if (GNUNET_YES == GNUNET_DISK_file_test (filename)) { @@ -1529,8 +1505,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, } GNUNET_free (filename); } - GNUNET_STATISTICS_get (stats, - "hostlist", + GNUNET_STATISTICS_get (stats, "hostlist", gettext_noop ("# milliseconds between hostlist downloads"), GNUNET_TIME_UNIT_MINUTES, &primary_task, &process_stat, diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index e30b3c1e0..e48b6a4ac 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -123,15 +123,15 @@ finish_response (struct HostSet *results) "Creating hostlist response with %u bytes\n", (unsigned int) results->size); #endif - response = MHD_create_response_from_data (results->size, - results->data, MHD_YES, MHD_NO); + response = + MHD_create_response_from_data (results->size, results->data, MHD_YES, + MHD_NO); if ((daemon_handle_v4 == NULL) && (daemon_handle_v6 == NULL)) { MHD_destroy_response (response); response = NULL; } - GNUNET_STATISTICS_set (stats, - gettext_noop ("bytes in hostlist"), + GNUNET_STATISTICS_set (stats, gettext_noop ("bytes in hostlist"), results->size, GNUNET_YES); GNUNET_free (results); } @@ -148,18 +148,17 @@ finish_response (struct HostSet *results) * @return GNUNET_SYSERR to stop iterating (unless expiration has occured) */ static int -check_has_addr (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +check_has_addr (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { int *arg = cls; if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) { GNUNET_STATISTICS_update (stats, - gettext_noop ("expired addresses encountered"), - 1, GNUNET_YES); + gettext_noop ("expired addresses encountered"), 1, + GNUNET_YES); return GNUNET_YES; /* ignore this address */ } *arg = GNUNET_YES; @@ -172,8 +171,7 @@ check_has_addr (void *cls, * hostlist response construction. */ static void -host_processor (void *cls, - const struct GNUNET_PeerIdentity *peer, +host_processor (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { struct HostSet *results = cls; @@ -229,8 +227,8 @@ host_processor (void *cls, } #if DEBUG_HOSTLIST_SERVER GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Adding peer `%s' to hostlist (%u bytes)\n", - GNUNET_i2s (peer), (unsigned int) s); + "Adding peer `%s' to hostlist (%u bytes)\n", GNUNET_i2s (peer), + (unsigned int) s); #endif GNUNET_array_grow (results->data, results->size, old + s); memcpy (&results->data[old], hello, s); @@ -242,8 +240,8 @@ host_processor (void *cls, * Hostlist access policy (very permissive, allows everything). */ static int -accept_policy_callback (void *cls, - const struct sockaddr *addr, socklen_t addrlen) +accept_policy_callback (void *cls, const struct sockaddr *addr, + socklen_t addrlen) { if (NULL == response) { @@ -261,12 +259,9 @@ accept_policy_callback (void *cls, * Main request handler. */ static int -access_handler_callback (void *cls, - struct MHD_Connection *connection, - const char *url, - const char *method, - const char *version, - const char *upload_data, +access_handler_callback (void *cls, struct MHD_Connection *connection, + const char *url, const char *method, + const char *version, const char *upload_data, size_t * upload_data_size, void **con_cls) { static int dummy; @@ -312,8 +307,7 @@ access_handler_callback (void *cls, return MHD_NO; /* internal error, no response yet */ } GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Received request for our hostlist\n")); - GNUNET_STATISTICS_update (stats, - gettext_noop ("hostlist requests processed"), + GNUNET_STATISTICS_update (stats, gettext_noop ("hostlist requests processed"), 1, GNUNET_YES); return MHD_queue_response (connection, MHD_HTTP_OK, response); } @@ -353,11 +347,11 @@ adv_transmit_ready (void *cls, size_t size, void *buf) "Sent advertisement message: Copied %u bytes into buffer!\n", (unsigned int) transmission_size); hostlist_adv_count++; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " # Sent advertisement message: %u\n", hostlist_adv_count); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " # Sent advertisement message: %u\n", + hostlist_adv_count); GNUNET_STATISTICS_update (stats, - gettext_noop ("# hostlist advertisements send"), - 1, GNUNET_NO); + gettext_noop ("# hostlist advertisements send"), 1, + GNUNET_NO); return transmission_size; } @@ -370,9 +364,7 @@ adv_transmit_ready (void *cls, size_t size, void *buf) * @param atsi performance data */ static void -connect_handler (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { size_t size; @@ -397,13 +389,10 @@ connect_handler (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked core to transmit advertisement message with a size of %u bytes to peer `%s'\n", size, GNUNET_i2s (peer)); - if (NULL == GNUNET_CORE_notify_transmit_ready (core, - GNUNET_YES, - 0, - GNUNET_ADV_TIMEOUT, - peer, - size, - &adv_transmit_ready, NULL)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 0, + GNUNET_ADV_TIMEOUT, peer, size, + &adv_transmit_ready, NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Advertisement message could not be queued by core\n")); @@ -433,8 +422,7 @@ disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer) * @param err_msg NULL if successful, otherwise contains error message */ static void -process_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { struct HostSet *results; @@ -451,18 +439,17 @@ process_notify (void *cls, } results = GNUNET_malloc (sizeof (struct HostSet)); GNUNET_assert (peerinfo != NULL); - pitr = GNUNET_PEERINFO_iterate (peerinfo, - NULL, - GNUNET_TIME_UNIT_MINUTES, - &host_processor, results); + pitr = + GNUNET_PEERINFO_iterate (peerinfo, NULL, GNUNET_TIME_UNIT_MINUTES, + &host_processor, results); } /** * Function that queries MHD's select sets and * starts the task waiting for them. */ -static GNUNET_SCHEDULER_TaskIdentifier -prepare_daemon (struct MHD_Daemon *daemon_handle); +static GNUNET_SCHEDULER_TaskIdentifier prepare_daemon (struct MHD_Daemon + *daemon_handle); /** @@ -524,9 +511,10 @@ prepare_daemon (struct MHD_Daemon *daemon_handle) GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1); GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1); - ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_TASK, - tv, wrs, wws, &run_daemon, daemon_handle); + ret = + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH, + GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + &run_daemon, daemon_handle); GNUNET_NETWORK_fdset_destroy (wrs); GNUNET_NETWORK_fdset_destroy (wws); GNUNET_NETWORK_fdset_destroy (wes); @@ -568,9 +556,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, _("Could not access PEERINFO service. Exiting.\n")); return GNUNET_SYSERR; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, - "HOSTLIST", - "HTTPPORT", &port)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "HOSTLIST", "HTTPPORT", + &port)) return GNUNET_SYSERR; if ((port == 0) || (port > UINT16_MAX)) { @@ -579,14 +567,13 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, return GNUNET_SYSERR; } - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, - "HOSTLIST", - "EXTERNAL_DNS_NAME", - &hostname)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", + "EXTERNAL_DNS_NAME", &hostname)) hostname = GNUNET_RESOLVER_local_fqdn_get (); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Hostlist service starts on %s:%llu\n"), hostname, port); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Hostlist service starts on %s:%llu\n"), + hostname, port); if (NULL != hostname) { size = strlen (hostname); @@ -596,8 +583,8 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, } else { - GNUNET_asprintf (&hostlist_uri, - "http://%s:%u/", hostname, (unsigned int) port); + GNUNET_asprintf (&hostlist_uri, "http://%s:%u/", hostname, + (unsigned int) port); GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Address to obtain hostlist: `%s'\n"), hostlist_uri); } @@ -607,12 +594,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, #if DEBUG_HOSTLIST_SERVER | MHD_USE_DEBUG #endif - , - (unsigned short) port, - &accept_policy_callback, - NULL, - &access_handler_callback, - NULL, + , (unsigned short) port, + &accept_policy_callback, NULL, + &access_handler_callback, NULL, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16, MHD_OPTION_PER_IP_CONNECTION_LIMIT, @@ -625,12 +609,9 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, #if DEBUG_HOSTLIST_SERVER | MHD_USE_DEBUG #endif - , - (unsigned short) port, - &accept_policy_callback, - NULL, - &access_handler_callback, - NULL, + , (unsigned short) port, + &accept_policy_callback, NULL, + &access_handler_callback, NULL, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 16, MHD_OPTION_PER_IP_CONNECTION_LIMIT, diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 5cca8becd..909b946e7 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c @@ -95,8 +95,7 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param distance in overlay hops, as given by transport plugin */ static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -129,16 +128,17 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, - ¬ify_connect, NULL); + p->th = + GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); GNUNET_assert (p->th != NULL); GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } @@ -155,8 +155,7 @@ waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -185,15 +184,14 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); ok++; timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); } @@ -213,9 +211,9 @@ check () GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-gnunet-daemon-hostlist", - "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-gnunet-daemon-hostlist", "nohelp", options, &run, + &ok); return ok; } diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index 7ecca8a85..2538e42fb 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -182,9 +182,8 @@ process_downloads_done (void *cls, int success) static int -process_downloads (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +process_downloads (void *cls, const char *subsystem, const char *name, + uint64_t value, int is_persistent) { if ((value >= 2) && (learned_hostlist_downloaded == GNUNET_NO)) { @@ -206,12 +205,11 @@ process_uris_recv_done (void *cls, int success) static int -process_uris_recv (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +process_uris_recv (void *cls, const char *subsystem, const char *name, + uint64_t value, int is_persistent) { - if (((struct PeerContext *) cls == &learn_peer) && - (value == 1) && (learned_hostlist_saved == GNUNET_NO)) + if (((struct PeerContext *) cls == &learn_peer) && (value == 1) && + (learned_hostlist_saved == GNUNET_NO)) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer has successfully saved advertised URI\n"); @@ -231,9 +229,8 @@ process_adv_sent_done (void *cls, int success) static int -process_adv_sent (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +process_adv_sent (void *cls, const char *subsystem, const char *name, + uint64_t value, int is_persistent) { if ((value >= 1) && (adv_sent == GNUNET_NO)) { @@ -259,44 +256,39 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) check_task = GNUNET_SCHEDULER_NO_TASK; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; - GNUNET_asprintf (&stat, - gettext_noop ("# advertised URI `%s' downloaded"), + GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"), current_adv_uri); if (NULL != learn_peer.stats) { if (NULL != download_stats) GNUNET_STATISTICS_get_cancel (download_stats); - download_stats = GNUNET_STATISTICS_get (learn_peer.stats, - "hostlist", - stat, - GNUNET_TIME_UNIT_MINUTES, - &process_downloads_done, - &process_downloads, &learn_peer); + download_stats = + GNUNET_STATISTICS_get (learn_peer.stats, "hostlist", stat, + GNUNET_TIME_UNIT_MINUTES, + &process_downloads_done, &process_downloads, + &learn_peer); if (NULL != urisrecv_stat) GNUNET_STATISTICS_get_cancel (urisrecv_stat); - urisrecv_stat = GNUNET_STATISTICS_get (learn_peer.stats, - "hostlist", - gettext_noop - ("# advertised hostlist URIs"), - GNUNET_TIME_UNIT_MINUTES, - &process_uris_recv_done, - &process_uris_recv, &learn_peer); + urisrecv_stat = + GNUNET_STATISTICS_get (learn_peer.stats, "hostlist", + gettext_noop ("# advertised hostlist URIs"), + GNUNET_TIME_UNIT_MINUTES, + &process_uris_recv_done, &process_uris_recv, + &learn_peer); } GNUNET_free (stat); if (NULL != adv_peer.stats) { if (NULL != advsent_stat) GNUNET_STATISTICS_get_cancel (advsent_stat); - advsent_stat = GNUNET_STATISTICS_get (adv_peer.stats, - "hostlist", - gettext_noop - ("# hostlist advertisements send"), - GNUNET_TIME_UNIT_MINUTES, - &process_adv_sent_done, - &process_adv_sent, NULL); + advsent_stat = + GNUNET_STATISTICS_get (adv_peer.stats, "hostlist", + gettext_noop ("# hostlist advertisements send"), + GNUNET_TIME_UNIT_MINUTES, &process_adv_sent_done, + &process_adv_sent, NULL); } - check_task = GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, - &check_statistics, NULL); + check_task = + GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, &check_statistics, NULL); } @@ -304,8 +296,7 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Core handler for p2p hostlist advertisements */ static int -ad_arrive_handler (void *cls, - const struct GNUNET_PeerIdentity *peer, +ad_arrive_handler (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -315,22 +306,20 @@ ad_arrive_handler (void *cls, const struct GNUNET_MessageHeader *incoming; const char *end; - if (-1 == GNUNET_CONFIGURATION_get_value_number (adv_peer.cfg, - "HOSTLIST", - "HTTPPORT", &port)) + if (-1 == + GNUNET_CONFIGURATION_get_value_number (adv_peer.cfg, "HOSTLIST", + "HTTPPORT", &port)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not read advertising server's configuration\n"); return GNUNET_SYSERR; } - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg, - "HOSTLIST", - "EXTERNAL_DNS_NAME", - &hostname)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg, "HOSTLIST", + "EXTERNAL_DNS_NAME", &hostname)) hostname = GNUNET_RESOLVER_local_fqdn_get (); - GNUNET_asprintf (&expected_uri, - "http://%s:%u/", + GNUNET_asprintf (&expected_uri, "http://%s:%u/", hostname != NULL ? hostname : "localhost", (unsigned int) port); incoming = (const struct GNUNET_MessageHeader *) message; @@ -379,18 +368,18 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (p->cfg, - "HOSTLIST", - "HOSTLISTFILE", - &filename)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (p->cfg, "HOSTLIST", "HOSTLISTFILE", + &filename)) { if (GNUNET_YES == GNUNET_DISK_file_test (filename)) { @@ -401,13 +390,9 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) } GNUNET_free (filename); } - p->core = GNUNET_CORE_connect (p->cfg, - 1, - NULL, - NULL, - NULL, NULL, NULL, - NULL, GNUNET_NO, - NULL, GNUNET_NO, learn_handlers); + p->core = + GNUNET_CORE_connect (p->cfg, 1, NULL, NULL, NULL, NULL, NULL, NULL, + GNUNET_NO, NULL, GNUNET_NO, learn_handlers); GNUNET_assert (NULL != p->core); p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); GNUNET_assert (NULL != p->stats); @@ -419,12 +404,13 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); @@ -433,9 +419,8 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { timeout = GNUNET_NO; adv_sent = GNUNET_NO; @@ -450,8 +435,8 @@ run (void *cls, setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - check_task = GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, - &check_statistics, NULL); + check_task = + GNUNET_SCHEDULER_add_delayed (CHECK_INTERVALL, &check_statistics, NULL); } @@ -472,9 +457,9 @@ check () GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-gnunet-daemon-hostlist-learning", - "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-gnunet-daemon-hostlist-learning", "nohelp", options, + &run, NULL); failed = GNUNET_NO; if (timeout == GNUNET_YES) { diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index d1227da4c..ff625cf8e 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c @@ -96,8 +96,7 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param distance in overlay hops, as given by transport plugin */ static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -133,16 +132,17 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, - ¬ify_connect, NULL); + p->th = + GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); GNUNET_assert (p->th != NULL); GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } @@ -159,8 +159,7 @@ waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "ARM process %u stopped\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_close (p->arm_proc); p->arm_proc = NULL; @@ -189,15 +188,14 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); ok++; timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_error, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); setup_peer (&p1, "test_gnunet_daemon_hostlist_peer1.conf"); setup_peer (&p2, "test_gnunet_daemon_hostlist_peer2.conf"); } @@ -217,9 +215,9 @@ check () GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-gnunet-daemon-hostlist", - "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-gnunet-daemon-hostlist", "nohelp", options, &run, + &ok); return ok; } diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index de1daecb0..338def09a 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -480,11 +480,9 @@ get_peer_info (const struct GNUNET_PeerIdentity *peer) peer_info = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); if (NULL == peer_info) { - peer_info = (struct MeshPeerInfo *) - GNUNET_malloc (sizeof (struct MeshPeerInfo)); - GNUNET_CONTAINER_multihashmap_put (peers, - &peer->hashPubKey, - peer_info, + peer_info = + (struct MeshPeerInfo *) GNUNET_malloc (sizeof (struct MeshPeerInfo)); + GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, peer_info, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); peer_info->id = GNUNET_PEER_intern (peer); peer_info->state = MESH_PEER_SEARCHING; @@ -591,8 +589,8 @@ add_path_to_peer (struct MeshPeerInfo *peer_info, struct MeshPath *path) if (best_cost < new_cost) { path->in_use = 0; - GNUNET_CONTAINER_DLL_insert_tail (peer_info->path, - peer_info->path_tail, path); + GNUNET_CONTAINER_DLL_insert_tail (peer_info->path, peer_info->path_tail, + path); } else { @@ -820,16 +818,12 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_PEER_resolve (myid, &id); for (i = 0; i < n_applications; i++) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting PUT for app %d\n", applications[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting PUT for app %d\n", + applications[i]); *p = htonl (applications[i]); GNUNET_CRYPTO_hash (buffer, 12, &hash); - GNUNET_DHT_put (dht_handle, - &hash, - 10U, - GNUNET_DHT_RO_RECORD_ROUTE, - GNUNET_BLOCK_TYPE_ANY, - sizeof (struct GNUNET_PeerIdentity), + GNUNET_DHT_put (dht_handle, &hash, 10U, GNUNET_DHT_RO_RECORD_ROUTE, + GNUNET_BLOCK_TYPE_ANY, sizeof (struct GNUNET_PeerIdentity), (const char *) &id, GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), APP_ANNOUNCE_TIME), @@ -840,9 +834,9 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) NULL, NULL); #endif } - announce_applications_task = GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, - &announce_applications, - cls); + announce_applications_task = + GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, &announce_applications, + cls); return; } @@ -883,8 +877,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) NULL, /* Continuation */ NULL); /* Continuation closure */ #endif - announce_id_task = GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, - &announce_id, cls); + announce_id_task = + GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, &announce_id, cls); } /******************************************************************************/ @@ -917,11 +911,8 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Retransmitting create path\n"); GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - &id, + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &id, sizeof (struct GNUNET_MESH_ManipulatePath) + (peer_info->path->length * @@ -942,8 +933,9 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) if (p == NULL) return 0; // TODO Notify ERROR Path not found - size_needed = sizeof (struct GNUNET_MESH_ManipulatePath) - + p->length * sizeof (struct GNUNET_PeerIdentity); + size_needed = + sizeof (struct GNUNET_MESH_ManipulatePath) + + p->length * sizeof (struct GNUNET_PeerIdentity); if (size < size_needed) { // TODO retry? cancel? @@ -1194,8 +1186,8 @@ send_p2p_tunnel_destroy (void *cls, size_t size, void *buf) c = t->client; msg = buf; msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); - /*FIXME*/ - msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); + /*FIXME*/ msg->header.size = + htons (sizeof (struct GNUNET_MESH_TunnelMessage)); msg->tunnel_id = htonl (t->id.tid); destroy_tunnel (c, t); @@ -1223,8 +1215,8 @@ send_subscribed_clients (struct GNUNET_MessageHeader *msg) if (is_client_subscribed (type, c)) { count++; - GNUNET_SERVER_notification_context_unicast (nc, - c->handle, msg, GNUNET_YES); + GNUNET_SERVER_notification_context_unicast (nc, c->handle, msg, + GNUNET_YES); } } return count; @@ -1284,8 +1276,7 @@ iterate_collect_neighbors (void *cls, const GNUNET_HashCode * key, void *value) * */ static int -handle_mesh_path_create (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1341,9 +1332,7 @@ handle_mesh_path_create (void *cls, GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); if (GNUNET_OK != - GNUNET_CONTAINER_multihashmap_put (tunnels, - &hash, - t, + GNUNET_CONTAINER_multihashmap_put (tunnels, &hash, t, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) { GNUNET_break (0); @@ -1351,15 +1340,14 @@ handle_mesh_path_create (void *cls, } } - dest_peer_info = GNUNET_CONTAINER_multihashmap_get (peers, - &pi[size - 1].hashPubKey); + dest_peer_info = + GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey); if (NULL == dest_peer_info) { dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]); dest_peer_info->state = MESH_PEER_WAITING; - GNUNET_CONTAINER_multihashmap_put (peers, - &pi[size - 1].hashPubKey, + GNUNET_CONTAINER_multihashmap_put (peers, &pi[size - 1].hashPubKey, dest_peer_info, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } @@ -1369,9 +1357,7 @@ handle_mesh_path_create (void *cls, orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); orig_peer_info->id = GNUNET_PEER_intern (pi); orig_peer_info->state = MESH_PEER_WAITING; - GNUNET_CONTAINER_multihashmap_put (peers, - &pi->hashPubKey, - orig_peer_info, + GNUNET_CONTAINER_multihashmap_put (peers, &pi->hashPubKey, orig_peer_info, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); } @@ -1424,11 +1410,8 @@ handle_mesh_path_create (void *cls, { add_path_to_peer (dest_peer_info, path); GNUNET_PEER_resolve (get_first_hop (path), &id); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - &id, + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &id, sizeof (struct GNUNET_MessageHeader), &send_core_create_path_for_peer, dest_peer_info); @@ -1448,8 +1431,7 @@ handle_mesh_path_create (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_mesh_data_unicast (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1460,8 +1442,9 @@ handle_mesh_data_unicast (void *cls, size_t size; size = ntohs (message->size); - if (size < sizeof (struct GNUNET_MESH_Unicast) - + sizeof (struct GNUNET_MessageHeader)) + if (size < + sizeof (struct GNUNET_MESH_Unicast) + + sizeof (struct GNUNET_MessageHeader)) { GNUNET_break (0); return GNUNET_OK; @@ -1488,11 +1471,9 @@ handle_mesh_data_unicast (void *cls, GNUNET_PEER_resolve (get_first_hop (pi->path), &id); msg = GNUNET_malloc (size); memcpy (msg, message, size); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - &id, size, &send_core_data_raw, msg); + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &id, size, + &send_core_data_raw, msg); return GNUNET_OK; } @@ -1508,8 +1489,7 @@ handle_mesh_data_unicast (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_mesh_data_multicast (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1524,8 +1504,9 @@ handle_mesh_data_multicast (void *cls, size = ntohs (message->size); - if (size < sizeof (struct GNUNET_MESH_Multicast) - + sizeof (struct GNUNET_MessageHeader)) + if (size < + sizeof (struct GNUNET_MESH_Multicast) + + sizeof (struct GNUNET_MessageHeader)) { GNUNET_break_op (0); return GNUNET_OK; @@ -1549,8 +1530,7 @@ handle_mesh_data_multicast (void *cls, /* Retransmit to other peers */ neighbors = GNUNET_malloc (sizeof (GNUNET_PEER_Id)); neighbors[0] = 0; - GNUNET_CONTAINER_multihashmap_iterate (t->peers, - &iterate_collect_neighbors, + GNUNET_CONTAINER_multihashmap_iterate (t->peers, &iterate_collect_neighbors, &neighbors); if (!neighbors[0]) { @@ -1598,8 +1578,7 @@ handle_mesh_data_multicast (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_mesh_data_to_orig (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1610,8 +1589,9 @@ handle_mesh_data_to_orig (void *cls, size_t size; size = ntohs (message->size); - if (size < sizeof (struct GNUNET_MESH_ToOrigin) - + sizeof (struct GNUNET_MessageHeader)) + if (size < + sizeof (struct GNUNET_MESH_ToOrigin) + + sizeof (struct GNUNET_MessageHeader)) { GNUNET_break_op (0); return GNUNET_OK; @@ -1633,9 +1613,8 @@ handle_mesh_data_to_orig (void *cls, GNUNET_break_op (0); return GNUNET_OK; } - GNUNET_SERVER_notification_context_unicast (nc, - t->client->handle, - message, GNUNET_YES); + GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, message, + GNUNET_YES); return GNUNET_OK; } peer_info = get_peer_info (&msg->oid); @@ -1648,11 +1627,9 @@ handle_mesh_data_to_orig (void *cls, GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); msg = GNUNET_malloc (size); memcpy (msg, message, size); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - &id, size, &send_core_data_raw, msg); + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &id, size, + &send_core_data_raw, msg); return GNUNET_OK; } @@ -1669,8 +1646,7 @@ handle_mesh_data_to_orig (void *cls, * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_mesh_path_ack (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1708,8 +1684,7 @@ handle_mesh_path_ack (void *cls, pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); pc.tunnel_id = htonl (t->local_tid); GNUNET_PEER_resolve (peer_info->id, &pc.peer); - GNUNET_SERVER_notification_context_unicast (nc, - t->client->handle, + GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, &pc.header, GNUNET_NO); return GNUNET_OK; } @@ -1724,11 +1699,8 @@ handle_mesh_path_ack (void *cls, GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_PathACK)); memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - &id, + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &id, sizeof (struct GNUNET_MESH_PathACK), &send_core_data_raw, msg); return GNUNET_OK; @@ -1826,14 +1798,12 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) return; GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - &id, + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &id, sizeof (struct GNUNET_MESH_ManipulatePath) - + (peer_info->path->length - * sizeof (struct GNUNET_PeerIdentity)), + + + (peer_info->path->length * + sizeof (struct GNUNET_PeerIdentity)), &send_core_create_path_for_peer, peer_info); peer_info->path_refresh_task = @@ -1860,8 +1830,7 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param data pointer to the result data */ static void -dht_get_id_handler (void *cls, - struct GNUNET_TIME_Absolute exp, +dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, @@ -1890,28 +1859,26 @@ dht_get_id_handler (void *cls, for (i = 0; get_path[i] != NULL; i++) ; for (i--; i >= 0; i--) { - p->peers = GNUNET_realloc (p->peers, - sizeof (GNUNET_PEER_Id) * (p->length + 1)); + p->peers = + GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); p->peers[p->length] = GNUNET_PEER_intern (get_path[i]); p->length++; } for (i = 0; put_path[i] != NULL; i++) ; for (i--; i >= 0; i--) { - p->peers = GNUNET_realloc (p->peers, - sizeof (GNUNET_PEER_Id) * (p->length + 1)); + p->peers = + GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); p->peers[p->length] = GNUNET_PEER_intern (put_path[i]); p->length++; } add_path_to_peer (peer_info, p); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - get_path[1], + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, get_path[1], sizeof (struct GNUNET_MESH_ManipulatePath) - + (p->length - * sizeof (struct GNUNET_PeerIdentity)), + + + (p->length * + sizeof (struct GNUNET_PeerIdentity)), &send_core_create_path_for_peer, peer_info); if (0 == peer_info->path_refresh_task) @@ -1941,13 +1908,12 @@ dht_get_id_handler (void *cls, * @param data pointer to the result data */ static void -dht_get_type_handler (void *cls, - struct GNUNET_TIME_Absolute exp, +dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity *const *get_path, const struct GNUNET_PeerIdentity *const *put_path, - enum GNUNET_BLOCK_Type type, - size_t size, const void *data) + enum GNUNET_BLOCK_Type type, size_t size, + const void *data) { const struct GNUNET_PeerIdentity *pi = data; struct MeshTunnel *t = cls; @@ -1962,9 +1928,7 @@ dht_get_type_handler (void *cls, return; } peer_info = get_peer_info (pi); - GNUNET_CONTAINER_multihashmap_put (t->peers, - &pi->hashPubKey, - peer_info, + GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path) { @@ -1984,28 +1948,26 @@ dht_get_type_handler (void *cls, for (i = 0; get_path[i] != NULL; i++) ; for (i--; i >= 0; i--) { - p->peers = GNUNET_realloc (p->peers, - sizeof (GNUNET_PEER_Id) * (p->length + 1)); + p->peers = + GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); p->peers[p->length] = GNUNET_PEER_intern (get_path[i]); p->length++; } for (i = 0; put_path[i] != NULL; i++) ; for (i--; i >= 0; i--) { - p->peers = GNUNET_realloc (p->peers, - sizeof (GNUNET_PEER_Id) * (p->length + 1)); + p->peers = + GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); p->peers[p->length] = GNUNET_PEER_intern (put_path[i]); p->length++; } add_path_to_peer (peer_info, p); - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, - GNUNET_TIME_UNIT_FOREVER_REL, - get_path[1], + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, get_path[1], sizeof (struct GNUNET_MESH_ManipulatePath) - + (p->length - * sizeof (struct GNUNET_PeerIdentity)), + + + (p->length * + sizeof (struct GNUNET_PeerIdentity)), &send_core_create_path_for_peer, peer_info); @@ -2039,8 +2001,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " matching client found, cleaning\n"); - GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, - &delete_tunnel_entry, c); + GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, &delete_tunnel_entry, + c); GNUNET_CONTAINER_multihashmap_destroy (c->tunnels); if (0 != c->app_counter) { /* deregister clients applications */ @@ -2055,10 +2017,10 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) applications[j] = applications[n_applications - 1]; applications_rc[j] = applications_rc[n_applications - 1]; n_applications--; - applications = GNUNET_realloc (applications, - n_applications * - sizeof - (GNUNET_MESH_ApplicationType)); + applications = + GNUNET_realloc (applications, + n_applications * + sizeof (GNUNET_MESH_ApplicationType)); applications_rc = GNUNET_realloc (applications_rc, n_applications * sizeof (unsigned int)); @@ -2100,8 +2062,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) * @param message the actual message, which includes messages the client wants */ static void -handle_local_new_client (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MESH_ClientConnect *cc_msg; @@ -2140,8 +2101,7 @@ handle_local_new_client (void *cls, { c->app_counter = apps; c->apps = GNUNET_malloc (apps * sizeof (GNUNET_MESH_ApplicationType)); - memcpy (c->apps, - &message[1] + types * sizeof (uint16_t), + memcpy (c->apps, &message[1] + types * sizeof (uint16_t), apps * sizeof (GNUNET_MESH_ApplicationType)); } for (i = 0; i < apps; i++) @@ -2159,11 +2119,13 @@ handle_local_new_client (void *cls, if (!known) { /* Register previously unknown application */ n_applications++; - applications = GNUNET_realloc (applications, - n_applications * - sizeof (GNUNET_MESH_ApplicationType)); - applications_rc = GNUNET_realloc (applications_rc, - n_applications * sizeof (unsigned int)); + applications = + GNUNET_realloc (applications, + n_applications * + sizeof (GNUNET_MESH_ApplicationType)); + applications_rc = + GNUNET_realloc (applications_rc, + n_applications * sizeof (unsigned int)); applications[n_applications - 1] = c->apps[i]; applications_rc[n_applications - 1] = 1; if (0 == announce_applications_task) @@ -2174,8 +2136,7 @@ handle_local_new_client (void *cls, } } } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " client has %u+%u subscriptions\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u+%u subscriptions\n", c->type_counter, c->app_counter); GNUNET_CONTAINER_DLL_insert (clients, clients_tail, c); @@ -2195,8 +2156,7 @@ handle_local_new_client (void *cls, * @param message the actual message */ static void -handle_local_tunnel_create (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MESH_TunnelMessage *t_msg; @@ -2278,8 +2238,7 @@ handle_local_tunnel_create (void *cls, * @param message the actual message */ static void -handle_local_tunnel_destroy (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MESH_TunnelMessage *tunnel_msg; @@ -2332,8 +2291,7 @@ handle_local_tunnel_destroy (void *cls, * @param message the actual message (PeerControl) */ static void -handle_local_connect_add (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MESH_PeerControl *peer_msg; @@ -2406,8 +2364,7 @@ handle_local_connect_add (void *cls, * @param message the actual message (PeerControl) */ static void -handle_local_connect_del (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_connect_del (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MESH_PeerControl *peer_msg; @@ -2466,8 +2423,7 @@ handle_local_connect_del (void *cls, * @param message the actual message (ConnectPeerByType) */ static void -handle_local_connect_by_type (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MESH_ConnectPeerByType *connect_msg; @@ -2528,8 +2484,7 @@ handle_local_connect_by_type (void *cls, struct GNUNET_MESH_PeerControl pc; GNUNET_PEER_resolve (myid, &pc.peer); - GNUNET_CONTAINER_multihashmap_put (t->peers, - &pc.peer.hashPubKey, + GNUNET_CONTAINER_multihashmap_put (t->peers, &pc.peer.hashPubKey, get_peer_info (&pc.peer), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); @@ -2546,14 +2501,11 @@ handle_local_connect_by_type (void *cls, { GNUNET_DHT_get_stop (c->dht_get_type); } - c->dht_get_type = GNUNET_DHT_get_start (dht_handle, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_ANY, - &hash, - 10U, - GNUNET_DHT_RO_RECORD_ROUTE, - NULL, - 0, NULL, 0, &dht_get_type_handler, t); + c->dht_get_type = + GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BLOCK_TYPE_ANY, &hash, 10U, + GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0, NULL, 0, + &dht_get_type_handler, t); GNUNET_SERVER_receive_done (client, GNUNET_OK); return; @@ -2568,8 +2520,7 @@ handle_local_connect_by_type (void *cls, * @param message the actual message */ static void -handle_local_unicast (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct MeshClient *c; @@ -2590,8 +2541,8 @@ handle_local_unicast (void *cls, } data_msg = (struct GNUNET_MESH_Unicast *) message; /* Sanity check for message size */ - if (sizeof (struct GNUNET_MESH_Unicast) + sizeof (struct GNUNET_MessageHeader) - > ntohs (data_msg->header.size)) + if (sizeof (struct GNUNET_MESH_Unicast) + + sizeof (struct GNUNET_MessageHeader) > ntohs (data_msg->header.size)) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -2645,9 +2596,8 @@ handle_local_unicast (void *cls, info->origin = &t->id; info->size = data_size; info->client = client; - GNUNET_CORE_notify_transmit_ready (core_handle, - 0, - 0, GNUNET_TIME_UNIT_FOREVER_REL, &next_hop, + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, + GNUNET_TIME_UNIT_FOREVER_REL, &next_hop, /* FIXME re-check types */ data_size + sizeof (struct GNUNET_MESH_Unicast), @@ -2663,8 +2613,7 @@ handle_local_unicast (void *cls, * @param message the actual message */ static void -handle_local_multicast (void *cls, - struct GNUNET_SERVER_Client *client, +handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct MeshClient *c; @@ -2751,8 +2700,7 @@ static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { * @param publicKey the public key of this peer */ static void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -2771,8 +2719,7 @@ core_init (void *cls, * @param atsi performance data for the connection */ static void -core_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { // GNUNET_PEER_Id pid; @@ -2870,8 +2817,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n"); @@ -2919,8 +2865,8 @@ run (void *cls, announce_applications_task = 0; /* Scheduled the task to clean up when shutdown is called */ - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of run()\n"); } @@ -2937,11 +2883,10 @@ main (int argc, char *const *argv) { int ret; - ret = (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "mesh", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "mesh", GNUNET_SERVICE_OPTION_NONE, &run, + NULL)) ? 0 : 1; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of main()\n"); return ret; } diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 1ccd31dfe..3a50e44ee 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -171,8 +171,8 @@ call_connect_handler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -core_startup (void *cls, - struct GNUNET_CORE_Handle *core __attribute__ ((unused)), +core_startup (void *cls, struct GNUNET_CORE_Handle *core + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey __attribute__ ((unused))) @@ -215,8 +215,7 @@ send_hello_message (void *cls, size_t size, void *buf) * */ static void -core_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct GNUNET_MESH_Handle *handle = cls; @@ -225,11 +224,8 @@ core_connect (void *cls, "Core tells us we are connected to peer %s\n", GNUNET_i2s (peer)); /* Send a hello to this peer */ - GNUNET_CORE_notify_transmit_ready (handle->core, - GNUNET_NO, - 42, - GNUNET_TIME_UNIT_SECONDS, - peer, + GNUNET_CORE_notify_transmit_ready (handle->core, GNUNET_NO, 42, + GNUNET_TIME_UNIT_SECONDS, peer, sizeof (struct GNUNET_MessageHeader) + handle->hello_message_size, &send_hello_message, cls); @@ -347,8 +343,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) * This is a hello-message, containing the application-types the other peer can receive */ static int -receive_hello (void *cls, - const struct GNUNET_PeerIdentity *other, +receive_hello (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -434,8 +429,7 @@ receive_hello (void *cls, * Receive a message from core. */ static int -core_receive (void *cls, - const struct GNUNET_PeerIdentity *other, +core_receive (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -448,9 +442,9 @@ core_receive (void *cls, for (handler = handle->handlers; handler->callback != NULL; handler++) { - if ((ntohs (rmessage->type) == handler->type) - && ((handler->expected_size == 0) - || (handler->expected_size == ntohs (rmessage->size)))) + if ((ntohs (rmessage->type) == handler->type) && + ((handler->expected_size == 0) || + (handler->expected_size == ntohs (rmessage->size)))) { break; } @@ -474,10 +468,10 @@ core_receive (void *cls, if (tunnel->tunnel.id.id == tmessage->id.id && (0 == memcmp (&tmessage->id.initiator, &tunnel->tunnel.id.initiator, - sizeof (struct GNUNET_PeerIdentity))) - && (0 == - memcmp (&tmessage->id.target, &tunnel->tunnel.id.target, - sizeof (struct GNUNET_PeerIdentity)))) + sizeof (struct GNUNET_PeerIdentity))) && + (0 == + memcmp (&tmessage->id.target, &tunnel->tunnel.id.target, + sizeof (struct GNUNET_PeerIdentity)))) break; tunnel = tunnel->next; } @@ -507,8 +501,8 @@ core_receive (void *cls, "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other), ntohs (rmessage->type)); - return handler->callback (handle->cls, &tunnel->tunnel, - &tunnel->tunnel.ctx, other, rmessage, atsi); + return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx, + other, rmessage, atsi); } struct GNUNET_MESH_Tunnel * @@ -691,19 +685,13 @@ core_notify (void *cls, size_t size, void *buf) * memory); if NULL is returned, "notify" will NOT be called. */ struct GNUNET_MESH_TransmitHandle * -GNUNET_MESH_notify_transmit_ready (struct - GNUNET_MESH_Tunnel - *tunnel, - int cork, +GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, uint32_t priority, - struct - GNUNET_TIME_Relative - maxdelay, + struct GNUNET_TIME_Relative maxdelay, const struct GNUNET_PeerIdentity *target - __attribute__ ((unused)), - size_t notify_size, - GNUNET_CONNECTION_TransmitReadyNotify - notify, void *notify_cls) + __attribute__ ((unused)), size_t notify_size, + GNUNET_CONNECTION_TransmitReadyNotify notify, + void *notify_cls) { if (NULL != tunnel->notify_handle) { @@ -718,7 +706,8 @@ GNUNET_MESH_notify_transmit_ready (struct cls->notify = notify; cls->tunnel = tunnel; - tunnel->notify_handle = (struct GNUNET_MESH_TransmitHandle *) + tunnel->notify_handle = + (struct GNUNET_MESH_TransmitHandle *) GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority, maxdelay, &tunnel->peer, notify_size + @@ -806,11 +795,8 @@ build_hello_message (struct GNUNET_MESH_Handle *handle, struct GNUNET_MESH_Handle * -GNUNET_MESH_connect (const struct - GNUNET_CONFIGURATION_Handle - *cfg, void *cls, - GNUNET_MESH_TunnelEndHandler - cleaner, +GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, + GNUNET_MESH_TunnelEndHandler cleaner, const struct GNUNET_MESH_MessageHandler *handlers, const GNUNET_MESH_ApplicationType *stypes) { @@ -845,15 +831,10 @@ GNUNET_MESH_connect (const struct {NULL, 0, 0} }; - ret->core = GNUNET_CORE_connect (cfg, - 42, - ret, - &core_startup, - &core_connect, - &core_disconnect, - NULL, - NULL, - GNUNET_NO, NULL, GNUNET_NO, core_handlers); + ret->core = + GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect, + &core_disconnect, NULL, NULL, GNUNET_NO, NULL, + GNUNET_NO, core_handlers); return ret; } diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index 83ac2a818..f765aca1c 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c @@ -239,18 +239,20 @@ send_connect_packet (void *cls, size_t size, void *buf) for (napps = 0, apps = NULL; napps < h->n_applications; napps++) { - apps = GNUNET_realloc (apps, - sizeof (GNUNET_MESH_ApplicationType) * (napps + 1)); + apps = + GNUNET_realloc (apps, + sizeof (GNUNET_MESH_ApplicationType) * (napps + 1)); apps[napps] = h->applications[napps]; } - msg->header.size = htons (sizeof (struct GNUNET_MESH_ClientConnect) + - sizeof (uint16_t) * ntypes + - sizeof (GNUNET_MESH_ApplicationType) * napps); + msg->header.size = + htons (sizeof (struct GNUNET_MESH_ClientConnect) + + sizeof (uint16_t) * ntypes + + sizeof (GNUNET_MESH_ApplicationType) * napps); memcpy (&msg[1], types, sizeof (uint16_t) * ntypes); - memcpy (&msg[1] + sizeof (uint16_t) * ntypes, - apps, sizeof (GNUNET_MESH_ApplicationType) * napps); + memcpy (&msg[1] + sizeof (uint16_t) * ntypes, apps, + sizeof (GNUNET_MESH_ApplicationType) * napps); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %lu bytes long message %d types and %d apps\n", ntohs (msg->header.size), ntypes, napps); @@ -303,8 +305,8 @@ send_tunnel_create_packet (void *cls, size_t size, void *buf) msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); msg->tunnel_id = htonl (t->tid); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sent %lu bytes long message\n", ntohs (msg->header.size)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %lu bytes long message\n", + ntohs (msg->header.size)); return ntohs (msg->header.size); } @@ -502,8 +504,8 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received a message from mesh\n"); - GNUNET_CLIENT_receive (h->client, - &msg_received, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &msg_received, h, + GNUNET_TIME_UNIT_FOREVER_REL); return; } @@ -527,8 +529,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg) * NULL on error (in this case, init is never called) */ struct GNUNET_MESH_Handle * -GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - void *cls, +GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_MESH_TunnelEndHandler cleaner, const struct GNUNET_MESH_MessageHandler *handlers, const GNUNET_MESH_ApplicationType *stypes) @@ -540,8 +541,8 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, h->cleaner = cleaner; h->client = GNUNET_CLIENT_connect ("mesh", cfg); - GNUNET_CLIENT_receive (h->client, - &msg_received, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &msg_received, h, + GNUNET_TIME_UNIT_FOREVER_REL); if (h->client == NULL) { GNUNET_free (h); @@ -560,12 +561,11 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, size += h->n_handlers * sizeof (uint16_t); size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType); - h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, - size, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, - &send_connect_packet, - (void *) h); + h->th = + GNUNET_CLIENT_notify_transmit_ready (h->client, size, + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_YES, &send_connect_packet, + (void *) h); return h; } @@ -602,8 +602,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) */ struct GNUNET_MESH_Tunnel * GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, - GNUNET_MESH_TunnelConnectHandler - connect_handler, + GNUNET_MESH_TunnelConnectHandler connect_handler, GNUNET_MESH_TunnelDisconnectHandler disconnect_handler, void *handler_cls) { @@ -619,13 +618,14 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, tunnel->tid = h->next_tid++; h->next_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK; // keep in range - h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, - sizeof (struct - GNUNET_MESH_TunnelMessage), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, - &send_tunnel_create_packet, - (void *) tunnel); + h->th = + GNUNET_CLIENT_notify_transmit_ready (h->client, + sizeof (struct + GNUNET_MESH_TunnelMessage), + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_YES, + &send_tunnel_create_packet, + (void *) tunnel); return tunnel; } @@ -714,14 +714,13 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel, * memory); if NULL is returned, "notify" will NOT be called. */ struct GNUNET_MESH_TransmitHandle * -GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, - int cork, +GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, uint32_t priority, struct GNUNET_TIME_Relative maxdelay, const struct GNUNET_PeerIdentity *target, size_t notify_size, - GNUNET_CONNECTION_TransmitReadyNotify - notify, void *notify_cls) + GNUNET_CONNECTION_TransmitReadyNotify notify, + void *notify_cls) { struct GNUNET_MESH_TransmitHandle *handle; diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c index 9828ee8d9..c5f0e9f0f 100644 --- a/src/mesh/test_mesh_api.c +++ b/src/mesh/test_mesh_api.c @@ -51,9 +51,7 @@ GNUNET_SCHEDULER_TaskIdentifier test_task; * GNUNET_SYSERR to close it (signal serious error) */ static int -callback (void *cls, - struct GNUNET_MESH_Tunnel *tunnel, - void **tunnel_ctx, +callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) @@ -125,16 +123,16 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - arm_pid = GNUNET_OS_start_process (NULL, NULL, - "gnunet-service-arm", "gnunet-service-arm", + arm_pid = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_mesh.conf", NULL); + "-c", "test_mesh.conf", NULL); abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply @@ -170,14 +168,14 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, - argv2, "test-mesh-api", "nohelp", - options, &run, NULL); + ret = + GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, + "test-mesh-api", "nohelp", options, &run, NULL); if (GNUNET_OK != ret) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "run failed with error code %d\n", ret); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "run failed with error code %d\n", + ret); return 1; } if (GNUNET_SYSERR == result) diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index d0d394177..fe0ca631d 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c @@ -213,8 +213,8 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -static void -churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void churn_peers (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -235,9 +235,9 @@ stats_finished_callback (void *cls, int success) { /* Stats lookup successful, write out data */ buf = NULL; - buf_len = GNUNET_asprintf (&buf, - "TOTAL_MESH_BYTES: %u\n", - stats_context->total_mesh_bytes); + buf_len = + GNUNET_asprintf (&buf, "TOTAL_MESH_BYTES: %u\n", + stats_context->total_mesh_bytes); if (buf_len > 0) { GNUNET_DISK_file_write (data_file, buf, buf_len); @@ -263,10 +263,9 @@ stats_finished_callback (void *cls, int success) * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -statistics_iterator (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, + const char *subsystem, const char *name, uint64_t value, + int is_persistent) { struct StatsContext *stats_context = cls; @@ -300,10 +299,9 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) // } GNUNET_asprintf (&buf, "round%llu", current_round); - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "test_mesh_small", - buf, - &peers_next_round)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "test_mesh_small", + buf, &peers_next_round)) { current_round++; GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); @@ -314,8 +312,7 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) stats_context = GNUNET_malloc (sizeof (struct StatsContext)); GNUNET_SCHEDULER_cancel (shutdown_handle); shutdown_handle = GNUNET_SCHEDULER_NO_TASK; - GNUNET_TESTING_get_statistics (pg, - &stats_finished_callback, + GNUNET_TESTING_get_statistics (pg, &stats_finished_callback, &statistics_iterator, stats_context); } GNUNET_free (buf); @@ -331,8 +328,8 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void topology_output_callback (void *cls, const char *emsg) { - disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, - &disconnect_mesh_peers, NULL); + disconnect_task = + GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL); GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL); } @@ -354,19 +351,18 @@ churn_callback (void *cls, const char *emsg) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn finished successfully.\n", current_round); GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); - GNUNET_asprintf (&temp_output_file, - "%s_%llu.dot", topology_file, current_round); - GNUNET_TESTING_peergroup_topology_to_file (pg, - temp_output_file, + GNUNET_asprintf (&temp_output_file, "%s_%llu.dot", topology_file, + current_round); + GNUNET_TESTING_peergroup_topology_to_file (pg, temp_output_file, &topology_output_callback, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Writing topology to file %s\n", temp_output_file); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", + temp_output_file); GNUNET_free (temp_output_file); } else { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Round %llu, churn FAILED!!\n", current_round); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn FAILED!!\n", + current_round); GNUNET_SCHEDULER_cancel (shutdown_handle); shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } @@ -383,9 +379,8 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Nothing to do... */ GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL); GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); - disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, - &disconnect_mesh_peers, - NULL); + disconnect_task = + GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", current_round); } @@ -401,18 +396,18 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, turning off %llu peers, turning on %llu peers!\n", current_round, - (peers_running > peers_next_round) - ? peers_running - peers_next_round - : 0, - (peers_next_round > peers_running) - ? peers_next_round - peers_running : 0); + (peers_running > + peers_next_round) ? peers_running - peers_next_round : 0, + (peers_next_round > + peers_running) ? peers_next_round - peers_running : 0); GNUNET_TESTING_daemons_churn (pg, "nse", - (peers_running > peers_next_round) - ? peers_running - peers_next_round - : 0, - (peers_next_round > peers_running) - ? peers_next_round - peers_running - : 0, wait_time, &churn_callback, NULL); + (peers_running > + peers_next_round) ? peers_running - + peers_next_round : 0, + (peers_next_round > + peers_running) ? peers_next_round - + peers_running : 0, wait_time, &churn_callback, + NULL); } } @@ -435,8 +430,8 @@ my_cb (void *cls, const char *emsg) #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully!\n"); #endif - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Have %u connections\n", total_connections); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", + total_connections); if (data_file != NULL) { buf = NULL; @@ -469,10 +464,8 @@ my_cb (void *cls, const char *emsg) * @param emsg error message (NULL on success) */ static void -connect_cb (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -484,9 +477,8 @@ connect_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *temp_str; unsigned long long temp_wait; @@ -496,82 +488,80 @@ run (void *cls, testing_cfg = (struct GNUNET_CONFIGURATION_Handle *) cfg; // GNUNET_CONFIGURATION_create(); #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); - GNUNET_CONFIGURATION_set_value_string (testing_cfg, - "testing", "use_progressbars", "YES"); + GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", + "use_progressbars", "YES"); #endif - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "testing", - "num_peers", - &num_peers)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", + "num_peers", &num_peers)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option TESTING:NUM_PEERS is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "test_mesh_small", - "wait_time", - &temp_wait)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "test_mesh_small", + "wait_time", &temp_wait)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nsetest_mesh_small:wait_time is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, - "testing", - "topology_output_file", - &topology_file)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing", + "topology_output_file", + &topology_file)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option test_mesh_small:topology_output_file is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, - "test_mesh_small", - "data_output_file", - &data_filename)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_mesh_small", + "data_output_file", + &data_filename)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option test_mesh_small:data_output_file is required!\n"); return; } - data_file = GNUNET_DISK_file_open (data_filename, - GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + data_file = + GNUNET_DISK_file_open (data_filename, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (data_file == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to open %s for output!\n", data_filename); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", + data_filename); GNUNET_free (data_filename); wait_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, - "test_mesh_small", - "output_file", - &temp_str)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "test_mesh_small", + "output_file", &temp_str)) { - output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + output_file = + GNUNET_DISK_file_open (temp_str, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (output_file == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to open %s for output!\n", temp_str); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", + temp_str); } GNUNET_free_non_null (temp_str); hosts = GNUNET_TESTING_hosts_load (testing_cfg); - pg = GNUNET_TESTING_peergroup_start (testing_cfg, - num_peers, - TIMEOUT, + pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT, &connect_cb, &my_cb, NULL, hosts); GNUNET_assert (pg != NULL); shutdown_handle = @@ -602,10 +592,9 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run (argc, - argv, "test_mesh_small", - gettext_noop ("Test mesh in a small network."), - options, &run, NULL); + GNUNET_PROGRAM_run (argc, argv, "test_mesh_small", + gettext_noop ("Test mesh in a small network."), options, + &run, NULL); #if REMOVE_DIR GNUNET_DISK_directory_remove ("/tmp/test_mesh_small"); #endif diff --git a/src/nat/gnunet-helper-nat-client-windows.c b/src/nat/gnunet-helper-nat-client-windows.c index 0fa62ff7c..864c911b0 100644 --- a/src/nat/gnunet-helper-nat-client-windows.c +++ b/src/nat/gnunet-helper-nat-client-windows.c @@ -258,8 +258,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.checksum = 0; ip_pkt.src_ip = my_ip->s_addr; ip_pkt.dst_ip = other->s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -273,8 +273,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) /* ip header of the presumably 'lost' udp packet */ ip_pkt.vers_ihl = 0x45; ip_pkt.tos = 0; - ip_pkt.pkt_len = htons (sizeof (struct ip_header) + - sizeof (struct udp_header)); + ip_pkt.pkt_len = + htons (sizeof (struct ip_header) + sizeof (struct udp_header)); ip_pkt.id = htons (0); ip_pkt.flags_frag_offset = 0; ip_pkt.ttl = 128; @@ -282,8 +282,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.checksum = 0; ip_pkt.src_ip = other->s_addr; ip_pkt.dst_ip = dummy.s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -296,20 +296,20 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) off += sizeof (struct udp_header); /* no go back to calculate ICMP packet checksum */ - icmp_pkt.checksum = htons (calc_checksum ((uint16_t *) & packet[off], - sizeof (struct - icmp_ttl_exceeded_header) + - sizeof (struct ip_header) + - sizeof (struct udp_header))); + icmp_pkt.checksum = + htons (calc_checksum + ((uint16_t *) & packet[off], + sizeof (struct icmp_ttl_exceeded_header) + + sizeof (struct ip_header) + sizeof (struct udp_header))); memcpy (&packet[sizeof (struct ip_header)], &icmp_pkt, sizeof (struct icmp_ttl_exceeded_header)); memset (&dst, 0, sizeof (dst)); dst.sin_family = AF_INET; dst.sin_addr = *other; - err = sendto (rawsock, - packet, - sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); + err = + sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, + sizeof (dst)); if (err < 0) { fprintf (stderr, "sendto failed: %s\n", strerror (errno)); @@ -352,8 +352,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.checksum = 0; ip_pkt.src_ip = my_ip->s_addr; ip_pkt.dst_ip = other->s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (ip_pkt); @@ -377,8 +377,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.src_ip = other->s_addr; ip_pkt.dst_ip = dummy.s_addr; ip_pkt.checksum = 0; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -386,26 +386,27 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) icmp_echo.code = 0; icmp_echo.reserved = htonl (port); icmp_echo.checksum = 0; - icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, - sizeof (struct icmp_echo_header))); + icmp_echo.checksum = + htons (calc_checksum + ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header))); memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); /* no go back to calculate ICMP packet checksum */ off = sizeof (struct ip_header); - icmp_ttl.checksum = htons (calc_checksum ((uint16_t *) & packet[off], - sizeof (struct - icmp_ttl_exceeded_header) + - sizeof (struct ip_header) + - sizeof (struct icmp_echo_header))); + icmp_ttl.checksum = + htons (calc_checksum + ((uint16_t *) & packet[off], + sizeof (struct icmp_ttl_exceeded_header) + + sizeof (struct ip_header) + sizeof (struct icmp_echo_header))); memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header)); memset (&dst, 0, sizeof (dst)); dst.sin_family = AF_INET; dst.sin_addr = *other; - err = sendto (rawsock, - packet, - sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); + err = + sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, + sizeof (dst)); if (err < 0) { @@ -439,8 +440,8 @@ make_raw_socket () if (0 != setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, bOptLen)) { - fprintf (stderr, - "Error setting SO_BROADCAST to ON: %s\n", strerror (errno)); + fprintf (stderr, "Error setting SO_BROADCAST to ON: %s\n", + strerror (errno)); closesocket (rawsock); return INVALID_SOCKET; } diff --git a/src/nat/gnunet-helper-nat-client.c b/src/nat/gnunet-helper-nat-client.c index 76f405bf1..fbebdbc0f 100644 --- a/src/nat/gnunet-helper-nat-client.c +++ b/src/nat/gnunet-helper-nat-client.c @@ -235,8 +235,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.checksum = 0; ip_pkt.src_ip = my_ip->s_addr; ip_pkt.dst_ip = other->s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -250,8 +250,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) /* ip header of the presumably 'lost' udp packet */ ip_pkt.vers_ihl = 0x45; ip_pkt.tos = 0; - ip_pkt.pkt_len = htons (sizeof (struct ip_header) + - sizeof (struct udp_header)); + ip_pkt.pkt_len = + htons (sizeof (struct ip_header) + sizeof (struct udp_header)); ip_pkt.id = htons (0); ip_pkt.flags_frag_offset = 0; ip_pkt.ttl = 128; @@ -259,8 +259,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.checksum = 0; ip_pkt.src_ip = other->s_addr; ip_pkt.dst_ip = dummy.s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -287,9 +287,9 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) dst.sin_len = sizeof (struct sockaddr_in); #endif dst.sin_addr = *other; - err = sendto (rawsock, - packet, - sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); + err = + sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, + sizeof (dst)); if (err < 0) { fprintf (stderr, "sendto failed: %s\n", strerror (errno)); @@ -332,8 +332,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.checksum = 0; ip_pkt.src_ip = my_ip->s_addr; ip_pkt.dst_ip = other->s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off = sizeof (ip_pkt); @@ -357,8 +357,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) ip_pkt.src_ip = other->s_addr; ip_pkt.dst_ip = dummy.s_addr; ip_pkt.checksum = 0; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -366,17 +366,18 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) icmp_echo.code = 0; icmp_echo.reserved = htonl (port); icmp_echo.checksum = 0; - icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, - sizeof (struct icmp_echo_header))); + icmp_echo.checksum = + htons (calc_checksum + ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header))); memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); /* no go back to calculate ICMP packet checksum */ off = sizeof (struct ip_header); - icmp_ttl.checksum = htons (calc_checksum ((uint16_t *) & packet[off], - sizeof (struct - icmp_ttl_exceeded_header) + - sizeof (struct ip_header) + - sizeof (struct icmp_echo_header))); + icmp_ttl.checksum = + htons (calc_checksum + ((uint16_t *) & packet[off], + sizeof (struct icmp_ttl_exceeded_header) + + sizeof (struct ip_header) + sizeof (struct icmp_echo_header))); memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header)); /* prepare for transmission */ @@ -386,9 +387,9 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) dst.sin_len = sizeof (struct sockaddr_in); #endif dst.sin_addr = *other; - err = sendto (rawsock, - packet, - sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); + err = + sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, + sizeof (dst)); if (err < 0) { fprintf (stderr, "sendto failed: %s\n", strerror (errno)); @@ -417,15 +418,15 @@ make_raw_socket () fprintf (stderr, "Error opening RAW socket: %s\n", strerror (errno)); return -1; } - if (0 != setsockopt (ret, SOL_SOCKET, SO_BROADCAST, - (char *) &one, sizeof (one))) + if (0 != + setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof (one))) { fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); close (ret); return -1; } - if (0 != setsockopt (ret, IPPROTO_IP, IP_HDRINCL, - (char *) &one, sizeof (one))) + if (0 != + setsockopt (ret, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one))) { fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); close (ret); diff --git a/src/nat/gnunet-helper-nat-server-windows.c b/src/nat/gnunet-helper-nat-server-windows.c index 727a7be67..8386a15b1 100644 --- a/src/nat/gnunet-helper-nat-server-windows.c +++ b/src/nat/gnunet-helper-nat-server-windows.c @@ -272,8 +272,8 @@ send_icmp_echo (const struct in_addr *my_ip) ip_pkt.checksum = 0; ip_pkt.src_ip = my_ip->s_addr; ip_pkt.dst_ip = dummy.s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -281,16 +281,17 @@ send_icmp_echo (const struct in_addr *my_ip) icmp_echo.code = 0; icmp_echo.reserved = 0; icmp_echo.checksum = 0; - icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, - sizeof (struct icmp_echo_header))); + icmp_echo.checksum = + htons (calc_checksum + ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header))); memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); off += sizeof (struct icmp_echo_header); memset (&dst, 0, sizeof (dst)); dst.sin_family = AF_INET; dst.sin_addr = dummy; - err = sendto (rawsock, - packet, off, 0, (struct sockaddr *) &dst, sizeof (dst)); + err = + sendto (rawsock, packet, off, 0, (struct sockaddr *) &dst, sizeof (dst)); if (err < 0) { #if VERBOSE @@ -383,9 +384,10 @@ process_icmp_response () switch (ip_pkt.proto) { case IPPROTO_ICMP: - if (have != (sizeof (struct ip_header) * 2 + - sizeof (struct icmp_ttl_exceeded_header) + - sizeof (struct icmp_echo_header))) + if (have != + (sizeof (struct ip_header) * 2 + + sizeof (struct icmp_ttl_exceeded_header) + + sizeof (struct icmp_echo_header))) { /* malformed */ return; @@ -395,9 +397,9 @@ process_icmp_response () port = (uint16_t) ntohl (icmp_echo.reserved); break; case IPPROTO_UDP: - if (have != (sizeof (struct ip_header) * 2 + - sizeof (struct icmp_ttl_exceeded_header) + - sizeof (struct udp_header))) + if (have != + (sizeof (struct ip_header) * 2 + + sizeof (struct icmp_ttl_exceeded_header) + sizeof (struct udp_header))) { /* malformed */ return; @@ -412,8 +414,8 @@ process_icmp_response () } ssize = sizeof (buf); - WSAAddressToString ((LPSOCKADDR) & source_ip, - sizeof (source_ip), NULL, buf, &ssize); + WSAAddressToString ((LPSOCKADDR) & source_ip, sizeof (source_ip), NULL, buf, + &ssize); if (port == 0) fprintf (stdout, "%s\n", buf); else @@ -460,16 +462,17 @@ make_raw_socket () return INVALID_SOCKET; } - if (0 != setsockopt (rawsock, - SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, bOptLen)) + if (0 != + setsockopt (rawsock, SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, + bOptLen)) { - fprintf (stderr, - "Error setting SO_BROADCAST to ON: %s\n", strerror (errno)); + fprintf (stderr, "Error setting SO_BROADCAST to ON: %s\n", + strerror (errno)); closesocket (rawsock); return INVALID_SOCKET; } - if (0 != setsockopt (rawsock, - IPPROTO_IP, IP_HDRINCL, (char *) &bOptVal, bOptLen)) + if (0 != + setsockopt (rawsock, IPPROTO_IP, IP_HDRINCL, (char *) &bOptVal, bOptLen)) { fprintf (stderr, "Error setting IP_HDRINCL to ON: %s\n", strerror (errno)); closesocket (rawsock); @@ -503,9 +506,8 @@ make_udp_socket (const struct in_addr *my_ip) addr.sin_port = htons (NAT_TRAV_PORT); if (0 != bind (ret, (struct sockaddr *) &addr, sizeof (addr))) { - fprintf (stderr, - "Error binding UDP socket to port %u: %s\n", - NAT_TRAV_PORT, strerror (errno)); + fprintf (stderr, "Error binding UDP socket to port %u: %s\n", NAT_TRAV_PORT, + strerror (errno)); /* likely problematic, but not certain, try to continue */ } return ret; @@ -530,9 +532,8 @@ main (int argc, char *const *argv) } if (1 != inet_pton (AF_INET, argv[1], &external)) { - fprintf (stderr, - "Error parsing IPv4 address: %s, error %s\n", - argv[1], strerror (errno)); + fprintf (stderr, "Error parsing IPv4 address: %s, error %s\n", argv[1], + strerror (errno)); return 1; } if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy)) diff --git a/src/nat/gnunet-helper-nat-server.c b/src/nat/gnunet-helper-nat-server.c index 636ae6003..684fa9706 100644 --- a/src/nat/gnunet-helper-nat-server.c +++ b/src/nat/gnunet-helper-nat-server.c @@ -252,8 +252,8 @@ send_icmp_echo (const struct in_addr *my_ip) ip_pkt.checksum = 0; ip_pkt.src_ip = my_ip->s_addr; ip_pkt.dst_ip = dummy.s_addr; - ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, - sizeof (struct ip_header))); + ip_pkt.checksum = + htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); off += sizeof (struct ip_header); @@ -261,8 +261,9 @@ send_icmp_echo (const struct in_addr *my_ip) icmp_echo.code = 0; icmp_echo.checksum = 0; icmp_echo.reserved = 0; - icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, - sizeof (struct icmp_echo_header))); + icmp_echo.checksum = + htons (calc_checksum + ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header))); memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); off += sizeof (struct icmp_echo_header); @@ -272,8 +273,8 @@ send_icmp_echo (const struct in_addr *my_ip) dst.sin_len = sizeof (struct sockaddr_in); #endif dst.sin_addr = dummy; - err = sendto (rawsock, - packet, off, 0, (struct sockaddr *) &dst, sizeof (dst)); + err = + sendto (rawsock, packet, off, 0, (struct sockaddr *) &dst, sizeof (dst)); if (err < 0) { #if VERBOSE @@ -368,9 +369,10 @@ process_icmp_response () switch (ip_pkt.proto) { case IPPROTO_ICMP: - if (have != (sizeof (struct ip_header) * 2 + - sizeof (struct icmp_ttl_exceeded_header) + - sizeof (struct icmp_echo_header))) + if (have != + (sizeof (struct ip_header) * 2 + + sizeof (struct icmp_ttl_exceeded_header) + + sizeof (struct icmp_echo_header))) { /* malformed */ return; @@ -380,9 +382,9 @@ process_icmp_response () port = (uint16_t) ntohl (icmp_echo.reserved); break; case IPPROTO_UDP: - if (have != (sizeof (struct ip_header) * 2 + - sizeof (struct icmp_ttl_exceeded_header) + - sizeof (struct udp_header))) + if (have != + (sizeof (struct ip_header) * 2 + + sizeof (struct icmp_ttl_exceeded_header) + sizeof (struct udp_header))) { /* malformed */ return; @@ -397,13 +399,12 @@ process_icmp_response () } if (port == 0) - fprintf (stdout, - "%s\n", inet_ntop (AF_INET, &source_ip, buf, sizeof (buf))); + fprintf (stdout, "%s\n", + inet_ntop (AF_INET, &source_ip, buf, sizeof (buf))); else - fprintf (stdout, - "%s:%u\n", - inet_ntop (AF_INET, - &source_ip, buf, sizeof (buf)), (unsigned int) port); + fprintf (stdout, "%s:%u\n", + inet_ntop (AF_INET, &source_ip, buf, sizeof (buf)), + (unsigned int) port); fflush (stdout); } @@ -426,9 +427,8 @@ make_icmp_socket () } if (ret >= FD_SETSIZE) { - fprintf (stderr, - "Socket number too large (%d > %u)\n", - ret, (unsigned int) FD_SETSIZE); + fprintf (stderr, "Socket number too large (%d > %u)\n", ret, + (unsigned int) FD_SETSIZE); close (ret); return -1; } @@ -453,15 +453,15 @@ make_raw_socket () fprintf (stderr, "Error opening RAW socket: %s\n", strerror (errno)); return -1; } - if (-1 == setsockopt (ret, - SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof (one))) + if (-1 == + setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof (one))) { fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); close (ret); return -1; } - if (-1 == setsockopt (ret, - IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one))) + if (-1 == + setsockopt (ret, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one))) { fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); close (ret); @@ -499,9 +499,8 @@ make_udp_socket (const struct in_addr *my_ip) if (0 != bind (ret, &addr, sizeof (addr))) { - fprintf (stderr, - "Error binding UDP socket to port %u: %s\n", - NAT_TRAV_PORT, strerror (errno)); + fprintf (stderr, "Error binding UDP socket to port %u: %s\n", NAT_TRAV_PORT, + strerror (errno)); /* likely problematic, but not certain, try to continue */ } return ret; diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 3b4ec2293..988e9fbc9 100644 --- a/src/nat/gnunet-nat-server.c +++ b/src/nat/gnunet-nat-server.c @@ -148,13 +148,11 @@ try_send_tcp (uint32_t dst_ipv4, uint16_t dport, uint16_t data) sa.sin_addr.s_addr = dst_ipv4; sa.sin_port = htons (dport); #if DEBUG_NAT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending TCP message to `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending TCP message to `%s'\n", GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa))); #endif if ((GNUNET_OK != - GNUNET_NETWORK_socket_connect (s, - (const struct sockaddr *) &sa, + GNUNET_NETWORK_socket_connect (s, (const struct sockaddr *) &sa, sizeof (sa))) && (errno != EINPROGRESS)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "connect"); @@ -196,14 +194,12 @@ try_send_udp (uint32_t dst_ipv4, uint16_t dport, uint16_t data) sa.sin_addr.s_addr = dst_ipv4; sa.sin_port = htons (dport); #if DEBUG_NAT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending UDP packet to `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending UDP packet to `%s'\n", GNUNET_a2s ((struct sockaddr *) &sa, sizeof (sa))); #endif - if (-1 == GNUNET_NETWORK_socket_sendto (s, - &data, sizeof (data), - (const struct sockaddr *) &sa, - sizeof (sa))) + if (-1 == + GNUNET_NETWORK_socket_sendto (s, &data, sizeof (data), + (const struct sockaddr *) &sa, sizeof (sa))) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto"); GNUNET_NETWORK_socket_close (s); } @@ -218,8 +214,7 @@ try_send_udp (uint32_t dst_ipv4, uint16_t dport, uint16_t data) * @param msg message with details about what to test */ static void -test (void *cls, - struct GNUNET_SERVER_Client *client, +test (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *msg) { const struct GNUNET_NAT_TestMessage *tm; @@ -263,9 +258,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { {&test, NULL, GNUNET_MESSAGE_TYPE_NAT_TEST, @@ -288,8 +282,8 @@ run (void *cls, }; cfg = c; - if ((args[0] == NULL) || - (1 != SSCANF (args[0], "%u", &port)) || (0 == port) || (65536 <= port)) + if ((args[0] == NULL) || (1 != SSCANF (args[0], "%u", &port)) || (0 == port) + || (65536 <= port)) { fprintf (stderr, _ @@ -307,12 +301,12 @@ run (void *cls, in4.sin_len = sizeof (in4); in6.sin6_len = sizeof (in6); #endif - server = GNUNET_SERVER_create (NULL, NULL, - (struct sockaddr * const *) sa, - slen, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); + server = + GNUNET_SERVER_create (NULL, NULL, (struct sockaddr * const *) sa, slen, + GNUNET_TIME_UNIT_SECONDS, GNUNET_YES); GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); } @@ -331,10 +325,9 @@ main (int argc, char *const argv[]) }; if (GNUNET_OK != - GNUNET_PROGRAM_run (argc, argv, - "gnunet-nat-server [options] PORT", - _("GNUnet NAT traversal test helper daemon"), - options, &run, NULL)) + GNUNET_PROGRAM_run (argc, argv, "gnunet-nat-server [options] PORT", + _("GNUnet NAT traversal test helper daemon"), options, + &run, NULL)) return 1; return 0; } diff --git a/src/nat/nat.c b/src/nat/nat.c index ed72be9f8..6069d40ad 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -386,8 +386,7 @@ remove_from_address_list_by_source (struct GNUNET_NAT_Handle *h, continue; GNUNET_CONTAINER_DLL_remove (h->lal_head, h->lal_tail, pos); if (NULL != h->address_callback) - h->address_callback (h->callback_cls, - GNUNET_NO, + h->address_callback (h->callback_cls, GNUNET_NO, (const struct sockaddr *) &pos[1], pos->addrlen); GNUNET_free (pos); } @@ -416,10 +415,10 @@ add_to_address_list_as_is (struct GNUNET_NAT_Handle *h, lal->source = src; GNUNET_CONTAINER_DLL_insert (h->lal_head, h->lal_tail, lal); #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", - "Adding address `%s' from source %d\n", - GNUNET_a2s (arg, arg_size), src); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", + "Adding address `%s' from source %d\n", GNUNET_a2s (arg, + arg_size), + src); #endif if (NULL != h->address_callback) h->address_callback (h->callback_cls, GNUNET_YES, arg, arg_size); @@ -438,8 +437,7 @@ add_to_address_list_as_is (struct GNUNET_NAT_Handle *h, * @param arg_size number of bytes in arg */ static void -add_to_address_list (struct GNUNET_NAT_Handle *h, - enum LocalAddressSource src, +add_to_address_list (struct GNUNET_NAT_Handle *h, enum LocalAddressSource src, const struct sockaddr *arg, socklen_t arg_size) { struct sockaddr_in s4; @@ -452,17 +450,13 @@ add_to_address_list (struct GNUNET_NAT_Handle *h, in4 = (const struct sockaddr_in *) arg; s4 = *in4; s4.sin_port = htons (h->adv_port); - add_to_address_list_as_is (h, - src, - (const struct sockaddr *) &s4, + add_to_address_list_as_is (h, src, (const struct sockaddr *) &s4, sizeof (struct sockaddr_in)); if (GNUNET_YES == h->enable_nat_server) { /* also add with PORT = 0 to indicate NAT server is enabled */ s4.sin_port = htons (0); - add_to_address_list_as_is (h, - src, - (const struct sockaddr *) &s4, + add_to_address_list_as_is (h, src, (const struct sockaddr *) &s4, sizeof (struct sockaddr_in)); } } @@ -473,9 +467,7 @@ add_to_address_list (struct GNUNET_NAT_Handle *h, in6 = (const struct sockaddr_in6 *) arg; s6 = *in6; s6.sin6_port = htons (h->adv_port); - add_to_address_list_as_is (h, - src, - (const struct sockaddr *) &s6, + add_to_address_list_as_is (h, src, (const struct sockaddr *) &s6, sizeof (struct sockaddr_in6)); } } @@ -497,8 +489,8 @@ add_to_address_list (struct GNUNET_NAT_Handle *h, */ static void add_ip_to_address_list (struct GNUNET_NAT_Handle *h, - enum LocalAddressSource src, - const void *addr, socklen_t addrlen) + enum LocalAddressSource src, const void *addr, + socklen_t addrlen) { struct sockaddr_in s4; const struct in_addr *in4; @@ -515,17 +507,13 @@ add_ip_to_address_list (struct GNUNET_NAT_Handle *h, s4.sin_len = (u_char) sizeof (struct sockaddr_in); #endif s4.sin_addr = *in4; - add_to_address_list (h, - src, - (const struct sockaddr *) &s4, + add_to_address_list (h, src, (const struct sockaddr *) &s4, sizeof (struct sockaddr_in)); if (GNUNET_YES == h->enable_nat_server) { /* also add with PORT = 0 to indicate NAT server is enabled */ s4.sin_port = htons (0); - add_to_address_list (h, - src, - (const struct sockaddr *) &s4, + add_to_address_list (h, src, (const struct sockaddr *) &s4, sizeof (struct sockaddr_in)); } @@ -542,9 +530,7 @@ add_ip_to_address_list (struct GNUNET_NAT_Handle *h, s6.sin6_len = (u_char) sizeof (struct sockaddr_in6); #endif s6.sin6_addr = *in6; - add_to_address_list (h, - src, - (const struct sockaddr *) &s6, + add_to_address_list (h, src, (const struct sockaddr *) &s6, sizeof (struct sockaddr_in6)); } } @@ -562,8 +548,8 @@ add_ip_to_address_list (struct GNUNET_NAT_Handle *h, * @param cls the NAT handle * @param tc scheduler context */ -static void -resolve_dns (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void resolve_dns (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -585,8 +571,8 @@ process_external_ip (void *cls, const struct sockaddr *addr, socklen_t addrlen) h->ext_dns = NULL; if (1 == inet_pton (AF_INET, h->external_address, &dummy)) return; /* repated lookup pointless: was numeric! */ - h->dns_task = GNUNET_SCHEDULER_add_delayed (h->dyndns_frequency, - &resolve_dns, h); + h->dns_task = + GNUNET_SCHEDULER_add_delayed (h->dyndns_frequency, &resolve_dns, h); return; } add_to_address_list (h, LAL_EXTERNAL_IP, addr, addrlen); @@ -599,8 +585,8 @@ process_external_ip (void *cls, const struct sockaddr *addr, socklen_t addrlen) * @param cls the NAT handle * @param tc scheduler context */ -static void -resolve_hostname (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void resolve_hostname (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -620,8 +606,9 @@ process_hostname_ip (void *cls, const struct sockaddr *addr, socklen_t addrlen) if (addr == NULL) { h->hostname_dns = NULL; - h->hostname_task = GNUNET_SCHEDULER_add_delayed (h->hostname_dns_frequency, - &resolve_hostname, h); + h->hostname_task = + GNUNET_SCHEDULER_add_delayed (h->hostname_dns_frequency, + &resolve_hostname, h); return; } add_to_address_list (h, LAL_HOSTNAME_DNS, addr, addrlen); @@ -640,9 +627,7 @@ process_hostname_ip (void *cls, const struct sockaddr *addr, socklen_t addrlen) * @return GNUNET_OK to continue iterating */ static int -process_interfaces (void *cls, - const char *name, - int isDefault, +process_interfaces (void *cls, const char *name, int isDefault, const struct sockaddr *addr, socklen_t addrlen) { struct GNUNET_NAT_Handle *h = cls; @@ -657,9 +642,8 @@ process_interfaces (void *cls, s4 = (struct sockaddr_in *) addr; ip = &s4->sin_addr; if (GNUNET_YES == h->use_localaddresses) - add_ip_to_address_list (h, - LAL_INTERFACE_ADDRESS, - &s4->sin_addr, sizeof (struct in_addr)); + add_ip_to_address_list (h, LAL_INTERFACE_ADDRESS, &s4->sin_addr, + sizeof (struct in_addr)); break; case AF_INET6: s6 = (struct sockaddr_in6 *) addr; @@ -670,24 +654,22 @@ process_interfaces (void *cls, } ip = &s6->sin6_addr; if (GNUNET_YES == h->use_localaddresses) - add_ip_to_address_list (h, - LAL_INTERFACE_ADDRESS, - &s6->sin6_addr, sizeof (struct in6_addr)); + add_ip_to_address_list (h, LAL_INTERFACE_ADDRESS, &s6->sin6_addr, + sizeof (struct in6_addr)); break; default: GNUNET_break (0); return GNUNET_OK; } - if ((h->internal_address == NULL) && - (h->server_proc == NULL) && + if ((h->internal_address == NULL) && (h->server_proc == NULL) && (h->server_read_task == GNUNET_SCHEDULER_NO_TASK) && - (GNUNET_YES == isDefault) && - ((addr->sa_family == AF_INET) || (addr->sa_family == AF_INET6))) + (GNUNET_YES == isDefault) && ((addr->sa_family == AF_INET) || + (addr->sa_family == AF_INET6))) { /* no internal address configured, but we found a "default" * interface, try using that as our 'internal' address */ - h->internal_address = GNUNET_strdup (inet_ntop (addr->sa_family, - ip, buf, sizeof (buf))); + h->internal_address = + GNUNET_strdup (inet_ntop (addr->sa_family, ip, buf, sizeof (buf))); start_gnunet_nat_server (h); } return GNUNET_OK; @@ -736,13 +718,12 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) return; memset (mybuf, 0, sizeof (mybuf)); - bytes = GNUNET_DISK_file_read (h->server_stdout_handle, - mybuf, sizeof (mybuf)); + bytes = + GNUNET_DISK_file_read (h->server_stdout_handle, mybuf, sizeof (mybuf)); if (bytes < 1) { #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "Finished reading from server stdout with code: %d\n", bytes); #endif @@ -787,13 +768,11 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if HAVE_SOCKADDR_IN_SIN_LEN sin_addr.sin_len = sizeof (sin_addr); #endif - if ((NULL == port_start) || - (1 != sscanf (port_start, "%d", &port)) || + if ((NULL == port_start) || (1 != sscanf (port_start, "%d", &port)) || (-1 == inet_pton (AF_INET, mybuf, &sin_addr.sin_addr))) { /* should we restart gnunet-helper-nat-server? */ - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "nat", _ ("gnunet-helper-nat-server generated malformed address `%s'\n"), mybuf); @@ -805,16 +784,15 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } sin_addr.sin_port = htons ((uint16_t) port); #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "gnunet-helper-nat-server read: %s:%d\n", mybuf, port); #endif - h->reversal_callback (h->callback_cls, - (const struct sockaddr *) &sin_addr, sizeof (sin_addr)); + h->reversal_callback (h->callback_cls, (const struct sockaddr *) &sin_addr, + sizeof (sin_addr)); h->server_read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - h->server_stdout_handle, - &nat_server_read, h); + h->server_stdout_handle, &nat_server_read, + h); } @@ -827,28 +805,25 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void start_gnunet_nat_server (struct GNUNET_NAT_Handle *h) { - if ((h->behind_nat == GNUNET_YES) && - (h->enable_nat_server == GNUNET_YES) && + if ((h->behind_nat == GNUNET_YES) && (h->enable_nat_server == GNUNET_YES) && (h->internal_address != NULL) && - (NULL != (h->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, - GNUNET_NO, GNUNET_YES)))) + (NULL != + (h->server_stdout = + GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES)))) { #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat" - "Starting %s at `%s'\n", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat" "Starting %s at `%s'\n", "gnunet-helper-nat-server", h->internal_address); #endif /* Start the server process */ - h->server_proc = GNUNET_OS_start_process (NULL, - h->server_stdout, - "gnunet-helper-nat-server", - "gnunet-helper-nat-server", - h->internal_address, NULL); + h->server_proc = + GNUNET_OS_start_process (NULL, h->server_stdout, + "gnunet-helper-nat-server", + "gnunet-helper-nat-server", + h->internal_address, NULL); if (h->server_proc == NULL) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "nat", _("Failed to start %s\n"), "gnunet-helper-nat-server"); GNUNET_DISK_pipe_close (h->server_stdout); h->server_stdout = NULL; @@ -857,13 +832,12 @@ start_gnunet_nat_server (struct GNUNET_NAT_Handle *h) { /* Close the write end of the read pipe */ GNUNET_DISK_pipe_close_end (h->server_stdout, GNUNET_DISK_PIPE_END_WRITE); - h->server_stdout_handle - = GNUNET_DISK_pipe_handle (h->server_stdout, - GNUNET_DISK_PIPE_END_READ); - h->server_read_task - = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - h->server_stdout_handle, - &nat_server_read, h); + h->server_stdout_handle = + GNUNET_DISK_pipe_handle (h->server_stdout, GNUNET_DISK_PIPE_END_READ); + h->server_read_task = + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, + h->server_stdout_handle, + &nat_server_read, h); } } } @@ -883,8 +857,8 @@ list_interfaces (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) h->ifc_task = GNUNET_SCHEDULER_NO_TASK; remove_from_address_list_by_source (h, LAL_INTERFACE_ADDRESS); GNUNET_OS_network_interfaces_list (&process_interfaces, h); - h->ifc_task = GNUNET_SCHEDULER_add_delayed (h->ifc_scan_frequency, - &list_interfaces, h); + h->ifc_task = + GNUNET_SCHEDULER_add_delayed (h->ifc_scan_frequency, &list_interfaces, h); } @@ -901,9 +875,9 @@ resolve_hostname (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) h->hostname_task = GNUNET_SCHEDULER_NO_TASK; remove_from_address_list_by_source (h, LAL_HOSTNAME_DNS); - h->hostname_dns = GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, - HOSTNAME_RESOLVE_TIMEOUT, - &process_hostname_ip, h); + h->hostname_dns = + GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, HOSTNAME_RESOLVE_TIMEOUT, + &process_hostname_ip, h); } @@ -921,10 +895,10 @@ resolve_dns (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) h->dns_task = GNUNET_SCHEDULER_NO_TASK; remove_from_address_list_by_source (h, LAL_EXTERNAL_IP); - h->ext_dns = GNUNET_RESOLVER_ip_get (h->external_address, - AF_INET, - GNUNET_TIME_UNIT_MINUTES, - &process_external_ip, h); + h->ext_dns = + GNUNET_RESOLVER_ip_get (h->external_address, AF_INET, + GNUNET_TIME_UNIT_MINUTES, &process_external_ip, + h); } @@ -938,8 +912,8 @@ resolve_dns (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param addrlen actual lenght of the address */ static void -upnp_add (void *cls, - int add_remove, const struct sockaddr *addr, socklen_t addrlen) +upnp_add (void *cls, int add_remove, const struct sockaddr *addr, + socklen_t addrlen) { struct GNUNET_NAT_Handle *h = cls; struct LocalAddressList *pos; @@ -955,13 +929,12 @@ upnp_add (void *cls, while (NULL != (pos = next)) { next = pos->next; - if ((pos->source != LAL_UPNP) || - (pos->addrlen != addrlen) || (0 != memcmp (&pos[1], addr, addrlen))) + if ((pos->source != LAL_UPNP) || (pos->addrlen != addrlen) || + (0 != memcmp (&pos[1], addr, addrlen))) continue; GNUNET_CONTAINER_DLL_remove (h->lal_head, h->lal_tail, pos); if (NULL != h->address_callback) - h->address_callback (h->callback_cls, - GNUNET_NO, + h->address_callback (h->callback_cls, GNUNET_NO, (const struct sockaddr *) &pos[1], pos->addrlen); GNUNET_free (pos); return; /* only remove once */ @@ -1036,8 +1009,9 @@ add_from_bind (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_break (0); break; } - if (0 != memcmp (&((const struct sockaddr_in6 *) sa)->sin6_addr, - &any, sizeof (struct in6_addr))) + if (0 != + memcmp (&((const struct sockaddr_in6 *) sa)->sin6_addr, &any, + sizeof (struct in6_addr))) add_to_address_list (h, LAL_BINDTO_ADDRESS, sa, sizeof (struct sockaddr_in6)); break; @@ -1068,12 +1042,9 @@ add_from_bind (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return NULL on error, otherwise handle that can be used to unregister */ struct GNUNET_NAT_Handle * -GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, - int is_tcp, - uint16_t adv_port, - unsigned int num_addrs, - const struct sockaddr **addrs, - const socklen_t * addrlens, +GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp, + uint16_t adv_port, unsigned int num_addrs, + const struct sockaddr **addrs, const socklen_t * addrlens, GNUNET_NAT_AddressCallback address_callback, GNUNET_NAT_ReversalCallback reversal_callback, void *callback_cls) @@ -1083,8 +1054,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int i; #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "Registered with NAT service at port %u with %u IP bound local addresses\n", (unsigned int) adv_port, num_addrs); #endif @@ -1114,16 +1084,14 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, if (GNUNET_OK == GNUNET_CONFIGURATION_have_value (cfg, "nat", "INTERNAL_ADDRESS")) { - (void) GNUNET_CONFIGURATION_get_value_string (cfg, - "nat", + (void) GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "INTERNAL_ADDRESS", &h->internal_address); } if ((h->internal_address != NULL) && (inet_pton (AF_INET, h->internal_address, &in_addr) != 1)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "nat", _("Malformed %s `%s' given in configuration!\n"), "INTERNAL_ADDRESS", h->internal_address); GNUNET_free (h->internal_address); @@ -1133,57 +1101,45 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, if (GNUNET_OK == GNUNET_CONFIGURATION_have_value (cfg, "nat", "EXTERNAL_ADDRESS")) { - (void) GNUNET_CONFIGURATION_get_value_string (cfg, - "nat", + (void) GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "EXTERNAL_ADDRESS", &h->external_address); } if ((h->external_address != NULL) && (inet_pton (AF_INET, h->external_address, &in_addr) != 1)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "nat", _("Malformed %s `%s' given in configuration!\n"), "EXTERNAL_ADDRESS", h->external_address); GNUNET_free (h->external_address); h->external_address = NULL; } - h->behind_nat = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", "BEHIND_NAT"); - h->nat_punched = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", "PUNCHED_NAT"); - h->enable_nat_client = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", - "ENABLE_NAT_CLIENT"); - h->enable_nat_server = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", - "ENABLE_NAT_SERVER"); - h->enable_upnp = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", "ENABLE_UPNP"); - h->use_localaddresses = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", - "USE_LOCALADDR"); - h->use_hostname = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", - "USE_HOSTNAME"); - h->disable_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "nat", "DISABLEV6"); + h->behind_nat = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "BEHIND_NAT"); + h->nat_punched = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "PUNCHED_NAT"); + h->enable_nat_client = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "ENABLE_NAT_CLIENT"); + h->enable_nat_server = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "ENABLE_NAT_SERVER"); + h->enable_upnp = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "ENABLE_UPNP"); + h->use_localaddresses = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "USE_LOCALADDR"); + h->use_hostname = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "USE_HOSTNAME"); + h->disable_ipv6 = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "DISABLEV6"); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "nat", - "DYNDNS_FREQUENCY", + GNUNET_CONFIGURATION_get_value_time (cfg, "nat", "DYNDNS_FREQUENCY", &h->dyndns_frequency)) h->dyndns_frequency = DYNDNS_FREQUENCY; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "nat", - "IFC_SCAN_FREQUENCY", + GNUNET_CONFIGURATION_get_value_time (cfg, "nat", "IFC_SCAN_FREQUENCY", &h->ifc_scan_frequency)) h->ifc_scan_frequency = IFC_SCAN_FREQUENCY; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "nat", - "HOSTNAME_DNS_FREQUENCY", + GNUNET_CONFIGURATION_get_value_time (cfg, "nat", "HOSTNAME_DNS_FREQUENCY", &h->hostname_dns_frequency)) h->hostname_dns_frequency = HOSTNAME_DNS_FREQUENCY; @@ -1191,8 +1147,8 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, h->enable_nat_server = GNUNET_NO; /* Check if NAT was hole-punched */ - if ((NULL != h->address_callback) && - (h->external_address != NULL) && (h->nat_punched == GNUNET_YES)) + if ((NULL != h->address_callback) && (h->external_address != NULL) && + (h->nat_punched == GNUNET_YES)) { h->dns_task = GNUNET_SCHEDULER_add_now (&resolve_dns, h); h->enable_nat_server = GNUNET_NO; @@ -1200,8 +1156,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, } /* Test for SUID binaries */ - if ((h->behind_nat == GNUNET_YES) && - (GNUNET_YES == h->enable_nat_server) && + if ((h->behind_nat == GNUNET_YES) && (GNUNET_YES == h->enable_nat_server) && (GNUNET_YES != GNUNET_OS_check_helper_binary ("gnunet-helper-nat-server"))) { @@ -1313,8 +1268,7 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h) { GNUNET_CONTAINER_DLL_remove (h->lal_head, h->lal_tail, lal); if (NULL != h->address_callback) - h->address_callback (h->callback_cls, - GNUNET_NO, + h->address_callback (h->callback_cls, GNUNET_NO, (const struct sockaddr *) &lal[1], lal->addrlen); GNUNET_free (lal); } @@ -1349,8 +1303,7 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, if (h->internal_address == NULL) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "nat", _ ("Internal IP address not known, cannot use ICMP NAT traversal method\n")); return; @@ -1363,17 +1316,14 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, } GNUNET_snprintf (port_as_string, sizeof (port_as_string), "%d", h->adv_port); #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", _("Running gnunet-helper-nat-client %s %s %u\n"), h->internal_address, inet4, (unsigned int) h->adv_port); #endif - proc = GNUNET_OS_start_process (NULL, - NULL, - "gnunet-helper-nat-client", - "gnunet-helper-nat-client", - h->internal_address, - inet4, port_as_string, NULL); + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-nat-client", + "gnunet-helper-nat-client", h->internal_address, + inet4, port_as_string, NULL); if (NULL == proc) return; /* we know that the gnunet-helper-nat-client will terminate virtually @@ -1394,8 +1344,8 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, * GNUNET_SYSERR if the address is malformed */ int -GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, - const void *addr, socklen_t addrlen) +GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr, + socklen_t addrlen) { struct LocalAddressList *pos; const struct sockaddr_in *in4; diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index c40231067..e88c9ca55 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c @@ -118,8 +118,9 @@ read_external_ipv4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) eh->task = GNUNET_SCHEDULER_NO_TASK; if (GNUNET_YES == GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, eh->r)) - ret = GNUNET_DISK_file_read (eh->r, - &eh->buf[eh->off], sizeof (eh->buf) - eh->off); + ret = + GNUNET_DISK_file_read (eh->r, &eh->buf[eh->off], + sizeof (eh->buf) - eh->off); else ret = -1; /* error reading, timeout, etc. */ if (ret > 0) @@ -172,9 +173,9 @@ GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout, GNUNET_free (eh); return NULL; } - eh->eip = GNUNET_OS_start_process (NULL, - eh->opipe, - "external-ip", "external-ip", NULL); + eh->eip = + GNUNET_OS_start_process (NULL, eh->opipe, "external-ip", "external-ip", + NULL); if (NULL == eh->eip) { GNUNET_DISK_pipe_close (eh->opipe); @@ -184,8 +185,8 @@ GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout, GNUNET_DISK_pipe_close_end (eh->opipe, GNUNET_DISK_PIPE_END_WRITE); eh->timeout = GNUNET_TIME_relative_to_absolute (timeout); eh->r = GNUNET_DISK_pipe_handle (eh->opipe, GNUNET_DISK_PIPE_END_READ); - eh->task = GNUNET_SCHEDULER_add_read_file (timeout, - eh->r, &read_external_ipv4, eh); + eh->task = + GNUNET_SCHEDULER_add_read_file (timeout, eh->r, &read_external_ipv4, eh); return eh; } @@ -278,8 +279,8 @@ struct GNUNET_NAT_MiniHandle * @param cls the 'struct GNUNET_NAT_MiniHandle' * @param tc scheduler context */ -static void -do_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void do_refresh (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -322,19 +323,15 @@ process_refresh_output (void *cls, const char *line) mini->did_map = GNUNET_NO; } GNUNET_snprintf (pstr, sizeof (pstr), "%u", (unsigned int) mini->port); - mini->map_cmd = GNUNET_OS_command_run (&process_map_output, - mini, - MAP_TIMEOUT, - "upnpc", - "upnpc", - "-r", pstr, - mini->is_tcp ? "tcp" : "udp", - NULL); + mini->map_cmd = + GNUNET_OS_command_run (&process_map_output, mini, MAP_TIMEOUT, + "upnpc", "upnpc", "-r", pstr, + mini->is_tcp ? "tcp" : "udp", NULL); if (NULL != mini->map_cmd) return; } - mini->refresh_task = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, - &do_refresh, mini); + mini->refresh_task = + GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, mini); return; } if (!mini->did_map) @@ -377,10 +374,11 @@ process_refresh_output (void *cls, const char *line) return; /* skip */ if (NULL == strstr (s, pstr)) return; /* skip */ - if (1 != sscanf (line, - (mini->is_tcp) - ? "%*u TCP %u->%*s:%*u %*s" - : "%*u UDP %u->%*s:%*u %*s", &nport)) + if (1 != + sscanf (line, + (mini-> + is_tcp) ? "%*u TCP %u->%*s:%*u %*s" : + "%*u UDP %u->%*s:%*u %*s", &nport)) return; /* skip */ mini->found = GNUNET_YES; if (nport == ntohs (mini->current_addr.sin_port)) @@ -410,10 +408,9 @@ do_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) mini->refresh_task = GNUNET_SCHEDULER_NO_TASK; mini->found = GNUNET_NO; - mini->refresh_cmd = GNUNET_OS_command_run (&process_refresh_output, - mini, - MAP_TIMEOUT, - "upnpc", "upnpc", "-l", NULL); + mini->refresh_cmd = + GNUNET_OS_command_run (&process_refresh_output, mini, MAP_TIMEOUT, + "upnpc", "upnpc", "-l", NULL); } @@ -436,8 +433,8 @@ process_map_output (void *cls, const char *line) { GNUNET_OS_command_stop (mini->map_cmd); mini->map_cmd = NULL; - mini->refresh_task = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, - &do_refresh, mini); + mini->refresh_task = + GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, mini); return; } /* @@ -486,8 +483,7 @@ process_map_output (void *cls, const char *line) * @return NULL on error (no 'upnpc' installed) */ struct GNUNET_NAT_MiniHandle * -GNUNET_NAT_mini_map_start (uint16_t port, - int is_tcp, +GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, GNUNET_NAT_AddressCallback ac, void *ac_cls) { struct GNUNET_NAT_MiniHandle *ret; @@ -501,17 +497,13 @@ GNUNET_NAT_mini_map_start (uint16_t port, ret->is_tcp = is_tcp; ret->port = port; GNUNET_snprintf (pstr, sizeof (pstr), "%u", (unsigned int) port); - ret->map_cmd = GNUNET_OS_command_run (&process_map_output, - ret, - MAP_TIMEOUT, - "upnpc", - "upnpc", - "-r", pstr, - is_tcp ? "tcp" : "udp", NULL); + ret->map_cmd = + GNUNET_OS_command_run (&process_map_output, ret, MAP_TIMEOUT, "upnpc", + "upnpc", "-r", pstr, is_tcp ? "tcp" : "udp", NULL); if (NULL != ret->map_cmd) return ret; - ret->refresh_task = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, - &do_refresh, ret); + ret->refresh_task = + GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ, &do_refresh, ret); return ret; } @@ -581,21 +573,17 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini) /* Note: oddly enough, deletion uses the external port whereas * addition uses the internal port; this rarely matters since they * often are the same, but it might... */ - GNUNET_snprintf (pstr, sizeof (pstr), - "%u", (unsigned int) ntohs (mini->current_addr.sin_port)); + GNUNET_snprintf (pstr, sizeof (pstr), "%u", + (unsigned int) ntohs (mini->current_addr.sin_port)); #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "Unmapping port %u with UPnP\n", ntohs (mini->current_addr.sin_port)); #endif - mini->unmap_cmd = GNUNET_OS_command_run (&process_unmap_output, - mini, - UNMAP_TIMEOUT, - "upnpc", - "upnpc", - "-d", pstr, - mini->is_tcp ? "tcp" : "udp", NULL); + mini->unmap_cmd = + GNUNET_OS_command_run (&process_unmap_output, mini, UNMAP_TIMEOUT, + "upnpc", "upnpc", "-d", pstr, + mini->is_tcp ? "tcp" : "udp", NULL); } diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 30db00803..74bb758dd 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c @@ -178,8 +178,7 @@ reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen) if (h->data != sa->sin_port) { #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "Received connection reversal request for wrong port\n"); #endif return; /* wrong port */ @@ -202,11 +201,11 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_NAT_Test *tst = cls; uint16_t data; - tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - tst->lsock, &do_udp_read, tst); + tst->ltask = + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, tst->lsock, + &do_udp_read, tst); if ((NULL != tc->write_ready) && - (GNUNET_NETWORK_fdset_isset (tc->read_ready, - tst->lsock)) && + (GNUNET_NETWORK_fdset_isset (tc->read_ready, tst->lsock)) && (sizeof (data) == GNUNET_NETWORK_socket_recv (tst->lsock, &data, sizeof (data)))) { @@ -214,14 +213,14 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) tst->report (tst->report_cls, GNUNET_OK); #if DEBUG_NAT else - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", "Received data mismatches expected value\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", + "Received data mismatches expected value\n"); #endif } #if DEBUG_NAT else - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", "Failed to receive data from inbound connection\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", + "Failed to receive data from inbound connection\n"); #endif } @@ -244,8 +243,7 @@ do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) tst = na->h; GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na); if ((NULL != tc->write_ready) && - (GNUNET_NETWORK_fdset_isset (tc->read_ready, - na->sock)) && + (GNUNET_NETWORK_fdset_isset (tc->read_ready, na->sock)) && (sizeof (data) == GNUNET_NETWORK_socket_recv (na->sock, &data, sizeof (data)))) { @@ -259,8 +257,8 @@ do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } #if DEBUG_NAT else - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", "Failed to receive data from inbound connection\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", + "Failed to receive data from inbound connection\n"); #endif GNUNET_NETWORK_socket_close (na->sock); GNUNET_free (na); @@ -284,8 +282,9 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) tst->ltask = GNUNET_SCHEDULER_NO_TASK; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) return; - tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - tst->lsock, &do_accept, tst); + tst->ltask = + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, tst->lsock, + &do_accept, tst); s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); if (NULL == s) { @@ -293,14 +292,15 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; /* odd error */ } #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", "Got an inbound connection, waiting for data\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", + "Got an inbound connection, waiting for data\n"); #endif wl = GNUNET_malloc (sizeof (struct NatActivity)); wl->sock = s; wl->h = tst; - wl->rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - wl->sock, &do_read, wl); + wl->rtask = + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, wl->sock, + &do_read, wl); GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl); } @@ -315,8 +315,8 @@ do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param addrlen actual lenght of the address */ static void -addr_cb (void *cls, - int add_remove, const struct sockaddr *addr, socklen_t addrlen) +addr_cb (void *cls, int add_remove, const struct sockaddr *addr, + socklen_t addrlen) { struct GNUNET_NAT_Test *h = cls; struct ClientActivity *ca; @@ -329,8 +329,7 @@ addr_cb (void *cls, if (addrlen != sizeof (struct sockaddr_in)) return; /* ignore IPv6 here */ #if DEBUG_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "nat", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "nat", "Asking gnunet-nat-server to connect to `%s'\n", GNUNET_a2s (addr, addrlen)); #endif @@ -353,11 +352,10 @@ addr_cb (void *cls, ca->client = client; GNUNET_CONTAINER_DLL_insert (h->ca_head, h->ca_tail, ca); GNUNET_break (GNUNET_OK == - GNUNET_CLIENT_transmit_and_get_response (client, - &msg.header, + GNUNET_CLIENT_transmit_and_get_response (client, &msg.header, GNUNET_TIME_UNIT_SECONDS, - GNUNET_YES, - NULL, NULL)); + GNUNET_YES, NULL, + NULL)); } @@ -375,9 +373,7 @@ addr_cb (void *cls, */ struct GNUNET_NAT_Test * GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, - int is_tcp, - uint16_t bnd_port, - uint16_t adv_port, + int is_tcp, uint16_t bnd_port, uint16_t adv_port, GNUNET_NAT_TestCallback report, void *report_cls) { struct GNUNET_NAT_Test *ret; @@ -401,19 +397,21 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, ret->report_cls = report_cls; if (bnd_port == 0) { - ret->nat = GNUNET_NAT_register (cfg, is_tcp, - 0, - 0, NULL, NULL, &addr_cb, &reversal_cb, ret); + ret->nat = + GNUNET_NAT_register (cfg, is_tcp, 0, 0, NULL, NULL, &addr_cb, + &reversal_cb, ret); } else { - ret->lsock = GNUNET_NETWORK_socket_create (AF_INET, - (is_tcp == GNUNET_YES) - ? SOCK_STREAM : SOCK_DGRAM, 0); + ret->lsock = + GNUNET_NETWORK_socket_create (AF_INET, + (is_tcp == + GNUNET_YES) ? SOCK_STREAM : SOCK_DGRAM, + 0); if ((ret->lsock == NULL) || - (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret->lsock, - (const struct sockaddr *) &sa, - sizeof (sa)))) + (GNUNET_OK != + GNUNET_NETWORK_socket_bind (ret->lsock, (const struct sockaddr *) &sa, + sizeof (sa)))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -428,18 +426,19 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, if (GNUNET_YES == is_tcp) { GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (ret->lsock, 5)); - ret->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - ret->lsock, &do_accept, ret); + ret->ltask = + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, + ret->lsock, &do_accept, ret); } else { - ret->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - ret->lsock, - &do_udp_read, ret); + ret->ltask = + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, + ret->lsock, &do_udp_read, ret); } - ret->nat = GNUNET_NAT_register (cfg, is_tcp, - adv_port, - 1, addrs, addrlens, &addr_cb, NULL, ret); + ret->nat = + GNUNET_NAT_register (cfg, is_tcp, adv_port, 1, addrs, addrlens, + &addr_cb, NULL, ret); } return ret; } diff --git a/src/nat/test_nat.c b/src/nat/test_nat.c index 12ff30cac..6a533798e 100644 --- a/src/nat/test_nat.c +++ b/src/nat/test_nat.c @@ -55,13 +55,13 @@ * believes to be valid for the transport. */ static void -addr_callback (void *cls, int add_remove, - const struct sockaddr *addr, socklen_t addrlen) +addr_callback (void *cls, int add_remove, const struct sockaddr *addr, + socklen_t addrlen) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Address changed: %s `%s' (%u bytes)\n", - add_remove == GNUNET_YES ? "added" : "removed", - GNUNET_a2s (addr, addrlen), (unsigned int) addrlen); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address changed: %s `%s' (%u bytes)\n", + add_remove == GNUNET_YES ? "added" : "removed", GNUNET_a2s (addr, + addrlen), + (unsigned int) addrlen); } @@ -97,9 +97,8 @@ struct addr_cls * @return GNUNET_OK to continue iterating */ static int -process_if (void *cls, - const char *name, - int isDefault, const struct sockaddr *addr, socklen_t addrlen) +process_if (void *cls, const char *name, int isDefault, + const struct sockaddr *addr, socklen_t addrlen) { struct addr_cls *data = cls; @@ -119,9 +118,8 @@ process_if (void *cls, * Main function run with scheduler. */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_NAT_Handle *nat; struct addr_cls data; @@ -147,9 +145,7 @@ run (void *cls, GNUNET_a2s (addr, data.addrlen)); nat = GNUNET_NAT_register (cfg, GNUNET_YES /* tcp */ , - 2086, - 1, - (const struct sockaddr **) &addr, + 2086, 1, (const struct sockaddr **) &addr, &data.addrlen, &addr_callback, NULL, NULL); GNUNET_free (addr); GNUNET_SCHEDULER_add_delayed (TIMEOUT, &stop, nat); diff --git a/src/nat/test_nat_mini.c b/src/nat/test_nat_mini.c index 8f689d6bc..4aac3d17f 100644 --- a/src/nat/test_nat_mini.c +++ b/src/nat/test_nat_mini.c @@ -46,13 +46,13 @@ * believes to be valid for the transport. */ static void -addr_callback (void *cls, int add_remove, - const struct sockaddr *addr, socklen_t addrlen) +addr_callback (void *cls, int add_remove, const struct sockaddr *addr, + socklen_t addrlen) { - fprintf (stderr, - "Address changed: %s `%s' (%u bytes)\n", - add_remove == GNUNET_YES ? "added" : "removed", - GNUNET_a2s (addr, addrlen), (unsigned int) addrlen); + fprintf (stderr, "Address changed: %s `%s' (%u bytes)\n", + add_remove == GNUNET_YES ? "added" : "removed", GNUNET_a2s (addr, + addrlen), + (unsigned int) addrlen); } @@ -74,9 +74,8 @@ stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Main function run with scheduler. */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_NAT_MiniHandle *mini; diff --git a/src/nat/test_nat_test.c b/src/nat/test_nat_test.c index 520d82d92..b1e6235f9 100644 --- a/src/nat/test_nat_test.c +++ b/src/nat/test_nat_test.c @@ -65,12 +65,12 @@ report_success (void *cls, int success) * Main function run with scheduler. */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - tst = GNUNET_NAT_test_start (cfg, GNUNET_YES, - 1285, 1285, &report_success, NULL); + tst = + GNUNET_NAT_test_start (cfg, GNUNET_YES, 1285, 1285, &report_success, + NULL); if (NULL == tst) return; end = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); @@ -105,16 +105,16 @@ main (int argc, char *const argv[]) "WARNING", #endif NULL); - gns = GNUNET_OS_start_process (NULL, NULL, - "gnunet-nat-server", "gnunet-nat-server", + gns = + GNUNET_OS_start_process (NULL, NULL, "gnunet-nat-server", + "gnunet-nat-server", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_nat_test_data.conf", - "12345", NULL); + "-c", "test_nat_test_data.conf", "12345", NULL); GNUNET_assert (NULL != gns); - GNUNET_PROGRAM_run (5, argv_prog, - "test-nat-test", "nohelp", options, &run, NULL); + GNUNET_PROGRAM_run (5, argv_prog, "test-nat-test", "nohelp", options, &run, + NULL); GNUNET_break (0 == GNUNET_OS_process_kill (gns, SIGTERM)); GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (gns)); GNUNET_OS_process_close (gns); diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index b88dbc3fc..df26280c4 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c @@ -213,13 +213,12 @@ handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, if (output_file != NULL) { - size = GNUNET_asprintf (&output_buffer, - "%s %llu %llu %f %f %f\n", - GNUNET_i2s (&peer->daemon->id), - peers_running, - timestamp.abs_value, - GNUNET_NSE_log_estimate_to_n (estimate), - estimate, std_dev); + size = + GNUNET_asprintf (&output_buffer, "%s %llu %llu %f %f %f\n", + GNUNET_i2s (&peer->daemon->id), peers_running, + timestamp.abs_value, + GNUNET_NSE_log_estimate_to_n (estimate), estimate, + std_dev); if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); GNUNET_free (output_buffer); @@ -254,9 +253,9 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (GNUNET_YES == GNUNET_TESTING_daemon_running (GNUNET_TESTING_daemon_get (pg, i))) { - current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, - &handle_estimate, - current_peer); + current_peer->nse_handle = + GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, + current_peer); GNUNET_assert (current_peer->nse_handle != NULL); } GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); @@ -264,8 +263,8 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -static void -churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void churn_peers (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -286,9 +285,9 @@ stats_finished_callback (void *cls, int success) { /* Stats lookup successful, write out data */ buf = NULL; - buf_len = GNUNET_asprintf (&buf, - "TOTAL_NSE_BYTES: %u\n", - stats_context->total_nse_bytes); + buf_len = + GNUNET_asprintf (&buf, "TOTAL_NSE_BYTES: %u\n", + stats_context->total_nse_bytes); if (buf_len > 0) { GNUNET_DISK_file_write (data_file, buf, buf_len); @@ -314,10 +313,9 @@ stats_finished_callback (void *cls, int success) * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -statistics_iterator (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, + const char *subsystem, const char *name, uint64_t value, + int is_persistent) { struct StatsContext *stats_context = cls; @@ -350,10 +348,9 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_asprintf (&buf, "round%llu", current_round); - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "nse-profiler", - buf, - &peers_next_round)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", buf, + &peers_next_round)) { current_round++; GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); @@ -364,8 +361,7 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) stats_context = GNUNET_malloc (sizeof (struct StatsContext)); GNUNET_SCHEDULER_cancel (shutdown_handle); shutdown_handle = GNUNET_SCHEDULER_NO_TASK; - GNUNET_TESTING_get_statistics (pg, - &stats_finished_callback, + GNUNET_TESTING_get_statistics (pg, &stats_finished_callback, &statistics_iterator, stats_context); } GNUNET_free (buf); @@ -381,8 +377,8 @@ disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void topology_output_callback (void *cls, const char *emsg) { - disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, - &disconnect_nse_peers, NULL); + disconnect_task = + GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_nse_peers, NULL); GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); } @@ -404,19 +400,18 @@ churn_callback (void *cls, const char *emsg) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn finished successfully.\n", current_round); GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); - GNUNET_asprintf (&temp_output_file, - "%s_%llu.dot", topology_file, current_round); - GNUNET_TESTING_peergroup_topology_to_file (pg, - temp_output_file, + GNUNET_asprintf (&temp_output_file, "%s_%llu.dot", topology_file, + current_round); + GNUNET_TESTING_peergroup_topology_to_file (pg, temp_output_file, &topology_output_callback, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Writing topology to file %s\n", temp_output_file); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", + temp_output_file); GNUNET_free (temp_output_file); } else { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Round %llu, churn FAILED!!\n", current_round); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn FAILED!!\n", + current_round); GNUNET_SCHEDULER_cancel (shutdown_handle); shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); } @@ -433,9 +428,8 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Nothing to do... */ GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); - disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, - &disconnect_nse_peers, - NULL); + disconnect_task = + GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_nse_peers, NULL); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", current_round); } @@ -451,18 +445,18 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, turning off %llu peers, turning on %llu peers!\n", current_round, - (peers_running > peers_next_round) - ? peers_running - peers_next_round - : 0, - (peers_next_round > peers_running) - ? peers_next_round - peers_running : 0); + (peers_running > + peers_next_round) ? peers_running - peers_next_round : 0, + (peers_next_round > + peers_running) ? peers_next_round - peers_running : 0); GNUNET_TESTING_daemons_churn (pg, "nse", - (peers_running > peers_next_round) - ? peers_running - peers_next_round - : 0, - (peers_next_round > peers_running) - ? peers_next_round - peers_running - : 0, wait_time, &churn_callback, NULL); + (peers_running > + peers_next_round) ? peers_running - + peers_next_round : 0, + (peers_next_round > + peers_running) ? peers_next_round - + peers_running : 0, wait_time, &churn_callback, + NULL); } } @@ -495,8 +489,8 @@ my_cb (void *cls, const char *emsg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully, connecting to NSE service for each peer!\n"); #endif - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Have %u connections\n", total_connections); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", + total_connections); if (data_file != NULL) { buf = NULL; @@ -506,9 +500,8 @@ my_cb (void *cls, const char *emsg) GNUNET_free (buf); } peers_running = GNUNET_TESTING_daemons_running (pg); - GNUNET_TESTING_daemons_start_service (pg, - "nse", - wait_time, &nse_started_cb, NULL); + GNUNET_TESTING_daemons_start_service (pg, "nse", wait_time, &nse_started_cb, + NULL); } @@ -528,10 +521,8 @@ my_cb (void *cls, const char *emsg) * @param emsg error message (NULL on success) */ static void -connect_cb (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -543,9 +534,8 @@ connect_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *temp_str; unsigned long long temp_wait; @@ -555,100 +545,99 @@ run (void *cls, testing_cfg = GNUNET_CONFIGURATION_create (); #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); - GNUNET_CONFIGURATION_set_value_string (testing_cfg, - "testing", "use_progressbars", "YES"); + GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", + "use_progressbars", "YES"); #endif - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "testing", - "num_peers", - &num_peers)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", + "num_peers", &num_peers)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option TESTING:NUM_PEERS is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "nse-profiler", - "wait_time", - &temp_wait)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", + "wait_time", &temp_wait)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:wait_time is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "nse-profiler", - "connection_limit", - &connection_limit)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "nse-profiler", + "connection_limit", + &connection_limit)) { connection_limit = 0; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, - "nse-profiler", - "topology_output_file", - &topology_file)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", + "topology_output_file", + &topology_file)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:topology_output_file is required!\n"); return; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, - "nse-profiler", - "data_output_file", - &data_filename)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (testing_cfg, "nse-profiler", + "data_output_file", + &data_filename)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Option nse-profiler:data_output_file is required!\n"); return; } - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, - "nse-profiler", - "skew_clock")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (testing_cfg, "nse-profiler", + "skew_clock")) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Setting our clock as skewed...\n"); - clock_skew = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - GNUNET_TIME_UNIT_MINUTES.rel_value); + clock_skew = + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + GNUNET_TIME_UNIT_MINUTES.rel_value); } - data_file = GNUNET_DISK_file_open (data_filename, - GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + data_file = + GNUNET_DISK_file_open (data_filename, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (data_file == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to open %s for output!\n", data_filename); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", + data_filename); GNUNET_free (data_filename); wait_time = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, - "nse-profiler", - "output_file", - &temp_str)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "nse-profiler", "output_file", + &temp_str)) { - output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + output_file = + GNUNET_DISK_file_open (temp_str, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (output_file == NULL) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Failed to open %s for output!\n", temp_str); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", + temp_str); } GNUNET_free_non_null (temp_str); hosts = GNUNET_TESTING_hosts_load (testing_cfg); - pg = GNUNET_TESTING_peergroup_start (testing_cfg, - num_peers, - TIMEOUT, + pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT, &connect_cb, &my_cb, NULL, hosts); GNUNET_assert (pg != NULL); shutdown_handle = @@ -679,8 +668,7 @@ main (int argc, char *argv[]) "WARNING", #endif NULL); - GNUNET_PROGRAM_run (argc, - argv, "nse-profiler", + GNUNET_PROGRAM_run (argc, argv, "nse-profiler", gettext_noop ("Measure quality and performance of the NSE service."), options, &run, NULL); diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 9da9abba2..5f880088f 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -315,8 +315,10 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) sumweight = 0.0; for (i = 0; i < estimate_count; i++) { - val = htonl (size_estimate_messages[(estimate_index - i + HISTORY_SIZE) - % HISTORY_SIZE].matching_bits); + val = + htonl (size_estimate_messages + [(estimate_index - i + + HISTORY_SIZE) % HISTORY_SIZE].matching_bits); weight = 1; /* was: estimate_count + 1 - i; */ temp = weight + sumweight; @@ -338,8 +340,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) em->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); em->size_estimate = mean - 1.0 / 3.0; em->std_deviation = std_dev; - GNUNET_STATISTICS_set (stats, - "# nodes in the network (estimate)", + GNUNET_STATISTICS_set (stats, "# nodes in the network (estimate)", (uint64_t) pow (2, mean - 1.0 / 3.0), GNUNET_NO); } @@ -385,8 +386,7 @@ get_matching_bits_delay (uint32_t matching_bits) // f is frequency (gnunet_nse_interval) // x is matching_bits // p' is current_size_estimate - return ((double) gnunet_nse_interval.rel_value / (double) 2.0) - - + return ((double) gnunet_nse_interval.rel_value / (double) 2.0) - ((gnunet_nse_interval.rel_value / M_PI) * atan (matching_bits - current_size_estimate)); } @@ -406,12 +406,12 @@ get_delay_randomization (uint32_t matching_bits) if (matching_bits == 0) return GNUNET_TIME_UNIT_ZERO; - ret.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - (uint32_t) (get_matching_bits_delay - (matching_bits - - 1) / - (double) (hop_count_max - + 1))); + ret.rel_value = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + (uint32_t) (get_matching_bits_delay + (matching_bits - + 1) / (double) (hop_count_max + + 1))); return ret; #else return GNUNET_TIME_UNIT_ZERO; @@ -432,8 +432,8 @@ get_matching_bits (struct GNUNET_TIME_Absolute timestamp, { GNUNET_HashCode timestamp_hash; - GNUNET_CRYPTO_hash (×tamp.abs_value, - sizeof (timestamp.abs_value), ×tamp_hash); + GNUNET_CRYPTO_hash (×tamp.abs_value, sizeof (timestamp.abs_value), + ×tamp_hash); return GNUNET_CRYPTO_hash_matching_bits (×tamp_hash, &id->hashPubKey); } @@ -498,8 +498,8 @@ get_transmit_delay (int round_offset) * @param cls the 'struct NSEPeerEntry' * @param tc scheduler context */ -static void -transmit_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void transmit_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -545,17 +545,15 @@ transmit_ready (void *cls, size_t size, void *buf) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "In round %llu, sending to `%s' estimate with %u bits\n", (unsigned long long) - GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx]. - timestamp).abs_value, - GNUNET_i2s (&peer_entry->id), + GNUNET_TIME_absolute_ntoh (size_estimate_messages[idx].timestamp). + abs_value, GNUNET_i2s (&peer_entry->id), (unsigned int) ntohl (size_estimate_messages[idx].matching_bits)); #endif if (ntohl (size_estimate_messages[idx].hop_count) == 0) GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); - GNUNET_STATISTICS_update (stats, - "# flood messages transmitted", 1, GNUNET_NO); - memcpy (buf, - &size_estimate_messages[idx], + GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, + GNUNET_NO); + memcpy (buf, &size_estimate_messages[idx], sizeof (struct GNUNET_NSE_FloodMessage)); GNUNET_STATISTICS_update (stats, "# flood messages sent", 1, GNUNET_NO); return sizeof (struct GNUNET_NSE_FloodMessage); @@ -575,15 +573,13 @@ transmit_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (NULL == peer_entry->th); - peer_entry->th - = GNUNET_CORE_notify_transmit_ready (coreAPI, - GNUNET_NO, - NSE_PRIORITY, - GNUNET_TIME_UNIT_FOREVER_REL, - &peer_entry->id, - sizeof (struct - GNUNET_NSE_FloodMessage), - &transmit_ready, peer_entry); + peer_entry->th = + GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO, NSE_PRIORITY, + GNUNET_TIME_UNIT_FOREVER_REL, + &peer_entry->id, + sizeof (struct + GNUNET_NSE_FloodMessage), + &transmit_ready, peer_entry); } @@ -622,10 +618,10 @@ setup_flood_message (unsigned int slot, struct GNUNET_TIME_Absolute ts) fm->header.type = htons (GNUNET_MESSAGE_TYPE_NSE_P2P_FLOOD); fm->hop_count = htonl (0); fm->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_NSE_SEND); - fm->purpose.size = htonl (sizeof (struct GNUNET_NSE_FloodMessage) - - sizeof (struct GNUNET_MessageHeader) - - sizeof (uint32_t) - - sizeof (struct GNUNET_CRYPTO_RsaSignature)); + fm->purpose.size = + htonl (sizeof (struct GNUNET_NSE_FloodMessage) - + sizeof (struct GNUNET_MessageHeader) - sizeof (uint32_t) - + sizeof (struct GNUNET_CRYPTO_RsaSignature)); fm->matching_bits = htonl (matching_bits); fm->timestamp = GNUNET_TIME_absolute_hton (ts); fm->pkey = my_public_key; @@ -684,13 +680,13 @@ update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (0 != offset.rel_value) { /* somehow run early, delay more */ - flood_task - = GNUNET_SCHEDULER_add_delayed (offset, &update_flood_message, NULL); + flood_task = + GNUNET_SCHEDULER_add_delayed (offset, &update_flood_message, NULL); return; } current_timestamp = next_timestamp; - next_timestamp = GNUNET_TIME_absolute_add (current_timestamp, - gnunet_nse_interval); + next_timestamp = + GNUNET_TIME_absolute_add (current_timestamp, gnunet_nse_interval); estimate_index = (estimate_index + 1) % HISTORY_SIZE; if (estimate_count < HISTORY_SIZE) estimate_count++; @@ -699,16 +695,16 @@ update_flood_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { /* we received a message for this round way early, use it! */ size_estimate_messages[estimate_index] = next_message; - size_estimate_messages[estimate_index].hop_count - = htonl (1 + ntohl (next_message.hop_count)); + size_estimate_messages[estimate_index].hop_count = + htonl (1 + ntohl (next_message.hop_count)); } else setup_flood_message (estimate_index, current_timestamp); next_message.matching_bits = htonl (0); /* reset for 'next' round */ hop_count_max = 0; for (i = 0; i < HISTORY_SIZE; i++) - hop_count_max = GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), - hop_count_max); + hop_count_max = + GNUNET_MAX (ntohl (size_estimate_messages[i].hop_count), hop_count_max); GNUNET_CONTAINER_multihashmap_iterate (peers, &schedule_current_round, NULL); flood_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining @@ -753,8 +749,8 @@ check_proof_of_work (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pkey, GNUNET_HashCode result; memcpy (buf, &val, sizeof (val)); - memcpy (&buf[sizeof (val)], - pkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); + memcpy (&buf[sizeof (val)], pkey, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); return (count_leading_zeroes (&result) >= nse_work_required) ? GNUNET_YES : GNUNET_NO; @@ -773,9 +769,7 @@ write_proof () GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) return; if (sizeof (my_proof) != - GNUNET_DISK_fn_write (proof, - &my_proof, - sizeof (my_proof), + GNUNET_DISK_fn_write (proof, &my_proof, sizeof (my_proof), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", proof); @@ -801,8 +795,7 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) unsigned int i; proof_task = GNUNET_SCHEDULER_NO_TASK; - memcpy (&buf[sizeof (uint64_t)], - &my_public_key, + memcpy (&buf[sizeof (uint64_t)], &my_public_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); i = 0; counter = my_proof; @@ -814,8 +807,7 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { my_proof = counter; #if DEBUG_NSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Proof of work found: %llu!\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Proof of work found: %llu!\n", (unsigned long long) GNUNET_ntohll (counter)); #endif for (i = 0; i < HISTORY_SIZE; i++) @@ -835,8 +827,7 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (my_proof / (100 * ROUND_SIZE) < counter / (100 * ROUND_SIZE)) { #if DEBUG_NSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Testing proofs currently at %llu\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing proofs currently at %llu\n", (unsigned long long) counter); #endif /* remember progress every 100 rounds */ @@ -847,8 +838,8 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { my_proof = counter; } - proof_task = GNUNET_SCHEDULER_add_delayed (proof_find_delay, - &find_proof, NULL); + proof_task = + GNUNET_SCHEDULER_add_delayed (proof_find_delay, &find_proof, NULL); } @@ -869,10 +860,9 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) check_proof_of_work (&incoming_flood->pkey, incoming_flood->proof_of_work)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Proof of work invalid: %llu!\n"), - (unsigned long long) - GNUNET_ntohll (incoming_flood->proof_of_work)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Proof of work invalid: %llu!\n"), + (unsigned long long) GNUNET_ntohll (incoming_flood-> + proof_of_work)); GNUNET_break_op (0); return GNUNET_NO; } @@ -923,9 +913,8 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; } delay = get_transmit_delay (0); - peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (delay, - &transmit_task, - peer_entry); + peer_entry->transmit_task = + GNUNET_SCHEDULER_add_delayed (delay, &transmit_task, peer_entry); return GNUNET_OK; } @@ -940,8 +929,7 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) * */ static int -handle_p2p_size_estimate (void *cls, - const struct GNUNET_PeerIdentity *peer, +handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -971,9 +959,9 @@ handle_p2p_size_estimate (void *cls, GNUNET_snprintf (pred, sizeof (pred), "%s", GNUNET_i2s (peer)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Flood at %llu from `%s' via `%s' at `%s' with bits %u\n", - (unsigned long long) - GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp).abs_value, - origin, pred, GNUNET_i2s (&my_identity), + (unsigned long long) GNUNET_TIME_absolute_ntoh (incoming_flood-> + timestamp). + abs_value, origin, pred, GNUNET_i2s (&my_identity), (unsigned int) matching_bits); } #endif @@ -1015,8 +1003,8 @@ handle_p2p_size_estimate (void *cls, if (0 == (memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))) { /* send to self, update our own estimate IF this also comes from us! */ - if (0 == memcmp (&incoming_flood->pkey, - &my_public_key, sizeof (my_public_key))) + if (0 == + memcmp (&incoming_flood->pkey, &my_public_key, sizeof (my_public_key))) update_network_size_estimate (); return GNUNET_OK; } @@ -1057,8 +1045,8 @@ handle_p2p_size_estimate (void *cls, { if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); - peer_entry->transmit_task = GNUNET_SCHEDULER_add_now (&transmit_task, - peer_entry); + peer_entry->transmit_task = + GNUNET_SCHEDULER_add_now (&transmit_task, peer_entry); } /* Not closer than our most recent message, no need to do work here */ GNUNET_STATISTICS_update (stats, @@ -1081,8 +1069,8 @@ handle_p2p_size_estimate (void *cls, update_network_size_estimate (); /* flood to rest */ - GNUNET_CONTAINER_multihashmap_iterate (peers, - &update_flood_times, peer_entry); + GNUNET_CONTAINER_multihashmap_iterate (peers, &update_flood_times, + peer_entry); return GNUNET_OK; } @@ -1102,14 +1090,12 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, struct NSEPeerEntry *peer_entry; #if DEBUG_NSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%s' connected to us\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected to us\n", + GNUNET_i2s (peer)); #endif peer_entry = GNUNET_malloc (sizeof (struct NSEPeerEntry)); peer_entry->id = *peer; - GNUNET_CONTAINER_multihashmap_put (peers, - &peer->hashPubKey, - peer_entry, + GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, peer_entry, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); peer_entry->transmit_task = GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task, @@ -1129,8 +1115,8 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) struct NSEPeerEntry *pos; #if DEBUG_NSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%s' disconnected from us\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected from us\n", + GNUNET_i2s (peer)); #endif pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); if (NULL == pos) @@ -1139,8 +1125,8 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) return; } GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (peers, - &peer->hashPubKey, pos)); + GNUNET_CONTAINER_multihashmap_remove (peers, &peer->hashPubKey, + pos)); if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (pos->transmit_task); if (pos->th != NULL) @@ -1251,8 +1237,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, } estimate_index = HISTORY_SIZE - 1; estimate_count = 2; - flood_task - = + flood_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (next_timestamp), &update_flood_message, NULL); @@ -1286,16 +1271,13 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, cfg = c; if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "NSE", "INTERVAL", + GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "INTERVAL", &gnunet_nse_interval)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "NSE", "WORKDELAY", + GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "WORKDELAY", &proof_find_delay)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - "NSE", "WORKBITS", + GNUNET_CONFIGURATION_get_value_number (cfg, "NSE", "WORKBITS", &nse_work_required))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1314,8 +1296,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "GNUNETD", "HOSTKEY", &keyfile)) + GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", + &keyfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -1374,8 +1356,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, NULL, /* Don't want notified about all outbound messages */ GNUNET_NO, /* For header only outbound notification */ core_handlers); /* Register these handlers */ - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); #if ENABLE_HISTOGRAM if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "HISTOGRAM", &proof)) @@ -1403,10 +1385,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, int main (int argc, char *const *argv) { - return (GNUNET_OK == GNUNET_SERVICE_run (argc, argv, - "nse", - GNUNET_SERVICE_OPTION_NONE, &run, - NULL)) ? 0 : 1; + return (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "nse", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } /* end of gnunet-service-nse.c */ diff --git a/src/nse/nse_api.c b/src/nse/nse_api.c index 62c58ca77..8ff0256b9 100644 --- a/src/nse/nse_api.c +++ b/src/nse/nse_api.c @@ -85,8 +85,8 @@ struct GNUNET_NSE_Handle * @param cls the handle to the transport service * @param tc scheduler context */ -static void -reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void reconnect (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -107,8 +107,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) /* Error, timeout, death */ GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); h->client = NULL; - h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, - &reconnect, h); + h->reconnect_task = + GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); return; } if ((ntohs (msg->size) != sizeof (struct GNUNET_NSE_ClientMessage)) || @@ -118,11 +118,10 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) return; } client_msg = (const struct GNUNET_NSE_ClientMessage *) msg; - h->recv_cb (h->recv_cb_cls, - GNUNET_TIME_absolute_ntoh (client_msg->timestamp), + h->recv_cb (h->recv_cb_cls, GNUNET_TIME_absolute_ntoh (client_msg->timestamp), client_msg->size_estimate, client_msg->std_deviation); - GNUNET_CLIENT_receive (h->client, - &message_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &message_handler, h, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -153,8 +152,8 @@ reschedule_connect (struct GNUNET_NSE_Handle *h) "Scheduling task to reconnect to nse service in %llu ms.\n", h->reconnect_delay.rel_value); #endif - h->reconnect_task - = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); + h->reconnect_task = + GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); if (h->reconnect_delay.rel_value == 0) { h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; @@ -162,8 +161,8 @@ reschedule_connect (struct GNUNET_NSE_Handle *h) else { h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); - h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, - h->reconnect_delay); + h->reconnect_delay = + GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->reconnect_delay); } } @@ -201,8 +200,8 @@ send_start (void *cls, size_t size, void *buf) msg = (struct GNUNET_MessageHeader *) buf; msg->size = htons (sizeof (struct GNUNET_MessageHeader)); msg->type = htons (GNUNET_MESSAGE_TYPE_NSE_START); - GNUNET_CLIENT_receive (h->client, - &message_handler, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &message_handler, h, + GNUNET_TIME_UNIT_FOREVER_REL); return sizeof (struct GNUNET_MessageHeader); } diff --git a/src/nse/test_nse_api.c b/src/nse/test_nse_api.c index c06b2be8b..e4d2ba409 100644 --- a/src/nse/test_nse_api.c +++ b/src/nse/test_nse_api.c @@ -88,8 +88,7 @@ end_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * */ static void -check_nse_message (void *cls, - struct GNUNET_TIME_Absolute timestamp, +check_nse_message (void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev) { int *ok = cls; @@ -110,13 +109,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) { p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, - "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); @@ -125,13 +124,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 1), - &end_test, NULL); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 1), &end_test, + NULL); setup_peer (&p1, cfgfile); h = GNUNET_NSE_connect (cfg, &check_nse_message, cls); diff --git a/src/nse/test_nse_multipeer.c b/src/nse/test_nse_multipeer.c index 29e5cd6cc..1db00415f 100644 --- a/src/nse/test_nse_multipeer.c +++ b/src/nse/test_nse_multipeer.c @@ -72,8 +72,8 @@ shutdown_callback (void *cls, const char *emsg) if (emsg != NULL) { #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Shutdown of peers failed: %s!\n", emsg); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed: %s!\n", + emsg); #endif if (ok == 0) ok = 666; @@ -117,17 +117,15 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * */ static void -handle_estimate (void *cls, - struct GNUNET_TIME_Absolute timestamp, +handle_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, double estimate, double std_dev) { struct NSEPeer *peer = cls; fprintf (stderr, "Received network size estimate from peer %s. logSize: %f std.dev. %f (%f/%u)\n", - GNUNET_i2s (&peer->daemon->id), - estimate, - std_dev, GNUNET_NSE_log_estimate_to_n (estimate), num_peers); + GNUNET_i2s (&peer->daemon->id), estimate, std_dev, + GNUNET_NSE_log_estimate_to_n (estimate), num_peers); } @@ -144,9 +142,9 @@ connect_nse_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { current_peer = GNUNET_malloc (sizeof (struct NSEPeer)); current_peer->daemon = GNUNET_TESTING_daemon_get (pg, i); - current_peer->nse_handle = GNUNET_NSE_connect (current_peer->daemon->cfg, - &handle_estimate, - current_peer); + current_peer->nse_handle = + GNUNET_NSE_connect (current_peer->daemon->cfg, &handle_estimate, + current_peer); GNUNET_assert (current_peer->nse_handle != NULL); GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, current_peer); } @@ -169,8 +167,8 @@ my_cb (void *cls, const char *emsg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully, connecting to NSE service for each peer!\n"); #endif - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Have %u connections\n", total_connections); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", + total_connections); GNUNET_SCHEDULER_add_now (&connect_nse_service, NULL); } @@ -191,10 +189,8 @@ my_cb (void *cls, const char *emsg) * @param emsg error message (NULL on success) */ static void -connect_cb (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -210,9 +206,8 @@ connect_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CONFIGURATION_Handle *testing_cfg; unsigned long long total_peers; @@ -223,20 +218,17 @@ run (void *cls, #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); - GNUNET_CONFIGURATION_set_value_string (testing_cfg, - "testing", "use_progressbars", "YES"); + GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", + "use_progressbars", "YES"); #endif - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, - "testing", - "num_peers", - &total_peers)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", + "num_peers", &total_peers)) total_peers = NUM_PEERS; peers_left = total_peers; num_peers = peers_left; - pg = GNUNET_TESTING_peergroup_start (testing_cfg, - peers_left, - TIMEOUT, + pg = GNUNET_TESTING_peergroup_start (testing_cfg, peers_left, TIMEOUT, &connect_cb, &my_cb, NULL, NULL); GNUNET_assert (pg != NULL); GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); @@ -257,8 +249,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-nse-multipeer", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-nse-multipeer", "nohelp", options, &run, &ok); return ok; } diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 951eecce8..c61b6abbf 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c @@ -87,8 +87,8 @@ process_resolved_address (void *cls, const char *address) dump_pc (pc); return; } - GNUNET_array_append (pc->address_list, - pc->num_addresses, GNUNET_strdup (address)); + GNUNET_array_append (pc->address_list, pc->num_addresses, + GNUNET_strdup (address)); } @@ -103,10 +103,9 @@ process_resolved_address (void *cls, const char *address) * @return GNUNET_OK to keep the address and continue */ static int -count_address (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +count_address (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct PrintContext *pc = cls; @@ -126,18 +125,13 @@ count_address (void *cls, * @return GNUNET_OK to keep the address and continue */ static int -print_address (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +print_address (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct PrintContext *pc = cls; - GNUNET_TRANSPORT_address_lookup (cfg, - addr, - addrlen, - no_resolve, - tname, + GNUNET_TRANSPORT_address_lookup (cfg, addr, addrlen, no_resolve, tname, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), &process_resolved_address, pc); @@ -151,8 +145,7 @@ print_address (void *cls, * Could of course do more (e.g. resolve via DNS). */ static void -print_peer_info (void *cls, - const struct GNUNET_PeerIdentity *peer, +print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { struct GNUNET_CRYPTO_HashAsciiEncoded enc; @@ -192,9 +185,8 @@ print_peer_info (void *cls, * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { struct GNUNET_CRYPTO_RsaPrivateKey *priv; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; @@ -216,20 +208,18 @@ run (void *cls, fprintf (stderr, _("Could not access PEERINFO service. Exiting.\n")); return; } - GNUNET_PEERINFO_iterate (peerinfo, - NULL, + GNUNET_PEERINFO_iterate (peerinfo, NULL, GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 5), - &print_peer_info, NULL); + (GNUNET_TIME_UNIT_SECONDS, 5), &print_peer_info, + NULL); } else { if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "GNUNETD", "HOSTKEY", &fn)) + GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", + &fn)) { - fprintf (stderr, - _("Could not find option `%s:%s' in configuration.\n"), + fprintf (stderr, _("Could not find option `%s:%s' in configuration.\n"), "GNUNETD", "HOSTKEYFILE"); return; } @@ -276,9 +266,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-peerinfo", + GNUNET_PROGRAM_run (argc, argv, "gnunet-peerinfo", gettext_noop ("Print information about peers."), options, &run, NULL)) ? 0 : 1; } diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 160993649..26fec5289 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -124,10 +124,9 @@ make_info_message (const struct HostEntry *he) * @return GNUNET_NO if expiration smaller than the current time */ static int -discard_expired (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +discard_expired (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { const struct GNUNET_TIME_Absolute *now = cls; @@ -170,8 +169,8 @@ notify_all (struct HostEntry *entry) struct InfoMessage *msg; msg = make_info_message (entry); - GNUNET_SERVER_notification_context_broadcast (notify_list, - &msg->header, GNUNET_NO); + GNUNET_SERVER_notification_context_broadcast (notify_list, &msg->header, + GNUNET_NO); GNUNET_free (msg); } @@ -195,8 +194,8 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) entry = GNUNET_CONTAINER_multihashmap_get (hostmap, &identity->hashPubKey); if (entry != NULL) return; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# peers known"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1, + GNUNET_NO); entry = GNUNET_malloc (sizeof (struct HostEntry)); entry->identity = *identity; @@ -216,16 +215,14 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) else { now = GNUNET_TIME_absolute_get (); - hello_clean = GNUNET_HELLO_iterate_addresses (hello, - GNUNET_YES, - &discard_expired, &now); + hello_clean = + GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired, + &now); entry->hello = hello_clean; } } GNUNET_free (fn); - GNUNET_CONTAINER_multihashmap_put (hostmap, - &identity->hashPubKey, - entry, + GNUNET_CONTAINER_multihashmap_put (hostmap, &identity->hashPubKey, entry, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); notify_all (entry); } @@ -244,8 +241,8 @@ remove_garbage (const char *fullname) ("File `%s' in directory `%s' does not match naming convention. " "Removed.\n"), fullname, networkIdDirectory); else - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "unlink", fullname); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "unlink", fullname); } @@ -271,8 +268,8 @@ hosts_directory_scan_callback (void *cls, const char *fullname) remove_garbage (fullname); return GNUNET_OK; } - if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (filename, - &identity.hashPubKey)) + if (GNUNET_OK != + GNUNET_CRYPTO_hash_from_string (filename, &identity.hashPubKey)) { remove_garbage (fullname); return GNUNET_OK; @@ -305,11 +302,10 @@ cron_scan_directory_data_hosts (void *cls, GNUNET_DISK_directory_scan (networkIdDirectory, &hosts_directory_scan_callback, &count); if ((0 == count) && (0 == (++retries & 31))) - GNUNET_log (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("Still no peers found in `%s'!\n"), networkIdDirectory); - GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, - &cron_scan_directory_data_hosts, NULL); + GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, &cron_scan_directory_data_hosts, + NULL); } @@ -352,9 +348,7 @@ bind_address (const struct GNUNET_PeerIdentity *peer, if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) { if (GNUNET_SYSERR == - GNUNET_DISK_fn_write (fn, - host->hello, - GNUNET_HELLO_size (host->hello), + GNUNET_DISK_fn_write (fn, host->hello, GNUNET_HELLO_size (host->hello), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_GROUP_READ | @@ -425,14 +419,11 @@ discard_hosts_helper (void *cls, const char *fn) return GNUNET_OK; } hello = (const struct GNUNET_HELLO_Message *) buffer; - new_hello = GNUNET_HELLO_iterate_addresses (hello, - GNUNET_YES, - &discard_expired, now); + new_hello = + GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired, now); if (new_hello != NULL) { - GNUNET_DISK_fn_write (fn, - new_hello, - GNUNET_HELLO_size (new_hello), + GNUNET_DISK_fn_write (fn, new_hello, GNUNET_HELLO_size (new_hello), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_GROUP_READ | @@ -461,8 +452,8 @@ cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; now = GNUNET_TIME_absolute_get (); GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now); - GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, - &cron_clean_data_hosts, NULL); + GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts, + NULL); } @@ -474,8 +465,7 @@ cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param message the actual message */ static void -handle_hello (void *cls, - struct GNUNET_SERVER_Client *client, +handle_hello (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct GNUNET_HELLO_Message *hello; @@ -489,8 +479,7 @@ handle_hello (void *cls, return; } #if DEBUG_PEERINFO - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s' message received for peer `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n", "HELLO", GNUNET_i2s (&pid)); #endif bind_address (&pid, hello); @@ -506,8 +495,7 @@ handle_hello (void *cls, * @param message the actual message */ static void -handle_get (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct ListPeerMessage *lpm; @@ -516,13 +504,11 @@ handle_get (void *cls, lpm = (const struct ListPeerMessage *) message; GNUNET_break (0 == ntohl (lpm->reserved)); #if DEBUG_PEERINFO - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s' message received for peer `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n", "GET", GNUNET_i2s (&lpm->peer)); #endif tc = GNUNET_SERVER_transmit_context_create (client); - GNUNET_CONTAINER_multihashmap_get_multiple (hostmap, - &lpm->peer.hashPubKey, + GNUNET_CONTAINER_multihashmap_get_multiple (hostmap, &lpm->peer.hashPubKey, &add_to_tc, tc); GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); @@ -538,8 +524,7 @@ handle_get (void *cls, * @param message the actual message */ static void -handle_get_all (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get_all (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_SERVER_TransmitContext *tc; @@ -563,8 +548,8 @@ do_notify_entry (void *cls, const GNUNET_HashCode * key, void *value) struct InfoMessage *msg; msg = make_info_message (he); - GNUNET_SERVER_notification_context_unicast (notify_list, - client, &msg->header, GNUNET_NO); + GNUNET_SERVER_notification_context_unicast (notify_list, client, &msg->header, + GNUNET_NO); GNUNET_free (msg); return GNUNET_YES; } @@ -578,8 +563,7 @@ do_notify_entry (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ static void -handle_notify (void *cls, - struct GNUNET_SERVER_Client *client, +handle_notify (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { #if DEBUG_PEERINFO @@ -630,8 +614,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param cfg configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -649,8 +632,7 @@ run (void *cls, stats = GNUNET_STATISTICS_create ("peerinfo", cfg); notify_list = GNUNET_SERVER_notification_context_create (server, 0); GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_filename (cfg, - "peerinfo", + GNUNET_CONFIGURATION_get_value_filename (cfg, "peerinfo", "HOSTS", &networkIdDirectory)); GNUNET_DISK_directory_create (networkIdDirectory); @@ -658,8 +640,8 @@ run (void *cls, &cron_scan_directory_data_hosts, NULL); GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &cron_clean_data_hosts, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); GNUNET_SERVER_add_handlers (server, handlers); } @@ -676,11 +658,10 @@ main (int argc, char *const *argv) { int ret; - ret = (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "peerinfo", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "peerinfo", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; GNUNET_free_non_null (networkIdDirectory); return ret; } diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 444ae98e2..4febf2eeb 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -240,8 +240,9 @@ reconnect (struct GNUNET_PEERINFO_Handle *h) h->client = GNUNET_CLIENT_connect ("peerinfo", h->cfg); if (NULL == h->client) { - h->r_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &reconnect_task, h); + h->r_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task, + h); return; } trigger_transmit (h); @@ -283,8 +284,8 @@ do_transmit (void *cls, size_t size, void *buf) memcpy (buf, &tqe[1], ret); #if DEBUG_PEERINFO GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting request of size %u to `%s' service.\n", - ret, "PEERINFO"); + "Transmitting request of size %u to `%s' service.\n", ret, + "PEERINFO"); #endif GNUNET_CONTAINER_DLL_remove (h->tq_head, h->tq_tail, tqe); if (tqe->cont != NULL) @@ -318,11 +319,11 @@ trigger_transmit (struct GNUNET_PEERINFO_Handle *h) reconnect (h); return; } - h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, - tqe->size, - GNUNET_TIME_absolute_get_remaining - (tqe->timeout), GNUNET_YES, - &do_transmit, h); + h->th = + GNUNET_CLIENT_notify_transmit_ready (h->client, tqe->size, + GNUNET_TIME_absolute_get_remaining + (tqe->timeout), GNUNET_YES, + &do_transmit, h); } @@ -487,9 +488,8 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) ic->h->in_receive = GNUNET_YES; if (ic->callback != NULL) ic->callback (ic->callback_cls, &im->peer, hello, NULL); - GNUNET_CLIENT_receive (ic->h->client, - &peerinfo_handler, - ic, GNUNET_TIME_absolute_get_remaining (ic->timeout)); + GNUNET_CLIENT_receive (ic->h->client, &peerinfo_handler, ic, + GNUNET_TIME_absolute_get_remaining (ic->timeout)); } @@ -527,9 +527,8 @@ iterator_start_receive (void *cls, int transmit_success) ic->h->in_receive = GNUNET_YES; ic->in_receive = GNUNET_YES; ic->tqe = NULL; - GNUNET_CLIENT_receive (ic->h->client, - &peerinfo_handler, - ic, GNUNET_TIME_absolute_get_remaining (ic->timeout)); + GNUNET_CLIENT_receive (ic->h->client, &peerinfo_handler, ic, + GNUNET_TIME_absolute_get_remaining (ic->timeout)); } @@ -549,8 +548,7 @@ signal_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CONTAINER_DLL_remove (ic->h->tq_head, ic->h->tq_tail, ic->tqe); else reconnect (ic->h); - ic->callback (ic->callback_cls, - NULL, NULL, + ic->callback (ic->callback_cls, NULL, NULL, _ ("Timeout transmitting iteration request to `PEERINFO' service.\n")); ic->callback = NULL; @@ -592,8 +590,9 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting list of peers from PEERINFO service\n"); #endif - tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + - sizeof (struct GNUNET_MessageHeader)); + tqe = + GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + + sizeof (struct GNUNET_MessageHeader)); tqe->size = sizeof (struct GNUNET_MessageHeader); lapm = (struct GNUNET_MessageHeader *) &tqe[1]; lapm->size = htons (sizeof (struct GNUNET_MessageHeader)); @@ -606,8 +605,9 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, "Requesting information on peer `%4s' from PEERINFO service\n", GNUNET_i2s (peer)); #endif - tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + - sizeof (struct ListPeerMessage)); + tqe = + GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + + sizeof (struct ListPeerMessage)); tqe->size = sizeof (struct ListPeerMessage); lpm = (struct ListPeerMessage *) &tqe[1]; lpm->header.size = htons (sizeof (struct ListPeerMessage)); @@ -620,8 +620,8 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, ic->callback = callback; ic->callback_cls = callback_cls; ic->timeout = GNUNET_TIME_relative_to_absolute (timeout); - ic->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &signal_timeout, ic); + ic->timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &signal_timeout, ic); tqe->timeout = ic->timeout; tqe->cont = &iterator_start_receive; tqe->cont_cls = ic; diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c index 0c7474f4a..4ec7b2192 100644 --- a/src/peerinfo/peerinfo_api_notify.c +++ b/src/peerinfo/peerinfo_api_notify.c @@ -104,8 +104,8 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (NULL == nc->client) { /* ugh */ - nc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &reconnect, nc); + nc->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, nc); return; } request_notifications (nc); @@ -176,9 +176,8 @@ process_notification (void *cls, const struct GNUNET_MessageHeader *msg) static void receive_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) { - GNUNET_CLIENT_receive (nc->client, - &process_notification, - nc, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (nc->client, &process_notification, nc, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -223,12 +222,12 @@ static void request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) { GNUNET_assert (NULL == nc->init); - nc->init = GNUNET_CLIENT_notify_transmit_ready (nc->client, - sizeof (struct - GNUNET_MessageHeader), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, - &transmit_notify_request, nc); + nc->init = + GNUNET_CLIENT_notify_transmit_ready (nc->client, + sizeof (struct GNUNET_MessageHeader), + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_YES, &transmit_notify_request, + nc); } diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index d0eadaf94..d9107c8fe 100755 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c @@ -47,9 +47,7 @@ static struct GNUNET_PEERINFO_Handle *h; static unsigned int numpeers; static int -check_it (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, +check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, const void *addr, uint16_t addrlen) { #if DEBUG @@ -74,10 +72,11 @@ address_generator (void *cls, size_t max, void *buf) GNUNET_asprintf (&address, "Address%d", *agc); - ret = GNUNET_HELLO_add_address ("peerinfotest", - GNUNET_TIME_relative_to_absolute - (GNUNET_TIME_UNIT_HOURS), - address, strlen (address) + 1, buf, max); + ret = + GNUNET_HELLO_add_address ("peerinfotest", + GNUNET_TIME_relative_to_absolute + (GNUNET_TIME_UNIT_HOURS), address, + strlen (address) + 1, buf, max); GNUNET_free (address); *agc = 0; return ret; @@ -100,8 +99,7 @@ add_peer (size_t i) static void -process (void *cls, - const struct GNUNET_PeerIdentity *peer, +process (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { if (peer == NULL) @@ -124,9 +122,8 @@ process (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { size_t i; @@ -136,11 +133,10 @@ run (void *cls, for (i = 0; i < NUM_REQUESTS; i++) { add_peer (i); - ic[i] = GNUNET_PEERINFO_iterate (h, - NULL, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 30), - &process, cls); + ic[i] = + GNUNET_PEERINFO_iterate (h, NULL, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, 30), &process, cls); } } @@ -165,21 +161,21 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", - "gnunet-service-peerinfo", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", + "gnunet-service-peerinfo", #if DEBUG_PEERINFO - "-L", "DEBUG", + "-L", "DEBUG", #else - "-L", "ERROR", + "-L", "ERROR", #endif - "-c", "test_peerinfo_api_data.conf", NULL); + "-c", "test_peerinfo_api_data.conf", NULL); #endif GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "perf-peerinfo-api", "nohelp", options, &run, &ok); - fprintf (stderr, - "Received %u/%u calls before timeout\n", - numpeers, NUM_REQUESTS * NUM_REQUESTS / 2); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "perf-peerinfo-api", "nohelp", options, &run, &ok); + fprintf (stderr, "Received %u/%u calls before timeout\n", numpeers, + NUM_REQUESTS * NUM_REQUESTS / 2); GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); #if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index e740f1fc9..bbdc591f4 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c @@ -45,9 +45,7 @@ static struct GNUNET_PEERINFO_Handle *h; static unsigned int retries; static int -check_it (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, +check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, const void *addr, uint16_t addrlen) { unsigned int *agc = cls; @@ -70,10 +68,11 @@ address_generator (void *cls, size_t max, void *buf) if (0 == *agc) return 0; - ret = GNUNET_HELLO_add_address ("peerinfotest", - GNUNET_TIME_relative_to_absolute - (GNUNET_TIME_UNIT_HOURS), "Address", *agc, - buf, max); + ret = + GNUNET_HELLO_add_address ("peerinfotest", + GNUNET_TIME_relative_to_absolute + (GNUNET_TIME_UNIT_HOURS), "Address", *agc, buf, + max); (*agc)--; return ret; } @@ -98,8 +97,7 @@ add_peer () static void -process (void *cls, - const struct GNUNET_PeerIdentity *peer, +process (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { int *ok = cls; @@ -119,11 +117,10 @@ process (void *cls, /* try again */ retries++; add_peer (); - ic = GNUNET_PEERINFO_iterate (h, - NULL, + ic = GNUNET_PEERINFO_iterate (h, NULL, GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 15), - &process, cls); + (GNUNET_TIME_UNIT_SECONDS, 15), &process, + cls); return; } GNUNET_assert (peer == NULL); @@ -145,16 +142,14 @@ process (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; h = GNUNET_PEERINFO_connect (cfg); GNUNET_assert (h != NULL); add_peer (); - ic = GNUNET_PEERINFO_iterate (h, - NULL, + ic = GNUNET_PEERINFO_iterate (h, NULL, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); } @@ -177,15 +172,16 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", - "gnunet-service-peerinfo", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", + "gnunet-service-peerinfo", #if DEBUG_PEERINFO - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_peerinfo_api_data.conf", NULL); + "-c", "test_peerinfo_api_data.conf", NULL); GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-peerinfo-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-peerinfo-api", "nohelp", options, &run, &ok); if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 5e0be1183..3305dc6f4 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -181,8 +181,8 @@ load (struct GNUNET_SERVER_Handle *server) char *buf; struct GNUNET_SERVER_MessageStreamTokenizer *mst; - fn = GNUNET_DISK_get_home_filename (cfg, - "statistics", "statistics.data", NULL); + fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", + NULL); if (fn == NULL) return; if ((0 != stat (fn, &sb)) || (sb.st_size == 0)) @@ -209,10 +209,8 @@ load (struct GNUNET_SERVER_Handle *server) (unsigned long long) sb.st_size, fn); mst = GNUNET_SERVER_mst_create (&inject_message, server); GNUNET_break (GNUNET_OK == - GNUNET_SERVER_mst_receive (mst, - NULL, - buf, - sb.st_size, GNUNET_YES, GNUNET_NO)); + GNUNET_SERVER_mst_receive (mst, NULL, buf, sb.st_size, + GNUNET_YES, GNUNET_NO)); GNUNET_SERVER_mst_destroy (mst); GNUNET_break (GNUNET_OK == GNUNET_DISK_file_unmap (mh)); GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); @@ -232,12 +230,12 @@ save () unsigned long long total; fh = NULL; - fn = GNUNET_DISK_get_home_filename (cfg, - "statistics", "statistics.data", NULL); + fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", + NULL); if (fn != NULL) - fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_WRITE - | GNUNET_DISK_OPEN_CREATE | - GNUNET_DISK_OPEN_TRUNCATE, + fh = GNUNET_DISK_file_open (fn, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE + | GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); total = 0; @@ -292,13 +290,13 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) m->uid |= htonl (GNUNET_STATISTICS_PERSIST_BIT); m->value = GNUNET_htonll (e->value); size -= sizeof (struct GNUNET_STATISTICS_ReplyMessage); - GNUNET_assert (size == GNUNET_STRINGS_buffer_fill ((char *) &m[1], - size, - 2, e->service, e->name)); + GNUNET_assert (size == + GNUNET_STRINGS_buffer_fill ((char *) &m[1], size, 2, + e->service, e->name)); #if DEBUG_STATISTICS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting value for `%s:%s' (%d): %llu\n", - e->service, e->name, e->persistent, e->value); + "Transmitting value for `%s:%s' (%d): %llu\n", e->service, + e->name, e->persistent, e->value); #endif GNUNET_SERVER_notification_context_unicast (nc, client, &m->header, GNUNET_NO); @@ -312,9 +310,8 @@ transmit (struct GNUNET_SERVER_Client *client, const struct StatsEntry *e) static int matches (const struct StatsEntry *e, const char *service, const char *name) { - return ((0 == strlen (service)) || - (0 == strcmp (service, e->service))) - && ((0 == strlen (name)) || (0 == strcmp (name, e->name))); + return ((0 == strlen (service)) || (0 == strcmp (service, e->service))) && + ((0 == strlen (name)) || (0 == strcmp (name, e->name))); } @@ -350,8 +347,7 @@ make_client_entry (struct GNUNET_SERVER_Client *client) * GNUNET_SYSERR to close it (signal serious error) */ static void -handle_get (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_MessageHeader end; @@ -363,8 +359,9 @@ handle_get (void *cls, if (client != NULL) make_client_entry (client); size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader); - if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], - size, 2, &service, &name)) + if (size != + GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], size, 2, + &service, &name)) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -407,9 +404,8 @@ notify_change (struct StatsEntry *se) wvm.wid = htonl (pos->wid); wvm.reserved = htonl (0); wvm.value = GNUNET_htonll (se->value); - GNUNET_SERVER_notification_context_unicast (nc, - pos->client, - &wvm.header, GNUNET_NO); + GNUNET_SERVER_notification_context_unicast (nc, pos->client, &wvm.header, + GNUNET_NO); pos->last_value = se->value; } pos = pos->next; @@ -424,8 +420,7 @@ notify_change (struct StatsEntry *se) * @param message the actual message */ static void -handle_set (void *cls, - struct GNUNET_SERVER_Client *client, +handle_set (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { char *service; @@ -452,8 +447,9 @@ handle_set (void *cls, size = msize - sizeof (struct GNUNET_STATISTICS_SetMessage); msg = (const struct GNUNET_STATISTICS_SetMessage *) message; - if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1], - size, 2, &service, &name)) + if (size != + GNUNET_STRINGS_buffer_tokenize ((const char *) &msg[1], size, 2, &service, + &name)) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -504,8 +500,8 @@ handle_set (void *cls, } #if DEBUG_STATISTICS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Statistic `%s:%s' updated to value %llu.\n", - service, name, pos->value); + "Statistic `%s:%s' updated to value %llu.\n", service, name, + pos->value); #endif if (changed) notify_change (pos); @@ -530,8 +526,8 @@ handle_set (void *cls, start = pos; #if DEBUG_STATISTICS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "New statistic on `%s:%s' with value %llu created.\n", - service, name, pos->value); + "New statistic on `%s:%s' with value %llu created.\n", service, + name, pos->value); #endif GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -545,8 +541,7 @@ handle_set (void *cls, * @param message the actual message */ static void -handle_watch (void *cls, - struct GNUNET_SERVER_Client *client, +handle_watch (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { char *service; @@ -567,8 +562,9 @@ handle_watch (void *cls, return; } size = msize - sizeof (struct GNUNET_MessageHeader); - if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], - size, 2, &service, &name)) + if (size != + GNUNET_STRINGS_buffer_tokenize ((const char *) &message[1], size, 2, + &service, &name)) { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -576,8 +572,8 @@ handle_watch (void *cls, } #if DEBUG_STATISTICS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received request to watch statistic on `%s:%s'\n", - service, name); + "Received request to watch statistic on `%s:%s'\n", service, + name); #endif pos = start; while (pos != NULL) @@ -588,8 +584,9 @@ handle_watch (void *cls, } if (pos == NULL) { - pos = GNUNET_malloc (sizeof (struct StatsEntry) + - sizeof (struct GNUNET_STATISTICS_SetMessage) + size); + pos = + GNUNET_malloc (sizeof (struct StatsEntry) + + sizeof (struct GNUNET_STATISTICS_SetMessage) + size); pos->next = start; pos->uid = uidgen++; pos->msg = (void *) &pos[1]; @@ -702,8 +699,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -717,8 +713,8 @@ run (void *cls, nc = GNUNET_SERVER_notification_context_create (server, 16); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); load (server); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); } @@ -733,9 +729,7 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "statistics", + GNUNET_SERVICE_run (argc, argv, "statistics", GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; } diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 5267e38cf..80488958f 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c @@ -63,14 +63,11 @@ static int persistent; * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -printer (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +printer (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { - FPRINTF (stdout, - "%s%-12s %-50s: %16llu\n", - is_persistent ? "!" : " ", subsystem, _(name), - (unsigned long long) value); + FPRINTF (stdout, "%s%-12s %-50s: %16llu\n", is_persistent ? "!" : " ", + subsystem, _(name), (unsigned long long) value); return GNUNET_OK; } @@ -106,17 +103,16 @@ cleanup (void *cls, int success) * @param cfg configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_STATISTICS_Handle *h; unsigned long long val; if (args[0] != NULL) { - if ((1 != SSCANF (args[0], "%llu", &val)) || - (subsystem == NULL) || (name == NULL)) + if ((1 != SSCANF (args[0], "%llu", &val)) || (subsystem == NULL) || + (name == NULL)) { FPRINTF (stderr, _("Invalid argument `%s'\n"), args[0]); ret = 1; @@ -138,9 +134,9 @@ run (void *cls, ret = 1; return; } - if (NULL == GNUNET_STATISTICS_get (h, - subsystem, name, GET_TIMEOUT, &cleanup, - &printer, h)) + if (NULL == + GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup, + &printer, h)) cleanup (h, GNUNET_SYSERR); } @@ -167,9 +163,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-statistics [options [value]]", + GNUNET_PROGRAM_run (argc, argv, "gnunet-statistics [options [value]]", gettext_noop ("Print statistics about GNUnet operations."), options, &run, NULL)) ? ret : 1; diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index a76f83db1..f4a71cc21 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -256,8 +256,8 @@ static void insert_ai (struct GNUNET_STATISTICS_Handle *h, struct GNUNET_STATISTICS_GetHandle *ai) { - GNUNET_CONTAINER_DLL_insert_after (h->action_head, - h->action_tail, h->action_tail, ai); + GNUNET_CONTAINER_DLL_insert_after (h->action_head, h->action_tail, + h->action_tail, ai); if (h->action_head == ai) schedule_action (h); } @@ -388,21 +388,20 @@ process_message (struct GNUNET_STATISTICS_Handle *h, } smsg = (const struct GNUNET_STATISTICS_ReplyMessage *) msg; size -= sizeof (struct GNUNET_STATISTICS_ReplyMessage); - if (size != GNUNET_STRINGS_buffer_tokenize ((const char *) &smsg[1], - size, 2, &service, &name)) + if (size != + GNUNET_STRINGS_buffer_tokenize ((const char *) &smsg[1], size, 2, + &service, &name)) { GNUNET_break (0); return GNUNET_SYSERR; } #if DEBUG_STATISTICS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received valid statistic on `%s:%s': %llu\n", - service, name, GNUNET_ntohll (smsg->value)); + "Received valid statistic on `%s:%s': %llu\n", service, name, + GNUNET_ntohll (smsg->value)); #endif if (GNUNET_OK != - h->current->proc (h->current->cls, - service, - name, + h->current->proc (h->current->cls, service, name, GNUNET_ntohll (smsg->value), 0 != (ntohl (smsg->uid) & GNUNET_STATISTICS_PERSIST_BIT))) @@ -442,9 +441,7 @@ process_watch_value (struct GNUNET_STATISTICS_Handle *h, return GNUNET_SYSERR; } w = h->watches[wid]; - (void) w->proc (w->proc_cls, - w->subsystem, - w->name, + (void) w->proc (w->proc_cls, w->subsystem, w->name, GNUNET_ntohll (wvm->value), 0 != (ntohl (wvm->flags) & GNUNET_STATISTICS_PERSIST_BIT)); return GNUNET_OK; @@ -485,8 +482,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) h->backoff = GNUNET_TIME_UNIT_MILLISECONDS; if (h->watches_size > 0) { - GNUNET_CLIENT_receive (h->client, - &receive_stats, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &receive_stats, h, + GNUNET_TIME_UNIT_FOREVER_REL); } else { @@ -502,11 +499,9 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing VALUE done, now reading more\n"); #endif - GNUNET_CLIENT_receive (h->client, - &receive_stats, - h, - GNUNET_TIME_absolute_get_remaining - (h->current->timeout)); + GNUNET_CLIENT_receive (h->client, &receive_stats, h, + GNUNET_TIME_absolute_get_remaining (h->current-> + timeout)); h->backoff = GNUNET_TIME_UNIT_MILLISECONDS; return; } @@ -517,8 +512,8 @@ receive_stats (void *cls, const struct GNUNET_MessageHeader *msg) { h->backoff = GNUNET_TIME_UNIT_MILLISECONDS; GNUNET_assert (h->watches_size > 0); - GNUNET_CLIENT_receive (h->client, - &receive_stats, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &receive_stats, h, + GNUNET_TIME_UNIT_FOREVER_REL); return; } GNUNET_break (0); @@ -566,9 +561,7 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) hdr->size = htons (msize); hdr->type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_GET); GNUNET_assert (slen1 + slen2 == - GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], - slen1 + slen2, - 2, + GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], slen1 + slen2, 2, handle->current->subsystem, handle->current->name)); if (!handle->receiving) @@ -578,11 +571,9 @@ transmit_get (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) "Transmission of GET done, now reading response\n"); #endif handle->receiving = GNUNET_YES; - GNUNET_CLIENT_receive (handle->client, - &receive_stats, - handle, - GNUNET_TIME_absolute_get_remaining (handle-> - current->timeout)); + GNUNET_CLIENT_receive (handle->client, &receive_stats, handle, + GNUNET_TIME_absolute_get_remaining (handle->current-> + timeout)); } return msize; } @@ -611,8 +602,8 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) return 0; } #if DEBUG_STATISTICS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting watch request for `%s'\n", handle->current->name); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting watch request for `%s'\n", + handle->current->name); #endif slen1 = strlen (handle->current->subsystem) + 1; slen2 = strlen (handle->current->name) + 1; @@ -622,17 +613,14 @@ transmit_watch (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) hdr->size = htons (msize); hdr->type = htons (GNUNET_MESSAGE_TYPE_STATISTICS_WATCH); GNUNET_assert (slen1 + slen2 == - GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], - slen1 + slen2, - 2, + GNUNET_STRINGS_buffer_fill ((char *) &hdr[1], slen1 + slen2, 2, handle->current->subsystem, handle->current->name)); if (GNUNET_YES != handle->receiving) { handle->receiving = GNUNET_YES; - GNUNET_CLIENT_receive (handle->client, - &receive_stats, - handle, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (handle->client, &receive_stats, handle, + GNUNET_TIME_UNIT_FOREVER_REL); } finish (handle, GNUNET_OK); return msize; @@ -675,9 +663,7 @@ transmit_set (struct GNUNET_STATISTICS_Handle *handle, size_t size, void *buf) if (handle->current->type == ACTION_UPDATE) r->flags |= htonl (GNUNET_STATISTICS_SETFLAG_RELATIVE); GNUNET_assert (slen + nlen == - GNUNET_STRINGS_buffer_fill ((char *) &r[1], - slen + nlen, - 2, + GNUNET_STRINGS_buffer_fill ((char *) &r[1], slen + nlen, 2, handle->current->subsystem, handle->current->name)); finish (handle, GNUNET_OK); @@ -809,11 +795,10 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int sync_first) if ((h->current != NULL) && (h->th == NULL)) { timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout); - h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, - h->current->msize, - timeout, - GNUNET_YES, - &transmit_action, h); + h->th = + GNUNET_CLIENT_notify_transmit_ready (h->client, h->current->msize, + timeout, GNUNET_YES, + &transmit_action, h); GNUNET_assert (NULL != h->th); } if (h->th != NULL) @@ -870,11 +855,11 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) return; /* action already pending */ if (GNUNET_YES != try_connect (h)) { - h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff, - &finish_task, h); + h->backoff_task = + GNUNET_SCHEDULER_add_delayed (h->backoff, &finish_task, h); h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); - h->backoff = GNUNET_TIME_relative_min (h->backoff, - GNUNET_CONSTANTS_SERVICE_TIMEOUT); + h->backoff = + GNUNET_TIME_relative_min (h->backoff, GNUNET_CONSTANTS_SERVICE_TIMEOUT); return; } @@ -892,11 +877,10 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) GNUNET_CONTAINER_DLL_remove (h->action_head, h->action_tail, h->current); timeout = GNUNET_TIME_absolute_get_remaining (h->current->timeout); if (NULL == - (h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, - h->current->msize, - timeout, - GNUNET_YES, - &transmit_action, h))) + (h->th = + GNUNET_CLIENT_notify_transmit_ready (h->client, h->current->msize, + timeout, GNUNET_YES, + &transmit_action, h))) { #if DEBUG_STATISTICS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -922,8 +906,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) */ struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, - const char *subsystem, - const char *name, + const char *subsystem, const char *name, struct GNUNET_TIME_Relative timeout, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls) @@ -1005,8 +988,7 @@ GNUNET_STATISTICS_get_cancel (struct GNUNET_STATISTICS_GetHandle *gh) */ int GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, - const char *subsystem, - const char *name, + const char *subsystem, const char *name, GNUNET_STATISTICS_Iterator proc, void *proc_cls) { struct GNUNET_STATISTICS_WatchEntry *w; @@ -1025,8 +1007,7 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, static void -add_setter_action (struct GNUNET_STATISTICS_Handle *h, - const char *name, +add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name, int make_persistent, uint64_t value, enum ActionType type) { struct GNUNET_STATISTICS_GetHandle *ai; @@ -1051,8 +1032,8 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, while (ai != NULL) { if ((0 == strcmp (ai->subsystem, h->subsystem)) && - (0 == strcmp (ai->name, name)) && - ((ai->type == ACTION_UPDATE) || (ai->type == ACTION_SET))) + (0 == strcmp (ai->name, name)) && ((ai->type == ACTION_UPDATE) || + (ai->type == ACTION_SET))) { if (ai->type == ACTION_SET) { @@ -1146,8 +1127,8 @@ GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, if (delta == 0) return; GNUNET_assert (GNUNET_NO == handle->do_destroy); - add_setter_action (handle, name, make_persistent, - (uint64_t) delta, ACTION_UPDATE); + add_setter_action (handle, name, make_persistent, (uint64_t) delta, + ACTION_UPDATE); } diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index de05d6c69..39a71a79e 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c @@ -34,12 +34,10 @@ #define START_SERVICE GNUNET_YES static int -check_1 (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received value %llu for `%s:%s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received value %llu for `%s:%s\n", (unsigned long long) value, subsystem, name); GNUNET_assert (0 == strcmp (name, "test-1")); GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); @@ -49,12 +47,10 @@ check_1 (void *cls, } static int -check_2 (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +check_2 (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received value %llu for `%s:%s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received value %llu for `%s:%s\n", (unsigned long long) value, subsystem, name); GNUNET_assert (0 == strcmp (name, "test-2")); GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); @@ -64,12 +60,10 @@ check_2 (void *cls, } static int -check_3 (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +check_3 (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received value %llu for `%s:%s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received value %llu for `%s:%s\n", (unsigned long long) value, subsystem, name); GNUNET_assert (0 == strcmp (name, "test-3")); GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api")); @@ -102,9 +96,8 @@ next (void *cls, int success) } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); @@ -119,9 +112,8 @@ run (void *cls, } static void -run_more (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run_more (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); GNUNET_break (NULL != @@ -151,16 +143,17 @@ check () #if START_SERVICE struct GNUNET_OS_Process *proc; - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", + "gnunet-service-statistics", #if DEBUG_STATISTICS - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_statistics_api_data.conf", NULL); + "-c", "test_statistics_api_data.conf", NULL); #endif GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, &run, + &ok); #if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { @@ -176,15 +169,16 @@ check () ok = 1; #if START_SERVICE /* restart to check persistence! */ - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", + "gnunet-service-statistics", #if DEBUG_STATISTICS - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_statistics_api_data.conf", NULL); + "-c", "test_statistics_api_data.conf", NULL); #endif - GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", - options, &run_more, &ok); + GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, + &run_more, &ok); #if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index 87190a99a..eb739b752 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c @@ -36,9 +36,8 @@ #define ROUNDS (1024 * 1024) static int -check_1 (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { GNUNET_assert (0 == strcmp (name, "test-0")); GNUNET_assert (0 == strcmp (subsystem, "test-statistics-api-loop")); @@ -59,9 +58,8 @@ next (void *cls, int success) } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int i; char name[128]; @@ -98,16 +96,17 @@ check () #if START_SERVICE struct GNUNET_OS_Process *proc; - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", + "gnunet-service-statistics", #if DEBUG_STATISTICS - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_statistics_api_data.conf", NULL); + "-c", "test_statistics_api_data.conf", NULL); #endif GNUNET_assert (NULL != proc); - GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, + &ok); #if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c index 72cb27ecf..cea495836 100644 --- a/src/statistics/test_statistics_api_watch.c +++ b/src/statistics/test_statistics_api_watch.c @@ -63,9 +63,8 @@ normal_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static int -watch_1 (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { GNUNET_assert (value == 42); GNUNET_assert (0 == strcmp (name, "test-1")); @@ -80,9 +79,8 @@ watch_1 (void *cls, static int -watch_2 (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { GNUNET_assert (value == 43); GNUNET_assert (0 == strcmp (name, "test-2")); @@ -97,24 +95,22 @@ watch_2 (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { h = GNUNET_STATISTICS_create ("dummy", cfg); GNUNET_assert (GNUNET_OK == - GNUNET_STATISTICS_watch (h, - "test-statistics-api-watch", + GNUNET_STATISTICS_watch (h, "test-statistics-api-watch", "test-1", &watch_1, NULL)); GNUNET_assert (GNUNET_OK == - GNUNET_STATISTICS_watch (h, - "test-statistics-api-watch", + GNUNET_STATISTICS_watch (h, "test-statistics-api-watch", "test-2", &watch_2, NULL)); h2 = GNUNET_STATISTICS_create ("test-statistics-api-watch", cfg); GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); - shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &force_shutdown, NULL); + shutdown_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &force_shutdown, + NULL); } @@ -132,17 +128,18 @@ check () #if START_SERVICE struct GNUNET_OS_Process *proc; - proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", + proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", + "gnunet-service-statistics", #if VERBOSE - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", "test_statistics_api_data.conf", NULL); + "-c", "test_statistics_api_data.conf", NULL); #endif GNUNET_assert (NULL != proc); ok = 3; - GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", - options, &run, NULL); + GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, + NULL); #if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { diff --git a/src/template/gnunet-service-template.c b/src/template/gnunet-service-template.c index 8ee88c961..54b7ecc94 100644 --- a/src/template/gnunet-service-template.c +++ b/src/template/gnunet-service-template.c @@ -49,8 +49,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param cfg configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -59,8 +58,8 @@ run (void *cls, }; /* FIXME: do setup here */ GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleanup_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, + NULL); } @@ -75,9 +74,7 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "template", + GNUNET_SERVICE_run (argc, argv, "template", GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; } diff --git a/src/template/gnunet-template.c b/src/template/gnunet-template.c index 657b3d4ce..7b1d9dfff 100644 --- a/src/template/gnunet-template.c +++ b/src/template/gnunet-template.c @@ -42,9 +42,8 @@ static int ret; * @param cfg configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { /* main code here */ } @@ -65,11 +64,9 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-template", - gettext_noop ("help text"), - options, &run, NULL)) ? ret : 1; + GNUNET_PROGRAM_run (argc, argv, "gnunet-template", + gettext_noop ("help text"), options, &run, + NULL)) ? ret : 1; } /* end of gnunet-template.c */ diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c index 88861a156..3e2cd65ee 100644 --- a/src/testing/test_testing.c +++ b/src/testing/test_testing.c @@ -59,8 +59,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -my_cb (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -74,9 +73,8 @@ my_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_TESTING_Daemon *d; @@ -103,8 +101,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing", "nohelp", options, &run, &ok); return ok; } diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index 19e3bb1c0..4fe3a1dd6 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c @@ -90,8 +90,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -my_connect_complete (void *cls, - const struct GNUNET_PeerIdentity *first, +my_connect_complete (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, unsigned int distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, @@ -105,32 +104,29 @@ my_connect_complete (void *cls, static void -my_cb2 (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb2 (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { GNUNET_assert (id != NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Daemon `%s' started.\n", GNUNET_i2s (id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n", + GNUNET_i2s (id)); #endif - GNUNET_TESTING_daemons_connect (d1, d2, - TIMEOUT, CONNECT_ATTEMPTS, - GNUNET_YES, &my_connect_complete, NULL); + GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, GNUNET_YES, + &my_connect_complete, NULL); } static void -my_cb1 (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb1 (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { GNUNET_assert (id != NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Daemon `%s' started.\n", GNUNET_i2s (id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n", + GNUNET_i2s (id)); #endif d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, &my_cb2, NULL); @@ -140,9 +136,8 @@ my_cb1 (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { ok = 1; #if VERBOSE @@ -171,9 +166,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-connect", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-connect", "nohelp", options, &run, &ok); return ok; } diff --git a/src/testing/test_testing_group.c b/src/testing/test_testing_group.c index 88893f45d..f5df45b19 100644 --- a/src/testing/test_testing_group.c +++ b/src/testing/test_testing_group.c @@ -65,8 +65,7 @@ shutdown_callback (void *cls, const char *emsg) static void -my_cb (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -105,9 +104,8 @@ my_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { ok = 1; #if VERBOSE @@ -117,9 +115,8 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ peers_left, /* Number of outstanding connections */ peers_left, /* Number of parallel ssh connections, or peers being started at once */ - TIMEOUT, - NULL, NULL, - &my_cb, NULL, NULL, NULL, NULL); + TIMEOUT, NULL, NULL, &my_cb, NULL, NULL, + NULL, NULL); GNUNET_assert (pg != NULL); } @@ -137,8 +134,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-group", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-group", "nohelp", options, &run, &ok); return ok; } diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c index d43e7ed57..e300f95e3 100644 --- a/src/testing/test_testing_group_remote.c +++ b/src/testing/test_testing_group_remote.c @@ -72,8 +72,7 @@ shutdown_callback (void *cls, const char *emsg) static void -my_cb (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -98,9 +97,8 @@ my_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_TESTING_Host *hosts; struct GNUNET_TESTING_Host *hostpos; @@ -133,8 +131,9 @@ run (void *cls, if (hostfile != NULL) { if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) - GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_fn_write (hostfile, NULL, 0, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -202,9 +201,8 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ peers_left, /* Number of outstanding connections */ peers_left, /* Number of parallel ssh connections, or peers being started at once */ - TIMEOUT, - NULL, - NULL, &my_cb, NULL, NULL, NULL, hosts); + TIMEOUT, NULL, NULL, &my_cb, NULL, NULL, + NULL, hosts); hostpos = hosts; while (hostpos != NULL) { @@ -233,8 +231,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-group", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-group", "nohelp", options, &run, &ok); return ok; } diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c index 62922e9e8..9581dc9b2 100644 --- a/src/testing/test_testing_large_topology.c +++ b/src/testing/test_testing_large_topology.c @@ -185,9 +185,9 @@ gather_log_data () GNUNET_asprintf (&peer_number, "%llu", num_peers); GNUNET_asprintf (&connect_number, "%llu", expected_connections); - mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", - "memsize.pl", "totals.txt", - peer_number, connect_number, NULL); + mem_process = + GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", "memsize.pl", + "totals.txt", peer_number, connect_number, NULL); GNUNET_OS_process_wait (mem_process); GNUNET_OS_process_close (mem_process); mem_process = NULL; @@ -257,15 +257,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Disconnect from the respective cores */ #if VERBOSE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting from peer 1 `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); #endif if (pos->peer1handle != NULL) GNUNET_CORE_disconnect (pos->peer1handle); #if VERBOSE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting from peer 2 `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); #endif if (pos->peer2handle != NULL) @@ -280,8 +278,7 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -topology_cb (void *cls, - const struct GNUNET_PeerIdentity *first, +topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, const char *emsg) { FILE *outfile = cls; @@ -310,8 +307,7 @@ topology_cb (void *cls, } static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -330,8 +326,8 @@ process_mtype (void *cls, fprintf (stdout, "0%%"); else fprintf (stdout, "%d%%", - (int) (((float) total_messages_received / - expected_messages) * 100)); + (int) (((float) total_messages_received / expected_messages) * + 100)); } else if (total_messages_received % dotnum == 0) @@ -462,8 +458,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { }; static void -init_notify_peer2 (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) @@ -481,13 +476,11 @@ init_notify_peer2 (void *cls, GNUNET_i2s (my_identity), GNUNET_h2s (&pos->peer1->id.hashPubKey)); #endif - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - 0, - timeout, - &pos->peer2->id, - sizeof (struct - GNUNET_TestMessage), - &transmit_ready, pos)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 0, timeout, + &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", @@ -509,9 +502,7 @@ init_notify_peer2 (void *cls, * @param atsi performance data for the connection */ static void -connect_notify_peers (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct TestMessageContext *pos = cls; @@ -536,13 +527,11 @@ connect_notify_peers (void *cls, GNUNET_i2s (&pos->peer2->id), GNUNET_h2s (&pos->peer1->id.hashPubKey)); #endif - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - 0, - timeout, - &pos->peer2->id, - sizeof (struct - GNUNET_TestMessage), - &transmit_ready, pos)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 0, timeout, + &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", @@ -557,8 +546,7 @@ connect_notify_peers (void *cls, } static void -init_notify_peer1 (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) @@ -576,15 +564,10 @@ init_notify_peer1 (void *cls, /* * Connect to the receiving peer */ - pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, - 1, - pos, - &init_notify_peer2, - NULL, - NULL, - NULL, NULL, - GNUNET_YES, NULL, GNUNET_YES, - handlers); + pos->peer2handle = + GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, NULL, + NULL, NULL, NULL, GNUNET_YES, NULL, GNUNET_YES, + handlers); } @@ -604,9 +587,9 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (die_task == GNUNET_SCHEDULER_NO_TASK) { - die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, - &end_badly, - "from send test messages (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly, + "from send test messages (timeout)"); } if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) @@ -620,15 +603,10 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* * Connect to the sending peer */ - pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, - 1, - pos, - &init_notify_peer1, - &connect_notify_peers, NULL, - NULL, - NULL, - GNUNET_NO, NULL, GNUNET_NO, - no_handlers); + pos->peer1handle = + GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1, + &connect_notify_peers, NULL, NULL, NULL, GNUNET_NO, + NULL, GNUNET_NO, no_handlers); GNUNET_assert (pos->peer1handle != NULL); @@ -646,10 +624,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -667,8 +643,8 @@ topology_callback (void *cls, fprintf (stdout, "0%%"); else fprintf (stdout, "%d%%", - (int) (((float) total_connections / - expected_connections) * 100)); + (int) (((float) total_connections / expected_connections) * + 100)); } else if (total_connections % dotnum == 0) @@ -787,12 +763,11 @@ connect_topology () GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier, - connect_timeout, - connect_attempts, + connect_timeout, connect_attempts, &topology_creation_finished, NULL); #if VERBOSE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Have %d expected connections\n", expected_connections); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", + expected_connections); #endif } @@ -804,9 +779,9 @@ connect_topology () "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly, + "from connect topology (timeout)"); modnum = expected_connections / 4; dotnum = (expected_connections / 50) + 1; #if VERBOSE @@ -836,15 +811,14 @@ create_topology () "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, - &end_badly, - "from continue startup (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly, + "from continue startup (timeout)"); } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -888,9 +862,9 @@ peers_started_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (timeout, - &end_badly, - "from peers_started_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (timeout, &end_badly, + "from peers_started_callback"); #if DELAY_FOR_LOGGING fprintf (stdout, "Connecting topology in 10 seconds\n"); gather_log_data (); @@ -913,8 +887,7 @@ peers_started_callback (void *cls, * @param emsg non-null on failure */ void -hostkey_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_TESTING_Daemon *d, const char *emsg) { if (emsg != NULL) @@ -925,8 +898,8 @@ hostkey_callback (void *cls, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey (%d/%d) created for peer `%s'\n", - num_peers - peers_left, num_peers, GNUNET_i2s (id)); + "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, + num_peers, GNUNET_i2s (id)); #endif #if VERBOSE @@ -956,18 +929,17 @@ hostkey_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, - &end_badly, - "from create_topology"); + die_task = + GNUNET_SCHEDULER_add_delayed (test_timeout, &end_badly, + "from create_topology"); GNUNET_SCHEDULER_add_now (&create_topology, NULL); ok = 0; } } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *topology_str; char *connect_topology_str; @@ -999,8 +971,8 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", - &topology_str)) - && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) + &topology_str)) && + (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -1011,10 +983,10 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology", - &connect_topology_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_get (&connection_topology, - connect_topology_str))) + &connect_topology_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&connection_topology, + connect_topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology `%s' given for section %s option %s\n", @@ -1024,10 +996,10 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option", - &connect_topology_option_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_option_get (&connect_topology_option, - connect_topology_option_str))) + &connect_topology_option_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_option_get (&connect_topology_option, + connect_topology_option_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology option `%s' given for section %s option %s\n", @@ -1063,10 +1035,10 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "blacklist_topology", - &blacklist_topology_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_get (&blacklist_topology, - blacklist_topology_str))) + &blacklist_topology_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&blacklist_topology, + blacklist_topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -1135,18 +1107,13 @@ run (void *cls, #endif /* Set up a task to end testing if peer start fails */ die_task = - GNUNET_SCHEDULER_add_delayed (timeout, - &end_badly, + GNUNET_SCHEDULER_add_delayed (timeout, &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); - pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - peers_left / 2, - peers_left, - timeout, - &hostkey_callback, NULL, - &peers_started_callback, NULL, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left / 2, + peers_left, timeout, &hostkey_callback, + NULL, &peers_started_callback, NULL, &topology_callback, NULL, NULL); } @@ -1173,8 +1140,9 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, binary_name, "nohelp", options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + binary_name, "nohelp", options, &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/testing/test_testing_peergroup.c b/src/testing/test_testing_peergroup.c index f06864036..061a0ca75 100644 --- a/src/testing/test_testing_peergroup.c +++ b/src/testing/test_testing_peergroup.c @@ -99,9 +99,8 @@ my_cb (void *cls, const char *emsg) static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_CONFIGURATION_Handle *testing_cfg; @@ -114,9 +113,8 @@ run (void *cls, "use_progressbars", "YES"); #endif peers_left = NUM_PEERS; - pg = GNUNET_TESTING_peergroup_start (testing_cfg, - peers_left, - TIMEOUT, NULL, &my_cb, NULL, NULL); + pg = GNUNET_TESTING_peergroup_start (testing_cfg, peers_left, TIMEOUT, NULL, + &my_cb, NULL, NULL); GNUNET_assert (pg != NULL); } @@ -134,9 +132,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-peergroup", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-peergroup", "nohelp", options, &run, &ok); return ok; } diff --git a/src/testing/test_testing_reconnect.c b/src/testing/test_testing_reconnect.c index 1e028779f..480bafdc6 100644 --- a/src/testing/test_testing_reconnect.c +++ b/src/testing/test_testing_reconnect.c @@ -113,8 +113,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -my_connect_complete (void *cls, - const struct GNUNET_PeerIdentity *first, +my_connect_complete (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, unsigned int distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, @@ -134,32 +133,29 @@ my_connect_complete (void *cls, static void -my_cb2 (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb2 (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { GNUNET_assert (id != NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Daemon `%s' started.\n", GNUNET_i2s (id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n", + GNUNET_i2s (id)); #endif - GNUNET_TESTING_daemons_connect (d1, d2, - TIMEOUT, CONNECT_ATTEMPTS, - GNUNET_YES, &my_connect_complete, NULL); + GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, GNUNET_YES, + &my_connect_complete, NULL); } static void -my_cb1 (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb1 (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { GNUNET_assert (id != NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Daemon `%s' started.\n", GNUNET_i2s (id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n", + GNUNET_i2s (id)); #endif d2 = GNUNET_TESTING_daemon_start (c2, TIMEOUT, GNUNET_NO, NULL, NULL, 0, NULL, NULL, NULL, &my_cb2, NULL); @@ -168,9 +164,8 @@ my_cb1 (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { ok = 1; #if VERBOSE @@ -206,9 +201,8 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-reconnect", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-reconnect", "nohelp", options, &run, &ok); return ok; } diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 73b49e469..27ad0a24c 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -193,9 +193,9 @@ gather_log_data () GNUNET_asprintf (&peer_number, "%llu", num_peers); GNUNET_asprintf (&connect_number, "%llu", expected_connections); - mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", - "memsize.pl", "totals.txt", - peer_number, connect_number, NULL); + mem_process = + GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", "memsize.pl", + "totals.txt", peer_number, connect_number, NULL); GNUNET_OS_process_wait (mem_process); GNUNET_OS_process_close (mem_process); mem_process = NULL; @@ -265,15 +265,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Disconnect from the respective cores */ #if VERBOSE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting from peer 1 `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); #endif if (pos->peer1handle != NULL) GNUNET_CORE_disconnect (pos->peer1handle); #if VERBOSE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting from peer 2 `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); #endif if (pos->peer2handle != NULL) @@ -305,20 +303,18 @@ stats_finished (void *cls, int result) * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration */ static int -stats_print (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +stats_print (void *cls, const struct GNUNET_PeerIdentity *peer, + const char *subsystem, const char *name, uint64_t value, + int is_persistent) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n", - GNUNET_i2s (peer), subsystem, name, value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n", GNUNET_i2s (peer), + subsystem, name, value); return GNUNET_OK; } #endif static void -topology_cb (void *cls, - const struct GNUNET_PeerIdentity *first, +topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, const char *emsg) { FILE *outfile = cls; @@ -350,8 +346,7 @@ topology_cb (void *cls, } static int -process_mtype (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -370,8 +365,8 @@ process_mtype (void *cls, fprintf (stdout, "0%%"); else fprintf (stdout, "%d%%", - (int) (((float) total_messages_received / - expected_messages) * 100)); + (int) (((float) total_messages_received / expected_messages) * + 100)); } else if (total_messages_received % dotnum == 0) @@ -502,8 +497,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { }; static void -init_notify_peer2 (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) @@ -521,14 +515,11 @@ init_notify_peer2 (void *cls, GNUNET_i2s (my_identity), GNUNET_h2s (&pos->peer1->id.hashPubKey)); #endif - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - GNUNET_YES, - 0, - TIMEOUT, - &pos->peer2->id, - sizeof (struct - GNUNET_TestMessage), - &transmit_ready, pos)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, + TIMEOUT, &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", @@ -550,9 +541,7 @@ init_notify_peer2 (void *cls, * @param atsi performance data for the connection */ static void -connect_notify_peers (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct TestMessageContext *pos = cls; @@ -577,14 +566,11 @@ connect_notify_peers (void *cls, GNUNET_i2s (&pos->peer2->id), GNUNET_h2s (&pos->peer1->id.hashPubKey)); #endif - if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, - GNUNET_YES, - 0, - TIMEOUT, - &pos->peer2->id, - sizeof (struct - GNUNET_TestMessage), - &transmit_ready, pos)) + if (NULL == + GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, + TIMEOUT, &pos->peer2->id, + sizeof (struct GNUNET_TestMessage), + &transmit_ready, pos)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", @@ -599,8 +585,7 @@ connect_notify_peers (void *cls, } static void -init_notify_peer1 (void *cls, - struct GNUNET_CORE_Handle *server, +init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) @@ -618,15 +603,10 @@ init_notify_peer1 (void *cls, /* * Connect to the receiving peer */ - pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, - 1, - pos, - &init_notify_peer2, - NULL, - NULL, - NULL, NULL, - GNUNET_YES, NULL, GNUNET_YES, - handlers); + pos->peer2handle = + GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, NULL, + NULL, NULL, NULL, GNUNET_YES, NULL, GNUNET_YES, + handlers); } @@ -646,9 +626,9 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (die_task == GNUNET_SCHEDULER_NO_TASK) { - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "from send test messages (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "from send test messages (timeout)"); } if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) @@ -662,15 +642,10 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* * Connect to the sending peer */ - pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, - 1, - pos, - &init_notify_peer1, - &connect_notify_peers, NULL, - NULL, - NULL, - GNUNET_NO, NULL, GNUNET_NO, - no_handlers); + pos->peer1handle = + GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1, + &connect_notify_peers, NULL, NULL, NULL, GNUNET_NO, + NULL, GNUNET_NO, no_handlers); GNUNET_assert (pos->peer1handle != NULL); @@ -688,10 +663,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -709,8 +682,8 @@ topology_callback (void *cls, fprintf (stdout, "0%%"); else fprintf (stdout, "%d%%", - (int) (((float) total_connections / - expected_connections) * 100)); + (int) (((float) total_connections / expected_connections) * + 100)); } else if (total_connections % dotnum == 0) @@ -833,12 +806,11 @@ connect_topology () GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier, - connect_timeout, - connect_attempts, + connect_timeout, connect_attempts, &topology_creation_finished, NULL); #if PROGRESS_BARS - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Have %d expected connections\n", expected_connections); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %d expected connections\n", + expected_connections); #endif } @@ -851,11 +823,12 @@ connect_topology () return; } - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - SECONDS_PER_PEER_START * num_peers), - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, + SECONDS_PER_PEER_START * num_peers), + &end_badly, + "from connect topology (timeout)"); modnum = expected_connections / 4; dotnum = (expected_connections / 50) + 1; if (modnum == 0) @@ -889,17 +862,17 @@ create_topology () "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - SECONDS_PER_PEER_START * num_peers), - &end_badly, - "from continue startup (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, + SECONDS_PER_PEER_START * num_peers), + &end_badly, + "from continue startup (timeout)"); } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -943,10 +916,10 @@ peers_started_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 8), - &end_badly, - "from peers_started_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 8), &end_badly, + "from peers_started_callback"); #if DELAY_FOR_LOGGING fprintf (stdout, "Connecting topology in 10 seconds\n"); gather_log_data (); @@ -969,8 +942,7 @@ peers_started_callback (void *cls, * @param emsg non-null on failure */ void -hostkey_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_TESTING_Daemon *d, const char *emsg) { if (emsg != NULL) @@ -981,8 +953,8 @@ hostkey_callback (void *cls, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey (%d/%d) created for peer `%s'\n", - num_peers - peers_left, num_peers, GNUNET_i2s (id)); + "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, + num_peers, GNUNET_i2s (id)); #endif #if PROGRESS_BARS @@ -1012,18 +984,17 @@ hostkey_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, - &end_badly, - "from create_topology"); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, + "from create_topology"); GNUNET_SCHEDULER_add_now (&create_topology, NULL); ok = 0; } } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { char *topology_str; char *connect_topology_str; @@ -1056,8 +1027,8 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", - &topology_str)) - && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) + &topology_str)) && + (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -1068,10 +1039,10 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology", - &connect_topology_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_get (&connection_topology, - connect_topology_str))) + &connect_topology_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&connection_topology, + connect_topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology `%s' given for section %s option %s\n", @@ -1081,10 +1052,10 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option", - &connect_topology_option_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_option_get (&connect_topology_option, - connect_topology_option_str))) + &connect_topology_option_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_option_get (&connect_topology_option, + connect_topology_option_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology option `%s' given for section %s option %s\n", @@ -1120,10 +1091,10 @@ run (void *cls, if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "blacklist_topology", - &blacklist_topology_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_get (&blacklist_topology, - blacklist_topology_str))) + &blacklist_topology_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&blacklist_topology, + blacklist_topology_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -1196,10 +1167,8 @@ run (void *cls, "didn't generate all hostkeys within a reasonable amount of time!!!"); GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); - pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - max_outstanding_connections, - peers_left, + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, + max_outstanding_connections, peers_left, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), @@ -1231,8 +1200,9 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, binary_name, "nohelp", options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + binary_name, "nohelp", options, &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index f9185b6fc..d60e3a8fb 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c @@ -173,10 +173,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) void -topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -222,9 +220,9 @@ topology_callback (void *cls, } else if (total_connections + failed_connections == expected_connections) { - if ((failed_connections == expected_failed_connections) - && (total_connections == - expected_connections - expected_failed_connections)) + if ((failed_connections == expected_failed_connections) && + (total_connections == + expected_connections - expected_failed_connections)) { GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_NO_TASK; @@ -260,11 +258,11 @@ connect_topology () GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier, - connect_timeout, - connect_attempts, NULL, NULL); + connect_timeout, connect_attempts, + NULL, NULL); #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Have %d expected connections\n", expected_connections); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", + expected_connections); #endif } @@ -276,9 +274,9 @@ connect_topology () "from connect topology (bad return)"); } - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "from connect topology (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "from connect topology (timeout)"); } static void @@ -302,15 +300,14 @@ create_topology () "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, - &end_badly, - "from continue startup (timeout)"); + die_task = + GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, + "from continue startup (timeout)"); } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -335,10 +332,10 @@ peers_started_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "from peers_started_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "from peers_started_callback"); connect_topology (); ok = 0; } @@ -353,8 +350,7 @@ peers_started_callback (void *cls, * @param emsg non-null on failure */ void -hostkey_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, struct GNUNET_TESTING_Daemon *d, const char *emsg) { if (emsg != NULL) @@ -364,8 +360,8 @@ hostkey_callback (void *cls, } #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey created for peer `%s'\n", GNUNET_i2s (id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostkey created for peer `%s'\n", + GNUNET_i2s (id)); #endif peers_left--; if (peers_left == 0) @@ -377,19 +373,18 @@ hostkey_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "from hostkey_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "from hostkey_callback"); GNUNET_SCHEDULER_add_now (&create_topology, NULL); ok = 0; } } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { unsigned long long topology_num; unsigned long long connect_topology_num; @@ -429,8 +424,7 @@ run (void *cls, topology = topology_num; if (GNUNET_YES == - GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "connect_topology", + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_topology", &connect_topology_num)) connection_topology = connect_topology_num; @@ -528,15 +522,14 @@ run (void *cls, /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "didn't start all daemons in reasonable amount of time!!!"); - - pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, peers_left, peers_left, - TIMEOUT, &hostkey_callback, - NULL, &peers_started_callback, NULL, + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "didn't start all daemons in reasonable amount of time!!!"); + + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left, peers_left, + TIMEOUT, &hostkey_callback, NULL, + &peers_started_callback, NULL, &topology_callback, NULL, NULL); } @@ -557,9 +550,10 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-topology-blacklist", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-topology-blacklist", "nohelp", options, + &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c index ee800c52c..5a348642c 100644 --- a/src/testing/test_testing_topology_churn.c +++ b/src/testing/test_testing_topology_churn.c @@ -198,8 +198,7 @@ churn_peers_off () } static void -peers_started_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -224,10 +223,10 @@ peers_started_callback (void *cls, GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "from peers_started_callback"); + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "from peers_started_callback"); churn_peers_off (); ok = 0; } @@ -235,9 +234,8 @@ peers_started_callback (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { ok = 1; @@ -274,18 +272,15 @@ run (void *cls, /* Set up a task to end testing if peer start fails */ - die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, 5), - &end_badly, - "didn't start all daemons in reasonable amount of time!!!"); - - pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - peers_left, - peers_left, + die_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, + "didn't start all daemons in reasonable amount of time!!!"); + + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left, peers_left, TIMEOUT, NULL, NULL, - &peers_started_callback, NULL, NULL, - NULL, NULL); + &peers_started_callback, NULL, NULL, NULL, + NULL); } @@ -305,9 +300,10 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-testing-topology-churn", "nohelp", - options, &run, &ok); + ret = + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-testing-topology-churn", "nohelp", options, + &run, &ok); if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/testing/testing.c b/src/testing/testing.c index c21166775..c107ec593 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -67,10 +67,9 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} }; #if EMPTY_HACK static int -test_address (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +test_address (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { int *empty = cls; @@ -144,8 +143,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) } #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' from transport service of `%4s'\n", - "HELLO", GNUNET_i2s (&daemon->id)); + "Received `%s' from transport service of `%4s'\n", "HELLO", + GNUNET_i2s (&daemon->id)); #endif GNUNET_free_non_null (daemon->hello); @@ -165,8 +164,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) #endif } -static void -start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void start_fsm (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); #if WAIT_FOR_HELLO /** @@ -182,8 +181,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); * @param publicKey public key of this peer, NULL if we failed */ static void -testing_init (void *cls, - struct GNUNET_CORE_Handle *server, +testing_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -197,17 +195,18 @@ testing_init (void *cls, d->server = NULL; if (GNUNET_YES == d->dead) GNUNET_TESTING_daemon_stop (d, - GNUNET_TIME_absolute_get_remaining - (d->max_timeout), d->dead_cb, - d->dead_cb_cls, GNUNET_YES, GNUNET_NO); + GNUNET_TIME_absolute_get_remaining (d-> + max_timeout), + d->dead_cb, d->dead_cb_cls, GNUNET_YES, + GNUNET_NO); else if (NULL != d->cb) d->cb (d->cb_cls, NULL, d->cfg, d, _("Failed to connect to core service\n")); return; } #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started peer `%4s'.\n", + GNUNET_i2s (my_identity)); #endif d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */ if (d->shortname == NULL) @@ -234,9 +233,10 @@ testing_init (void *cls, { if (GNUNET_YES == d->dead) GNUNET_TESTING_daemon_stop (d, - GNUNET_TIME_absolute_get_remaining - (d->max_timeout), d->dead_cb, - d->dead_cb_cls, GNUNET_YES, GNUNET_NO); + GNUNET_TIME_absolute_get_remaining (d-> + max_timeout), + d->dead_cb, d->dead_cb_cls, GNUNET_YES, + GNUNET_NO); else if (NULL != d->cb) d->cb (d->cb_cls, &d->id, d->cfg, d, _("Failed to connect to transport service!\n")); @@ -252,9 +252,8 @@ testing_init (void *cls, /* wait some more */ if (d->task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (d->task); - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); } #endif @@ -312,17 +311,15 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, d, + cb (d->cb_cls, NULL, d->cfg, d, _ ("`scp' does not seem to terminate (timeout copying config).\n")); return; } /* wait some more */ - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); return; } if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) @@ -350,13 +347,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, - d, - (NULL == d->hostname) - ? _("Failed to create pipe for `gnunet-peerinfo' process.\n") - : _("Failed to create pipe for `ssh' process.\n")); + cb (d->cb_cls, NULL, d->cfg, d, + (NULL == + d-> + hostname) ? + _("Failed to create pipe for `gnunet-peerinfo' process.\n") : + _("Failed to create pipe for `ssh' process.\n")); return; } if (NULL == d->hostname) @@ -369,8 +365,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo", - "gnunet-peerinfo", "-c", d->cfgfile, - "-sq", NULL); + "gnunet-peerinfo", "-c", d->cfgfile, "-sq", + NULL); GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); } else @@ -392,20 +388,19 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if !DEBUG_TESTING "-q", #endif - dst, - "gnunet-peerinfo", - "-c", d->cfgfile, "-sq", NULL); + dst, "gnunet-peerinfo", "-c", + d->cfgfile, "-sq", NULL); } else { - d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", - "ssh", "-p", d->ssh_port_str, + d->proc = + GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", "ssh", "-p", + d->ssh_port_str, #if !DEBUG_TESTING - "-q", + "-q", #endif - dst, - "gnunet-peerinfo", - "-c", d->cfgfile, "-sq", NULL); + dst, "gnunet-peerinfo", "-c", d->cfgfile, + "-sq", NULL); } GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); GNUNET_free (dst); @@ -418,13 +413,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, - d, - (NULL == d->hostname) - ? _("Failed to start `gnunet-peerinfo' process.\n") - : _("Failed to start `ssh' process.\n")); + cb (d->cb_cls, NULL, d->cfg, d, + (NULL == + d-> + hostname) ? _("Failed to start `gnunet-peerinfo' process.\n") : + _("Failed to start `ssh' process.\n")); GNUNET_DISK_pipe_close (d->pipe_stdout); return; } @@ -433,13 +426,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Started `%s', waiting for hostkey.\n", "gnunet-peerinfo"); #endif d->phase = SP_HOSTKEY_CREATE; - d->task - = + d->task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining (d->max_timeout), - GNUNET_DISK_pipe_handle - (d->pipe_stdout, - GNUNET_DISK_PIPE_END_READ), + GNUNET_DISK_pipe_handle (d-> + pipe_stdout, + GNUNET_DISK_PIPE_END_READ), &start_fsm, d); } else /* Already have a hostkey! */ @@ -469,21 +461,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((d->hostkeybufpos < 104) && (bytes_read > 0)) { /* keep reading */ - d->task - = + d->task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining (d->max_timeout), - GNUNET_DISK_pipe_handle - (d->pipe_stdout, - GNUNET_DISK_PIPE_END_READ), + GNUNET_DISK_pipe_handle (d-> + pipe_stdout, + GNUNET_DISK_PIPE_END_READ), &start_fsm, d); return; } d->hostkeybuf[103] = '\0'; if ((bytes_read < 0) || - (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, - &d->id.hashPubKey))) + (GNUNET_OK != + GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, &d->id.hashPubKey))) { /* error */ if (bytes_read < 0) @@ -529,20 +520,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Fall through */ case SP_HOSTKEY_CREATED: /* wait for topology finished */ - if ((GNUNET_YES == d->dead) - || (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)) + if ((GNUNET_YES == d->dead) || + (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)) { cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, d->cfg, d, _("`Failed while waiting for topology setup!\n")); + cb (d->cb_cls, NULL, d->cfg, d, + _("`Failed while waiting for topology setup!\n")); return; } - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); break; case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! */ /* start GNUnet on remote host */ @@ -551,18 +542,19 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting `%s', with command `%s %s %s %s %s %s'.\n", - "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, - "-L", "DEBUG", "-s"); + "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG", + "-s"); #endif - d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", - "gnunet-arm", "-c", d->cfgfile, + d->proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", + d->cfgfile, #if DEBUG_TESTING - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-s", "-q", "-T", - GNUNET_TIME_relative_to_string - (GNUNET_TIME_absolute_get_remaining - (d->max_timeout)), NULL); + "-s", "-q", "-T", + GNUNET_TIME_relative_to_string + (GNUNET_TIME_absolute_get_remaining + (d->max_timeout)), NULL); } else { @@ -574,8 +566,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n", - "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", - d->cfgfile, "-L", "DEBUG", "-s", "-q"); + "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile, + "-L", "DEBUG", "-s", "-q"); #endif if (d->ssh_port_str == NULL) { @@ -587,8 +579,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_TESTING "-L", "DEBUG", #endif - "-c", d->cfgfile, "-s", "-q", - "-T", + "-c", d->cfgfile, "-s", "-q", "-T", GNUNET_TIME_relative_to_string (GNUNET_TIME_absolute_get_remaining (d->max_timeout)), NULL); @@ -596,20 +587,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { - d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", - "ssh", "-p", d->ssh_port_str, + d->proc = + GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-p", + d->ssh_port_str, #if !DEBUG_TESTING - "-q", + "-q", #endif - dst, "gnunet-arm", + dst, "gnunet-arm", #if DEBUG_TESTING - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", d->cfgfile, "-s", "-q", - "-T", - GNUNET_TIME_relative_to_string - (GNUNET_TIME_absolute_get_remaining - (d->max_timeout)), NULL); + "-c", d->cfgfile, "-s", "-q", "-T", + GNUNET_TIME_relative_to_string + (GNUNET_TIME_absolute_get_remaining + (d->max_timeout)), NULL); } GNUNET_free (dst); } @@ -621,24 +612,22 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, - d, - (NULL == d->hostname) - ? _("Failed to start `gnunet-arm' process.\n") - : _("Failed to start `ssh' process.\n")); + cb (d->cb_cls, NULL, d->cfg, d, + (NULL == + d-> + hostname) ? _("Failed to start `gnunet-arm' process.\n") : + _("Failed to start `ssh' process.\n")); return; } #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Started `%s', waiting for `%s' to be up.\n", - "gnunet-arm", "gnunet-service-core"); + "Started `%s', waiting for `%s' to be up.\n", "gnunet-arm", + "gnunet-service-core"); #endif d->phase = SP_START_ARMING; - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); break; case SP_START_ARMING: if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) @@ -648,13 +637,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, - d, - (NULL == d->hostname) - ? _("`gnunet-arm' does not seem to terminate.\n") - : _("`ssh' does not seem to terminate.\n")); + cb (d->cb_cls, NULL, d->cfg, d, + (NULL == + d-> + hostname) ? _("`gnunet-arm' does not seem to terminate.\n") : + _("`ssh' does not seem to terminate.\n")); GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_free (d->cfgfile); GNUNET_free_non_null (d->hostname); @@ -664,14 +651,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } /* wait some more */ - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); return; } #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Successfully started `%s'.\n", "gnunet-arm"); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Successfully started `%s'.\n", + "gnunet-arm"); #endif GNUNET_free (d->proc); d->phase = SP_START_CORE; @@ -689,9 +676,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, d, _("Unable to connect to CORE service for peer!\n")); + cb (d->cb_cls, NULL, d->cfg, d, + _("Unable to connect to CORE service for peer!\n")); GNUNET_CONFIGURATION_destroy (d->cfg); GNUNET_free (d->cfgfile); GNUNET_free_non_null (d->hostname); @@ -699,14 +685,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (d); return; } - d->server = GNUNET_CORE_connect (d->cfg, 1, - d, - &testing_init, - NULL, NULL, NULL, - NULL, GNUNET_NO, - NULL, GNUNET_NO, no_handlers); - d->task - = + d->server = + GNUNET_CORE_connect (d->cfg, 1, d, &testing_init, NULL, NULL, NULL, + NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); + d->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_SERVICE_RETRY, 2), &start_fsm, d); @@ -716,9 +698,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (GNUNET_YES == d->dead) GNUNET_TESTING_daemon_stop (d, - GNUNET_TIME_absolute_get_remaining - (d->max_timeout), d->dead_cb, - d->dead_cb_cls, GNUNET_YES, GNUNET_NO); + GNUNET_TIME_absolute_get_remaining (d-> + max_timeout), + d->dead_cb, d->dead_cb_cls, GNUNET_YES, + GNUNET_NO); else if (NULL != d->cb) d->cb (d->cb_cls, &d->id, d->cfg, d, _("Failed to connect to transport service!\n")); @@ -761,8 +744,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (d->hello != NULL) return; GNUNET_assert (d->task == GNUNET_SCHEDULER_NO_TASK); - d->task - = + d->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_SERVICE_RETRY, 2), &start_fsm, d); @@ -779,19 +761,17 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, - d, - (NULL == d->hostname) - ? _("`gnunet-arm' does not seem to terminate.\n") - : _("`ssh' does not seem to terminate.\n")); + cb (d->cb_cls, NULL, d->cfg, d, + (NULL == + d-> + hostname) ? _("`gnunet-arm' does not seem to terminate.\n") : + _("`ssh' does not seem to terminate.\n")); return; } /* wait some more */ - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); return; } #if EXTRA_CHECKS @@ -800,12 +780,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, - d->cfg, - d, - (NULL == d->hostname) - ? + cb (d->cb_cls, NULL, d->cfg, d, + (NULL == + d-> + hostname) ? _ ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n") : _("`ssh' does not seem to terminate.\n")); @@ -834,9 +812,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } /* wait some more */ - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); return; } #if EXTRA_CHECKS @@ -883,9 +861,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } /* wait some more */ - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); return; } if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) @@ -963,14 +941,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb = d->cb; d->cb = NULL; if (NULL != cb) - cb (d->cb_cls, - NULL, d->cfg, d, _("`scp' does not seem to terminate.\n")); + cb (d->cb_cls, NULL, d->cfg, d, + _("`scp' does not seem to terminate.\n")); return; } /* wait some more */ - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + d); return; } if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) @@ -1231,8 +1209,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, daemon->phase = SP_TOPOLOGY_SETUP; daemon->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); - GNUNET_SCHEDULER_add_continuation (&start_fsm, - daemon, + GNUNET_SCHEDULER_add_continuation (&start_fsm, daemon, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -1261,12 +1238,9 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, */ struct GNUNET_TESTING_Daemon * GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_TIME_Relative timeout, - int pretend, - const char *hostname, - const char *ssh_username, - uint16_t sshport, - const char *hostkey, + struct GNUNET_TIME_Relative timeout, int pretend, + const char *hostname, const char *ssh_username, + uint16_t sshport, const char *hostkey, GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, void *hostkey_cls, GNUNET_TESTING_NotifyDaemonRunning cb, @@ -1295,8 +1269,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, /* Find service home and base service home directories, create it if it doesn't exist */ GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, - "PATHS", + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &servicehome)); @@ -1321,9 +1294,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, ret->cb_cls = cb_cls; ret->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); ret->cfg = GNUNET_CONFIGURATION_dup (cfg); - GNUNET_CONFIGURATION_set_value_string (ret->cfg, - "PATHS", - "DEFAULTCONFIG", ret->cfgfile); + GNUNET_CONFIGURATION_set_value_string (ret->cfg, "PATHS", "DEFAULTCONFIG", + ret->cfgfile); if (hostkey != NULL) /* Get the peer identity from the hostkey */ { @@ -1344,8 +1316,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, { GNUNET_asprintf (&hostkeyfile, "%s/.hostkey", servicehome); fn = GNUNET_DISK_file_open (hostkeyfile, - GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); GNUNET_assert (fn != NULL); @@ -1358,8 +1330,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile)) { if (0 != UNLINK (ret->cfgfile)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", ret->cfgfile); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + ret->cfgfile); GNUNET_CONFIGURATION_destroy (ret->cfg); GNUNET_free_non_null (ret->hostname); GNUNET_free (ret->cfgfile); @@ -1368,11 +1340,10 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } if (ssh_username != NULL) username = GNUNET_strdup (ssh_username); - if ((ssh_username == NULL) && (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "TESTING", - "USERNAME", - &username))) + if ((ssh_username == NULL) && + (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "USERNAME", + &username))) { if (NULL != getenv ("USER")) username = GNUNET_strdup (getenv ("USER")); @@ -1420,13 +1391,13 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } else { - ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", - "scp", "-r", "-P", - ret->ssh_port_str, + ret->proc = + GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", "-P", + ret->ssh_port_str, #if !DEBUG_TESTING - "-q", + "-q", #endif - servicehome, arg, NULL); + servicehome, arg, NULL); } GNUNET_free (arg); if (NULL == ret->proc) @@ -1436,25 +1407,25 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, ("Could not start `%s' process to copy configuration directory.\n"), "scp"); if (0 != UNLINK (ret->cfgfile)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", ret->cfgfile); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + ret->cfgfile); GNUNET_CONFIGURATION_destroy (ret->cfg); GNUNET_free_non_null (ret->hostname); GNUNET_free_non_null (ret->username); GNUNET_free (ret->cfgfile); GNUNET_free (ret); if ((hostkey != NULL) && (0 != UNLINK (hostkeyfile))) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", hostkeyfile); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + hostkeyfile); GNUNET_free_non_null (hostkeyfile); GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome)); GNUNET_free (servicehome); return NULL; } - ret->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, ret); + ret->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, + ret); GNUNET_free_non_null (hostkeyfile); GNUNET_free (servicehome); return ret; @@ -1464,8 +1435,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, "No need to copy configuration file since we are running locally.\n"); #endif ret->phase = SP_COPIED; - GNUNET_SCHEDULER_add_continuation (&start_fsm, - ret, + GNUNET_SCHEDULER_add_continuation (&start_fsm, ret, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } GNUNET_free_non_null (hostkeyfile); @@ -1520,8 +1490,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, GNUNET_free_non_null (d->hello); #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"), + GNUNET_i2s (&d->id)); #endif d->phase = SP_START_ARMING; @@ -1567,9 +1537,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, } GNUNET_free_non_null (del_arg); - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); } @@ -1608,8 +1577,8 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, } #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"), + GNUNET_i2s (&d->id)); #endif if (d->churned_services != NULL) { @@ -1698,8 +1667,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, if (NULL != d->cb) { #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Setting d->dead on peer `%4s'\n"), GNUNET_i2s (&d->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n"), + GNUNET_i2s (&d->id)); #endif d->dead = GNUNET_YES; return; @@ -1746,8 +1715,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, */ /* shutdown ARM process (will terminate others) */ #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"), + GNUNET_i2s (&d->id)); #endif d->phase = SP_SHUTDOWN_START; d->running = GNUNET_NO; @@ -1781,8 +1750,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, #if DEBUG_TESTING "-L", "DEBUG", #endif - "-c", d->cfgfile, "-e", "-q", - "-T", + "-c", d->cfgfile, "-e", "-q", "-T", GNUNET_TIME_relative_to_string (timeout), del_arg, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1801,8 +1769,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, #if DEBUG_TESTING "-L", "DEBUG", #endif - "-c", d->cfgfile, "-e", "-q", - "-T", + "-c", d->cfgfile, "-e", "-q", "-T", GNUNET_TIME_relative_to_string (timeout), del_arg, NULL); } @@ -1873,8 +1840,7 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, if (NULL == d->proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("Could not start `%s' process to copy configuration file.\n"), + _("Could not start `%s' process to copy configuration file.\n"), "scp"); if (NULL != cb) cb (cb_cls, _("Failed to copy new configuration to remote machine.")); @@ -1883,9 +1849,8 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, } d->update_cb = cb; d->update_cb_cls = cb_cls; - d->task - = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, - &start_fsm, d); + d->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); } @@ -1981,9 +1946,9 @@ struct ConnectContext /** Forward declaration **/ -static void -reattempt_daemons_connect (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc); +static void reattempt_daemons_connect (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** @@ -2039,10 +2004,7 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (ctx->cb != NULL) { - ctx->cb (ctx->cb_cls, - &ctx->d1->id, - &ctx->d2->id, - ctx->distance, + ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->distance, ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, NULL); } } @@ -2081,15 +2043,13 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * */ static void -connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct ConnectContext *ctx = cls; #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Connected peer %s to peer %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n", ctx->d1->shortname, GNUNET_i2s (peer)); #endif @@ -2118,8 +2078,7 @@ connect_notify (void *cls, * */ static void -connect_notify_core2 (void *cls, - const struct GNUNET_PeerIdentity *peer, +connect_notify_core2 (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct ConnectContext *ctx = cls; @@ -2158,9 +2117,9 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) return; - if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL) - && (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)) - && (ctx->d1->phase == SP_START_DONE) && (ctx->d2->phase == SP_START_DONE)) + if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL) && + (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)) && + (ctx->d1->phase == SP_START_DONE) && (ctx->d2->phase == SP_START_DONE)) { hello = GNUNET_HELLO_get_header (ctx->d2->hello); GNUNET_assert (hello != NULL); @@ -2171,8 +2130,7 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL); GNUNET_assert (ctx->d1core != NULL); ctx->connect_request_handle = - GNUNET_CORE_peer_request_connect (ctx->d1core, - &ctx->d2->id, + GNUNET_CORE_peer_request_connect (ctx->d1core, &ctx->d2->id, &core_connect_request_cont, ctx); #if DEBUG_TESTING @@ -2186,8 +2144,8 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)); } - ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed (ctx->timeout_hello, - &send_hello, ctx); + ctx->hello_send_task = + GNUNET_SCHEDULER_add_delayed (ctx->timeout_hello, &send_hello, ctx); } /** @@ -2199,11 +2157,10 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param publicKey the public key of the peer */ void -core_init_notify (void *cls, - struct GNUNET_CORE_Handle *server, +core_init_notify (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, - const struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) + const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded + *publicKey) { struct ConnectContext *connect_ctx = cls; @@ -2246,12 +2203,10 @@ reattempt_daemons_connect (void *cls, ctx->connect_attempts--; GNUNET_assert (ctx->d1core == NULL); ctx->d1core_ready = GNUNET_NO; - ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, - ctx, - &core_init_notify, - &connect_notify, NULL, NULL, - NULL, GNUNET_NO, - NULL, GNUNET_NO, no_handlers); + ctx->d1core = + GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify, + &connect_notify, NULL, NULL, NULL, GNUNET_NO, NULL, + GNUNET_NO, no_handlers); if (ctx->d1core == NULL) { if (NULL != ctx->cb) @@ -2299,9 +2254,9 @@ reattempt_daemons_connect (void *cls, if (ctx->send_hello == GNUNET_YES) { - ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, - &ctx->d1->id, - ctx->d1, NULL, NULL, NULL); + ctx->d1th = + GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL, + NULL, NULL); if (ctx->d1th == NULL) { GNUNET_CORE_disconnect (ctx->d1core); @@ -2317,8 +2272,7 @@ reattempt_daemons_connect (void *cls, else { ctx->connect_request_handle = - GNUNET_CORE_peer_request_connect (ctx->d1core, - &ctx->d2->id, + GNUNET_CORE_peer_request_connect (ctx->d1core, &ctx->d2->id, &core_connect_request_cont, ctx); } ctx->timeout_task = @@ -2338,8 +2292,7 @@ reattempt_daemons_connect (void *cls, * */ static void -core_initial_iteration (void *cls, - const struct GNUNET_PeerIdentity *peer, +core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct ConnectContext *ctx = cls; @@ -2355,8 +2308,8 @@ core_initial_iteration (void *cls, { if (ctx->connected == GNUNET_YES) { - ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, - ctx); + ctx->timeout_task = + GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); return; } @@ -2367,12 +2320,10 @@ core_initial_iteration (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers are NOT connected, connecting to core!\n"); #endif - ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, - ctx, - &core_init_notify, - &connect_notify, NULL, NULL, - NULL, GNUNET_NO, - NULL, GNUNET_NO, no_handlers); + ctx->d1core = + GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify, + &connect_notify, NULL, NULL, NULL, GNUNET_NO, + NULL, GNUNET_NO, no_handlers); } if (ctx->d1core == NULL) @@ -2405,9 +2356,9 @@ core_initial_iteration (void *cls, if (ctx->send_hello == GNUNET_YES) { - ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, - &ctx->d1->id, ctx->d1, NULL, NULL, - NULL); + ctx->d1th = + GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL, + NULL, NULL); if (ctx->d1th == NULL) { GNUNET_CORE_disconnect (ctx->d1core); @@ -2475,8 +2426,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, ctx->connected = GNUNET_NO; ctx->send_hello = send_hello; #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asked to connect peer %s to peer %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s\n", d1->shortname, d2->shortname); #endif diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 723afd456..d03cb307b 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -87,12 +87,13 @@ enum PeerLists * Prototype of a function called whenever two peers would be connected * in a certain topology. */ -typedef unsigned int - (*GNUNET_TESTING_ConnectionProcessor) (struct GNUNET_TESTING_PeerGroup * pg, - unsigned int first, - unsigned int second, - enum PeerLists list, - unsigned int check); +typedef unsigned int (*GNUNET_TESTING_ConnectionProcessor) (struct + GNUNET_TESTING_PeerGroup + * pg, + unsigned int first, + unsigned int second, + enum PeerLists list, + unsigned int check); /** * Context for handling churning a peer group @@ -1091,8 +1092,8 @@ update_meter (struct ProgressMeter *meter) fprintf (stdout, "%sProgress: [0%%", meter->startup_string); } else - fprintf (stdout, "%d%%", (int) (((float) meter->completed - / meter->total) * 100)); + fprintf (stdout, "%d%%", + (int) (((float) meter->completed / meter->total) * 100)); } else if (meter->completed % meter->dotnum == 0) fprintf (stdout, "."); @@ -1332,24 +1333,24 @@ update_config (void *cls, const char *section, const char *option, if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) { - if ((ival != 0) && (GNUNET_YES - != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, - "testing", - single_variable))) + if ((ival != 0) && + (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing", + single_variable))) { GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++); value = cval; } - else if ((ival != 0) && (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, - "testing", - single_variable)) - && GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", - per_host_variable, - &num_per_host)) + else if ((ival != 0) && + (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing", + single_variable)) && + GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", + per_host_variable, + &num_per_host)) { - GNUNET_snprintf (cval, sizeof (cval), "%u", ival + ctx->fdnum - % num_per_host); + GNUNET_snprintf (cval, sizeof (cval), "%u", + ival + ctx->fdnum % num_per_host); value = cval; } @@ -1361,23 +1362,23 @@ update_config (void *cls, const char *section, const char *option, if (0 == strcmp (option, "UNIXPATH")) { - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, - "testing", - single_variable)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing", + single_variable)) { - GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", - section, ctx->upnum++); + GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section, + ctx->upnum++); value = uval; } - else if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", - per_host_variable, - &num_per_host)) - && (num_per_host > 0)) + else if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", + per_host_variable, + &num_per_host)) && + (num_per_host > 0)) { - GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", - section, ctx->fdnum % num_per_host); + GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section, + ctx->fdnum % num_per_host); value = uval; } } @@ -1437,10 +1438,10 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, return NULL; } - if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "skew_variance", - &skew_variance)) - && (skew_variance > 0)) + if ((GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "skew_variance", + &skew_variance)) && + (skew_variance > 0)) { skew_offset = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, @@ -1454,8 +1455,8 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, skew_offset); } - if (GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "control_host", - &control_host) == GNUNET_OK) + if (GNUNET_CONFIGURATION_get_value_string + (cfg, "testing", "control_host", &control_host) == GNUNET_OK) { if (hostname != NULL) GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1; %s;", control_host, @@ -1469,12 +1470,12 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "ACCEPT_FROM", allowed_hosts); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", - "ACCEPT_FROM", allowed_hosts); + GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "ACCEPT_FROM", + allowed_hosts); GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM", allowed_hosts); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", - "ACCEPT_FROM", allowed_hosts); + GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FROM", + allowed_hosts); GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", ""); @@ -1629,23 +1630,19 @@ remove_connections (struct GNUNET_TESTING_PeerGroup *pg, unsigned int first, } #else if (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_contains (pg-> - peers[first].blacklisted_peers, - &hash_second)) + GNUNET_CONTAINER_multihashmap_contains (pg->peers[first]. + blacklisted_peers, &hash_second)) { - GNUNET_CONTAINER_multihashmap_remove_all (pg-> - peers[first].blacklisted_peers, - &hash_second); + GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[first]. + blacklisted_peers, &hash_second); } if (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_contains (pg-> - peers[second].blacklisted_peers, - &hash_first)) + GNUNET_CONTAINER_multihashmap_contains (pg->peers[second]. + blacklisted_peers, &hash_first)) { - GNUNET_CONTAINER_multihashmap_remove_all (pg-> - peers[second].blacklisted_peers, - &hash_first); + GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[second]. + blacklisted_peers, &hash_first); } #endif @@ -1801,22 +1798,22 @@ create_scale_free (struct GNUNET_TESTING_PeerGroup *pg, previous_total_connections = total_connections; for (i = 0; i < outer_count; i++) { - probability = pg->peers[i].num_connections - / (double) previous_total_connections; - random - = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX)) - / ((double) UINT64_MAX); + probability = + pg->peers[i].num_connections / (double) previous_total_connections; + random = + ((double) + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT64_MAX)) / ((double) UINT64_MAX); #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Considering connecting peer %d to peer %d\n", - outer_count, i); + "Considering connecting peer %d to peer %d\n", outer_count, + i); #endif if (random < probability) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", outer_count, i); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", + outer_count, i); #endif total_connections += proc (pg, outer_count, i, list, GNUNET_YES); } @@ -1872,9 +1869,9 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, int connect_attempts; logNModifier = 0.5; /* FIXME: default value? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PERCENTAGE", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", + &p_string)) { if (sscanf (p_string, "%lf", &logNModifier) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -1884,9 +1881,9 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_free (p_string); } probability = 0.5; /* FIXME: default percentage? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PROBABILITY", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", + &p_string)) { if (sscanf (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -1926,22 +1923,20 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, for (j = 0; j < connsPerPeer / 2; j++) { - random - = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX) - / ((double) UINT64_MAX)); + random = + ((double) + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT64_MAX) / ((double) UINT64_MAX)); if (random < probability) { /* Connect to uniformly selected random peer */ - randomPeer - = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); - while ((((randomPeer < max) && (randomPeer > min)) && (useAnd - == 0)) || + randomPeer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); + while ((((randomPeer < max) && (randomPeer > min)) && (useAnd == 0)) || (((randomPeer > min) || (randomPeer < max)) && (useAnd == 1))) { - randomPeer - = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - pg->total); + randomPeer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); } smallWorldConnections += proc (pg, i, randomPeer, list, GNUNET_YES); } @@ -1987,9 +1982,9 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, char *p_string; nat_percentage = 0.6; /* FIXME: default percentage? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PERCENTAGE", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", + &p_string)) { if (sscanf (p_string, "%lf", &nat_percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2008,12 +2003,11 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, if ((outer_count > cutoff) || (inner_count > cutoff)) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", outer_count, inner_count); #endif - connect_attempts += proc (pg, outer_count, inner_count, list, - GNUNET_YES); + connect_attempts += + proc (pg, outer_count, inner_count, list, GNUNET_YES); } } } @@ -2047,9 +2041,9 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg, struct ProgressMeter *conn_meter; nat_percentage = 0.6; /* FIXME: default percentage? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PERCENTAGE", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", + &p_string)) { if (sscanf (p_string, "%lf", &nat_percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2080,12 +2074,11 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg, if ((outer_count > cutoff) || (inner_count > cutoff)) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", outer_count, inner_count); #endif - connect_attempts += proc (pg, outer_count, inner_count, list, - GNUNET_YES); + connect_attempts += + proc (pg, outer_count, inner_count, list, GNUNET_YES); add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO); update_meter (conn_meter); } @@ -2137,9 +2130,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, cols = square; percentage = 0.5; /* FIXME: default percentage? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PERCENTAGE", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", + &p_string)) { if (sscanf (p_string, "%lf", &percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2157,9 +2150,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, percentage = 0.5; } probability = 0.5; /* FIXME: default percentage? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PROBABILITY", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", + &p_string)) { if (sscanf (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2182,8 +2175,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, } #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Connecting nodes in 2d torus topology: %u rows %u columns\n"), + _("Connecting nodes in 2d torus topology: %u rows %u columns\n"), rows, cols); #endif @@ -2220,8 +2212,8 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, natLog = log (pg->total); #if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("natural log of %d is %d, will run %d iterations\n"), - pg->total, natLog, (int) (natLog * percentage)); + _("natural log of %d is %d, will run %d iterations\n"), pg->total, + natLog, (int) (natLog * percentage)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Total connections added thus far: %u!\n"), connect_attempts); #endif @@ -2249,10 +2241,10 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, /* Calculate probability as 1 over the square of the distance */ probability = 1.0 / (distance * distance); /* Choose a random value between 0 and 1 */ - random - = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX)) - / ((double) UINT64_MAX); + random = + ((double) + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT64_MAX)) / ((double) UINT64_MAX); /* If random < probability, then connect the two nodes */ if (random < probability) smallWorldConnections += proc (pg, j, k, list, GNUNET_YES); @@ -2295,9 +2287,9 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, char *p_string; probability = 0.5; /* FIXME: default percentage? */ - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", - "PROBABILITY", - &p_string)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", + &p_string)) { if (sscanf (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2311,18 +2303,18 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, { for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) { - temp_rand - = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX)) - / ((double) UINT64_MAX); + temp_rand = + ((double) + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT64_MAX)) / ((double) UINT64_MAX); #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("rand is %f probability is %f\n"), temp_rand, probability); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("rand is %f probability is %f\n"), + temp_rand, probability); #endif if (temp_rand < probability) { - connect_attempts += proc (pg, outer_count, inner_count, list, - GNUNET_YES); + connect_attempts += + proc (pg, outer_count, inner_count, list, GNUNET_YES); } } } @@ -2376,8 +2368,7 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, } #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Connecting nodes in 2d torus topology: %u rows %u columns\n"), + _("Connecting nodes in 2d torus topology: %u rows %u columns\n"), rows, cols); #endif /* Rows and columns are all sorted out, now iterate over all nodes and connect each @@ -2395,8 +2386,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, else nodeToConnect = i - cols + 1; #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", i, nodeToConnect); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i, + nodeToConnect); #endif connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); @@ -2413,8 +2404,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, if (nodeToConnect < pg->total) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", i, nodeToConnect); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i, + nodeToConnect); #endif connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); } @@ -2450,15 +2441,16 @@ create_clique (struct GNUNET_TESTING_PeerGroup *pg, connect_attempts = 0; - conn_meter = create_meter ((((pg->total * pg->total) + pg->total) / 2) - - pg->total, "Create Clique ", GNUNET_NO); + conn_meter = + create_meter ((((pg->total * pg->total) + pg->total) / 2) - pg->total, + "Create Clique ", GNUNET_NO); for (outer_count = 0; outer_count < pg->total - 1; outer_count++) { for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", outer_count, inner_count); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", + outer_count, inner_count); #endif connect_attempts += proc (pg, outer_count, inner_count, list, check); update_meter (conn_meter); @@ -2568,8 +2560,8 @@ create_line (struct GNUNET_TESTING_PeerGroup *pg, for (count = 0; count < pg->total - 1; count++) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", count, count + 1); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", + count, count + 1); #endif connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); } @@ -2691,12 +2683,11 @@ create_from_file (struct GNUNET_TESTING_PeerGroup *pg, char *filename, return connect_attempts; } /* Assume file is written with first peer 1, but array index is 0 */ - connect_attempts += proc (pg, first_peer_index - 1, second_peer_index - - 1, list, GNUNET_YES); - while ((buf[count] != '\n') && (buf[count] != ',') && (count - < - frstat.st_size - - 1)) + connect_attempts += + proc (pg, first_peer_index - 1, second_peer_index - 1, list, + GNUNET_YES); + while ((buf[count] != '\n') && (buf[count] != ',') && + (count < frstat.st_size - 1)) count++; if (buf[count] == '\n') { @@ -2746,8 +2737,8 @@ create_ring (struct GNUNET_TESTING_PeerGroup *pg, for (count = 0; count < pg->total - 1; count++) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer %d to peer %d\n", count, count + 1); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", + count, count + 1); #endif connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); } @@ -2873,8 +2864,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) conn_iter = pg->peers[pg_iter].allowed_peers_head; while (conn_iter != NULL) { - GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon-> - id.hashPubKey, &peer_enc); + GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id. + hashPubKey, &peer_enc); fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc); conn_iter = conn_iter->next; } @@ -2885,8 +2876,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) #endif fclose (temp_friend_handle); - if (GNUNET_OK - != + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg, "PATHS", "SERVICEHOME", &temp_service_path)) @@ -2904,8 +2894,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ { GNUNET_asprintf (&arg, "%s/friends", temp_service_path); - procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv", - mytemp, arg, NULL); + procarr[pg_iter] = + GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL); GNUNET_assert (procarr[pg_iter] != NULL); #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2926,8 +2916,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) GNUNET_asprintf (&arg, "%s:%s/friends", pg->peers[pg_iter].daemon->hostname, temp_service_path); - procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", - mytemp, arg, NULL); + procarr[pg_iter] = + GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL); GNUNET_assert (procarr[pg_iter] != NULL); ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */ GNUNET_OS_process_close (procarr[pg_iter]); @@ -2960,13 +2950,13 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Checking copy status of file %d\n", pg_iter); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d\n", + pg_iter); #endif if (procarr[pg_iter] != NULL) /* Check for already completed! */ { - if (GNUNET_OS_process_status - (procarr[pg_iter], &type, &return_code) != GNUNET_OK) + if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) != + GNUNET_OK) { ret = GNUNET_SYSERR; } @@ -3061,15 +3051,15 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, conn_iter = pg->peers[pg_iter].blacklisted_peers_head; while (conn_iter != NULL) { - GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon-> - id.hashPubKey, &peer_enc); + GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id. + hashPubKey, &peer_enc); fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc); conn_iter = conn_iter->next; } #else blacklist_ctx.transport = pos; - (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers - [pg_iter].blacklisted_peers, + (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter]. + blacklisted_peers, &blacklist_file_iterator, &blacklist_ctx); #endif @@ -3084,8 +3074,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_free (temp_transports); fclose (temp_file_handle); - if (GNUNET_OK - != + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg, "PATHS", "SERVICEHOME", &temp_service_path)) @@ -3103,8 +3092,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ { GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path); - procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv", - mytemp, arg, NULL); + procarr[pg_iter] = + GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL); #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Copying file with command cp %s %s\n"), mytemp, arg); @@ -3123,8 +3112,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_asprintf (&arg, "%s:%s/blacklist", pg->peers[pg_iter].daemon->hostname, temp_service_path); - procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", - mytemp, arg, NULL); + procarr[pg_iter] = + GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL); GNUNET_assert (procarr[pg_iter] != NULL); GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */ @@ -3151,8 +3140,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, #endif if (procarr[pg_iter] != NULL) /* Check for already completed! */ { - if (GNUNET_OS_process_status (procarr[pg_iter], &type, - &return_code) != GNUNET_OK) + if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) != + GNUNET_OK) { ret = GNUNET_SYSERR; } @@ -3187,8 +3176,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, } /* Forward Declaration */ -static void -schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void schedule_connect (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** * Choose a random peer's next connection to create, and @@ -3206,11 +3195,11 @@ preschedule_connect (struct GNUNET_TESTING_PeerGroup *pg) if (ct_ctx->remaining_connections == 0) return; - random_peer - = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); + random_peer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); while (pg->peers[random_peer].connect_peers_head == NULL) - random_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - pg->total); + random_peer = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); connection_iter = pg->peers[random_peer].connect_peers_head; connect_context = GNUNET_malloc (sizeof (struct ConnectContext)); @@ -3330,19 +3319,19 @@ send_core_connect_requests (void *cls, conn = send_hello_context->peer->connect_peers_head; while (conn != NULL) { - GNUNET_CORE_peer_request_connect (send_hello_context->peer-> - daemon->server, - &send_hello_context->pg-> - peers[conn->index].daemon->id, NULL, - NULL); + GNUNET_CORE_peer_request_connect (send_hello_context->peer->daemon-> + server, + &send_hello_context->pg->peers[conn-> + index]. + daemon->id, NULL, NULL); conn = conn->next; } send_hello_context->core_connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide - (send_hello_context->pg-> - ct_ctx.connect_timeout, - send_hello_context->pg-> - ct_ctx.connect_attempts), + (send_hello_context->pg->ct_ctx. + connect_timeout, + send_hello_context->pg->ct_ctx. + connect_attempts), &send_core_connect_requests, send_hello_context); } @@ -3368,8 +3357,7 @@ send_core_connect_requests (void *cls, * doesn't take too long! */ static void -core_connect_notify (void *cls, - const struct GNUNET_PeerIdentity *peer, +core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct SendHelloContext *send_hello_context = cls; @@ -3380,8 +3368,7 @@ core_connect_notify (void *cls, struct PeerData *other_peer; #endif #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Connected peer %s to peer %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n", ctx->d1->shortname, GNUNET_i2s (peer)); #endif @@ -3474,8 +3461,7 @@ core_connect_notify (void *cls, * @param publicKey the public key of the peer */ void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -3536,10 +3522,10 @@ hello_sent_callback (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) send_hello_context->core_connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide - (send_hello_context->pg-> - ct_ctx.connect_timeout, - send_hello_context->pg-> - ct_ctx.connect_attempts), + (send_hello_context->pg->ct_ctx. + connect_timeout, + send_hello_context->pg->ct_ctx. + connect_attempts), &send_core_connect_requests, send_hello_context); } @@ -3590,22 +3576,22 @@ schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (send_hello_context->peer->daemon->th == NULL) { pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */ - send_hello_context->peer->daemon->th - = GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, - send_hello_context, NULL, NULL, NULL); + send_hello_context->peer->daemon->th = + GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, + send_hello_context, NULL, NULL, NULL); } #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Offering Hello of peer %s to peer %s\n"), send_hello_context->peer->daemon->shortname, - pg->peers[send_hello_context->peer_pos->index]. - daemon->shortname); + pg->peers[send_hello_context->peer_pos->index].daemon-> + shortname); #endif GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th, - (const struct GNUNET_MessageHeader *) - pg->peers[send_hello_context->peer_pos-> - index].daemon->hello, - &hello_sent_callback, send_hello_context); + (const struct GNUNET_MessageHeader *) pg-> + peers[send_hello_context->peer_pos->index]. + daemon->hello, &hello_sent_callback, + send_hello_context); send_hello_context->peer_pos = send_hello_context->peer_pos->next; GNUNET_assert (send_hello_context->peer->daemon->th != NULL); } @@ -3644,12 +3630,10 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first, other_peer = NULL; #endif - while ((connection != NULL) && (0 - != memcmp (first, - &pg->peers[connection-> - index].daemon->id, - sizeof (struct - GNUNET_PeerIdentity)))) + while ((connection != NULL) && + (0 != + memcmp (first, &pg->peers[connection->index].daemon->id, + sizeof (struct GNUNET_PeerIdentity)))) { connection = connection->next; } @@ -3659,16 +3643,14 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first, GNUNET_assert (0 < ct_ctx->remaining_connections); ct_ctx->remaining_connections--; if (pg->notify_connection != NULL) /* Notify of reverse connection */ - pg->notify_connection (pg->notify_connection_cls, second, first, - distance, second_cfg, first_cfg, second_daemon, - first_daemon, emsg); - - GNUNET_CONTAINER_DLL_remove (pg-> - peers[connect_ctx-> - second_index].connect_peers_head, - pg->peers[connect_ctx-> - second_index].connect_peers_tail, - connection); + pg->notify_connection (pg->notify_connection_cls, second, first, distance, + second_cfg, first_cfg, second_daemon, first_daemon, + emsg); + + GNUNET_CONTAINER_DLL_remove (pg->peers[connect_ctx->second_index]. + connect_peers_head, + pg->peers[connect_ctx->second_index]. + connect_peers_tail, connection); GNUNET_free (connection); } @@ -3707,8 +3689,8 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) return; - if ((pg->outstanding_connects > pg->max_outstanding_connections) - || (pg->stop_connects == GNUNET_YES)) + if ((pg->outstanding_connects > pg->max_outstanding_connections) || + (pg->stop_connects == GNUNET_YES)) { #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -3729,10 +3711,10 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif pg->outstanding_connects++; pg->total_connects_scheduled++; - GNUNET_TESTING_daemons_connect (pg-> - peers[connect_context->first_index].daemon, - pg->peers[connect_context-> - second_index].daemon, + GNUNET_TESTING_daemons_connect (pg->peers[connect_context->first_index]. + daemon, + pg->peers[connect_context->second_index]. + daemon, connect_context->ct_ctx->connect_timeout, connect_context->ct_ctx->connect_attempts, #if USE_SEND_HELLOS @@ -4032,11 +4014,11 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n")); #endif - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing", - "topology_file", - &filename)) - num_connections = create_from_file (pg, filename, &add_connections, - ALLOWED); + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing", + "topology_file", &filename)) + num_connections = + create_from_file (pg, filename, &add_connections, ALLOWED); else { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -4057,8 +4039,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, break; } - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", - "F2F")) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F")) { ret = create_and_copy_friend_files (pg); if (ret != GNUNET_OK) @@ -4079,9 +4061,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, } /* Use the create clique method to initially set all connections as blacklisted. */ - if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) && (restrict_topology - != - GNUNET_TESTING_TOPOLOGY_FROM_FILE)) + if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) && + (restrict_topology != GNUNET_TESTING_TOPOLOGY_FROM_FILE)) create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO); else return num_connections; @@ -4095,49 +4076,48 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but clique topology\n")); #endif - unblacklisted_connections = create_clique (pg, &remove_connections, - BLACKLIST, GNUNET_NO); + unblacklisted_connections = + create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but small world (ring) topology\n")); #endif - unblacklisted_connections = create_small_world_ring (pg, - &remove_connections, - BLACKLIST); + unblacklisted_connections = + create_small_world_ring (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but small world (2d-torus) topology\n")); #endif - unblacklisted_connections = create_small_world (pg, &remove_connections, - BLACKLIST); + unblacklisted_connections = + create_small_world (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_RING: #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but ring topology\n")); #endif - unblacklisted_connections - = create_ring (pg, &remove_connections, BLACKLIST); + unblacklisted_connections = + create_ring (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_2D_TORUS: #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but 2d torus topology\n")); #endif - unblacklisted_connections = create_2d_torus (pg, &remove_connections, - BLACKLIST); + unblacklisted_connections = + create_2d_torus (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but Erdos-Renyi topology\n")); #endif - unblacklisted_connections = create_erdos_renyi (pg, &remove_connections, - BLACKLIST); + unblacklisted_connections = + create_erdos_renyi (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_INTERNAT: #if VERBOSE_TESTING @@ -4168,8 +4148,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, pg->peers[off].connect_peers_head = NULL; pg->peers[off].connect_peers_tail = NULL; } - unblacklisted_connections - = create_nated_internet_copy (pg, &remove_connections, BLACKLIST); + unblacklisted_connections = + create_nated_internet_copy (pg, &remove_connections, BLACKLIST); #else unblacklisted_connections = create_nated_internet (pg, &remove_connections, BLACKLIST); @@ -4181,16 +4161,16 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but Scale Free topology\n")); #endif - unblacklisted_connections = create_scale_free (pg, &remove_connections, - BLACKLIST); + unblacklisted_connections = + create_scale_free (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_LINE: #if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklisting all but straight line topology\n")); #endif - unblacklisted_connections - = create_line (pg, &remove_connections, BLACKLIST); + unblacklisted_connections = + create_line (pg, &remove_connections, BLACKLIST); default: break; } @@ -4244,8 +4224,8 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value) if (random_number < random_ctx->percentage) { GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (random_ctx-> - first->connect_peers_working_set, + GNUNET_CONTAINER_multihashmap_put (random_ctx->first-> + connect_peers_working_set, key, value, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); } @@ -4255,11 +4235,12 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value) hash_from_uid (random_ctx->first_uid, &first_hash); GNUNET_assert (random_ctx->pg->total > second_pos); GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg->peers - [second_pos].connect_peers, + GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg-> + peers[second_pos]. + connect_peers, &first_hash, - random_ctx-> - first->daemon)); + random_ctx->first-> + daemon)); return GNUNET_YES; } @@ -4289,25 +4270,29 @@ minimum_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value) if (min_ctx->pg_array[i] == min_ctx->current) { GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put - (min_ctx->first->connect_peers_working_set, key, - value, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + GNUNET_CONTAINER_multihashmap_put (min_ctx->first-> + connect_peers_working_set, + key, value, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); uid_from_hash (key, &second_pos); hash_from_uid (min_ctx->first_uid, &first_hash); GNUNET_assert (min_ctx->pg->total > second_pos); GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (min_ctx->pg->peers - [second_pos].connect_peers_working_set, + GNUNET_CONTAINER_multihashmap_put (min_ctx->pg-> + peers[second_pos]. + connect_peers_working_set, &first_hash, - min_ctx->first-> - daemon, + min_ctx-> + first->daemon, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */ GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove - (min_ctx->pg->peers[second_pos].connect_peers, - &first_hash, min_ctx->first->daemon)); + GNUNET_CONTAINER_multihashmap_remove (min_ctx->pg-> + peers[second_pos]. + connect_peers, + &first_hash, + min_ctx->first-> + daemon)); } } min_ctx->current++; @@ -4336,26 +4321,28 @@ dfs_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value) if (dfs_ctx->current == dfs_ctx->chosen) { GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (dfs_ctx-> - first->connect_peers_working_set, + GNUNET_CONTAINER_multihashmap_put (dfs_ctx->first-> + connect_peers_working_set, key, value, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); uid_from_hash (key, &dfs_ctx->second_uid); hash_from_uid (dfs_ctx->first_uid, &first_hash); GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg->peers - [dfs_ctx-> - second_uid].connect_peers_working_set, + GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg-> + peers + [dfs_ctx->second_uid]. + connect_peers_working_set, &first_hash, dfs_ctx->first->daemon, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (dfs_ctx-> - pg->peers - [dfs_ctx->second_uid].connect_peers, + GNUNET_CONTAINER_multihashmap_remove (dfs_ctx->pg-> + peers[dfs_ctx-> + second_uid]. + connect_peers, &first_hash, - dfs_ctx-> - first->daemon)); + dfs_ctx->first-> + daemon)); /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */ return GNUNET_NO; /* We have found our peer, don't iterate more */ } @@ -4391,10 +4378,10 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg, conn_iter = pg->peers[pg_iter].connect_peers_head; while (conn_iter != NULL) { - random_number - = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX)) - / ((double) UINT64_MAX); + random_number = + ((double) + GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT64_MAX)) / ((double) UINT64_MAX); if (random_number < percentage) { add_connections (pg, pg_iter, conn_iter->index, WORKING_SET, @@ -4407,16 +4394,16 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg, random_ctx.first = &pg->peers[pg_iter]; random_ctx.percentage = percentage; random_ctx.pg = pg; - pg->peers[pg_iter].connect_peers_working_set - = GNUNET_CONTAINER_multihashmap_create (pg->total); + pg->peers[pg_iter].connect_peers_working_set = + GNUNET_CONTAINER_multihashmap_create (pg->total); GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers, &random_connect_iterator, &random_ctx); /* Now remove the old connections */ GNUNET_CONTAINER_multihashmap_destroy (pg->peers[pg_iter].connect_peers); /* And replace with the random set */ - pg->peers[pg_iter].connect_peers - = pg->peers[pg_iter].connect_peers_working_set; + pg->peers[pg_iter].connect_peers = + pg->peers[pg_iter].connect_peers_working_set; #endif } @@ -4425,13 +4412,13 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg, conn_iter = pg->peers[pg_iter].connect_peers_head; while (pg->peers[pg_iter].connect_peers_head != NULL) remove_connections (pg, pg_iter, - pg->peers[pg_iter].connect_peers_head->index, - CONNECT, GNUNET_YES); + pg->peers[pg_iter].connect_peers_head->index, CONNECT, + GNUNET_YES); - pg->peers[pg_iter].connect_peers_head - = pg->peers[pg_iter].connect_peers_working_set_head; - pg->peers[pg_iter].connect_peers_tail - = pg->peers[pg_iter].connect_peers_working_set_tail; + pg->peers[pg_iter].connect_peers_head = + pg->peers[pg_iter].connect_peers_working_set_head; + pg->peers[pg_iter].connect_peers_tail = + pg->peers[pg_iter].connect_peers_working_set_tail; pg->peers[pg_iter].connect_peers_working_set_head = NULL; pg->peers[pg_iter].connect_peers_working_set_tail = NULL; } @@ -4482,8 +4469,8 @@ count_workingset_connections (struct GNUNET_TESTING_PeerGroup *pg) } #else count += - GNUNET_CONTAINER_multihashmap_size (pg->peers - [pg_iter].connect_peers_working_set); + GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter]. + connect_peers_working_set); #endif } @@ -4546,14 +4533,14 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) temp_list_size = count_connections (pg->peers[pg_iter].connect_peers_head); if (temp_list_size == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Peer %d has 0 connections!?!?\n", pg_iter); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peer %d has 0 connections!?!?\n", + pg_iter); break; } for (i = 0; i < num; i++) { - random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - temp_list_size); + random = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_list_size); conn_iter = pg->peers[pg_iter].connect_peers_head; for (count = 0; count < random; count++) conn_iter = conn_iter->next; @@ -4574,8 +4561,10 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) minimum_ctx.first_uid = pg_iter; minimum_ctx.pg_array = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, - GNUNET_CONTAINER_multihashmap_size - (pg->peers[pg_iter].connect_peers)); + GNUNET_CONTAINER_multihashmap_size (pg-> + peers + [pg_iter]. + connect_peers)); minimum_ctx.first = &pg->peers[pg_iter]; minimum_ctx.pg = pg; minimum_ctx.num_to_add = num; @@ -4606,10 +4595,10 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) /*remove_connections(pg, pg_iter, pg->peers[pg_iter].connect_peers_head->index, CONNECT, GNUNET_YES); */ } - pg->peers[pg_iter].connect_peers_head - = pg->peers[pg_iter].connect_peers_working_set_head; - pg->peers[pg_iter].connect_peers_tail - = pg->peers[pg_iter].connect_peers_working_set_tail; + pg->peers[pg_iter].connect_peers_head = + pg->peers[pg_iter].connect_peers_working_set_head; + pg->peers[pg_iter].connect_peers_tail = + pg->peers[pg_iter].connect_peers_working_set_tail; pg->peers[pg_iter].connect_peers_working_set_head = NULL; pg->peers[pg_iter].connect_peers_working_set_tail = NULL; } @@ -4663,16 +4652,15 @@ find_closest_peers (void *cls, const GNUNET_HashCode * key, void *value) (GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey, &closest_ctx->curr_peer->daemon->id.hashPubKey) > - closest_ctx->closest_dist)) - && (GNUNET_YES != - GNUNET_CONTAINER_multihashmap_contains (closest_ctx-> - curr_peer->connect_peers, - key))) + closest_ctx->closest_dist)) && + (GNUNET_YES != + GNUNET_CONTAINER_multihashmap_contains (closest_ctx->curr_peer-> + connect_peers, key))) { closest_ctx->closest_dist = GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey, - &closest_ctx->curr_peer->daemon-> - id.hashPubKey); + &closest_ctx->curr_peer->daemon->id. + hashPubKey); closest_ctx->closest = daemon; uid_from_hash (key, &closest_ctx->closest_num); } @@ -4750,18 +4738,17 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) #if OLD starting_peer = 0; dfs_count = 0; - while ((count_workingset_connections (pg) < num * pg->total) - && (count_allowed_connections (pg) > 0)) + while ((count_workingset_connections (pg) < num * pg->total) && + (count_allowed_connections (pg) > 0)) { if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */ { least_connections = -1; /* Set to very high number */ for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { - temp_count - = - count_connections (pg-> - peers[pg_iter].connect_peers_working_set_head); + temp_count = + count_connections (pg->peers[pg_iter]. + connect_peers_working_set_head); if (temp_count < least_connections) { starting_peer = pg_iter; @@ -4770,13 +4757,13 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) } } - temp_count - = count_connections (pg->peers[starting_peer].connect_peers_head); + temp_count = + count_connections (pg->peers[starting_peer].connect_peers_head); if (temp_count == 0) continue; /* FIXME: infinite loop? */ - random_connection = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - temp_count); + random_connection = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_count); temp_count = 0; peer_iter = pg->peers[starting_peer].connect_peers_head; while (temp_count < random_connection) @@ -4802,8 +4789,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) starting_peer = 0; dfs_count = 0; - while ((count_workingset_connections (pg) < num * pg->total) - && (count_allowed_connections (pg) > 0)) + while ((count_workingset_connections (pg) < num * pg->total) && + (count_allowed_connections (pg) > 0)) { if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */ { @@ -4815,8 +4802,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) { starting_peer = pg_iter; least_connections = - GNUNET_CONTAINER_multihashmap_size (pg->peers - [pg_iter].connect_peers_working_set); + GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter]. + connect_peers_working_set); } } } @@ -4830,25 +4817,28 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num) /* Choose a random peer from the chosen peers set of connections to add */ dfs_ctx.chosen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, - GNUNET_CONTAINER_multihashmap_size - (pg->peers[starting_peer].connect_peers)); + GNUNET_CONTAINER_multihashmap_size (pg-> + peers + [starting_peer]. + connect_peers)); dfs_ctx.first_uid = starting_peer; dfs_ctx.first = &pg->peers[starting_peer]; dfs_ctx.pg = pg; dfs_ctx.current = 0; - GNUNET_CONTAINER_multihashmap_iterate (pg->peers - [starting_peer].connect_peers, - &dfs_connect_iterator, &dfs_ctx); + GNUNET_CONTAINER_multihashmap_iterate (pg->peers[starting_peer]. + connect_peers, &dfs_connect_iterator, + &dfs_ctx); /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */ hash_from_uid (dfs_ctx.second_uid, &second_hash); GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (pg->peers - [starting_peer].connect_peers, + GNUNET_CONTAINER_multihashmap_remove (pg-> + peers[starting_peer]. + connect_peers, &second_hash, - pg-> - peers - [dfs_ctx.second_uid].daemon)); + pg->peers[dfs_ctx. + second_uid]. + daemon)); starting_peer = dfs_ctx.second_uid; } @@ -4906,8 +4896,8 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) return; - if (topology_context->connected - > topology_context->pg->max_outstanding_connections) + if (topology_context->connected > + topology_context->pg->max_outstanding_connections) { #if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -4927,9 +4917,9 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif topology_context->connected++; - if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->cfg, - &internal_topology_callback, - core_context)) + if (GNUNET_OK != + GNUNET_CORE_iterate_peers (core_context->daemon->cfg, + &internal_topology_callback, core_context)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n"); internal_topology_callback (core_context, NULL, NULL); @@ -5068,19 +5058,19 @@ schedule_get_statistics (void *cls, #endif stats_context->connected++; - core_context->stats_handle - = GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg); + core_context->stats_handle = + GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg); if (core_context->stats_handle == NULL) { internal_stats_cont (core_context, GNUNET_NO); return; } - core_context->stats_get_handle - = GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, - GNUNET_TIME_relative_get_forever (), - &internal_stats_cont, - &internal_stats_callback, core_context); + core_context->stats_get_handle = + GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, + GNUNET_TIME_relative_get_forever (), + &internal_stats_cont, &internal_stats_callback, + core_context); if (core_context->stats_get_handle == NULL) internal_stats_cont (core_context, GNUNET_NO); @@ -5121,21 +5111,20 @@ stats_check_existing (struct GNUNET_TESTING_PeerGroup *pg, unsigned long long port; char *to_match; - if (GNUNET_YES - != GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing", - "single_statistics_per_host")) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing", + "single_statistics_per_host")) return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */ pos = *stats_list; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, - "statistics", - "unixpath", - &unix_domain_socket)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, "statistics", + "unixpath", &unix_domain_socket)) return GNUNET_NO; - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, - "statistics", "port", - &port)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, "statistics", + "port", &port)) { GNUNET_free (unix_domain_socket); return GNUNET_NO; @@ -5200,11 +5189,8 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg, for (i = 0; i < pg->total; i++) { - if ((pg->peers[i].daemon->running == GNUNET_YES) && (GNUNET_NO - == - stats_check_existing - (pg, &pg->peers[i], - &stats_list))) + if ((pg->peers[i].daemon->running == GNUNET_YES) && + (GNUNET_NO == stats_check_existing (pg, &pg->peers[i], &stats_list))) { /* Allocate one core context per core we need to connect to */ core_ctx = GNUNET_malloc (sizeof (struct StatsCoreContext)); @@ -5358,8 +5344,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, copy_allowed_topology (pg); break; default: - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ - ("Unknown topology specification, can't connect peers!\n")); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("Unknown topology specification, can't connect peers!\n")); return GNUNET_SYSERR; } @@ -5367,7 +5353,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, { case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: #if VERBOSE_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _ ("Connecting random subset (%'.2f percent) of possible peers\n"), 100 * option_modifier); #endif @@ -5383,7 +5370,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, break; case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: #if VERBOSE_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _ ("Using DFS to connect a minimum of %u peers each (if possible)\n"), (unsigned int) option_modifier); #endif @@ -5393,8 +5381,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, break; case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST: #if VERBOSE_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ - ("Finding additional %u closest peers each (if possible)\n"), + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("Finding additional %u closest peers each (if possible)\n"), (unsigned int) option_modifier); #endif #if FIXME @@ -5498,8 +5486,8 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, if (internal_context->hostkey_callback != NULL) internal_context->hostkey_callback (internal_context->hostkey_cls, id, d, emsg); - else if (internal_context->peer->pg->started - == internal_context->peer->pg->total) + else if (internal_context->peer->pg->started == + internal_context->peer->pg->total) { internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */ GNUNET_TESTING_daemons_continue_startup (internal_context->peer->pg); @@ -5544,12 +5532,13 @@ internal_continue_startup (void *cls, return; } - if ((internal_context->peer->pg->starting - < internal_context->peer->pg->max_concurrent_ssh) - || ((internal_context->hostname != NULL) - && (count_outstanding_at_host (internal_context->hostname, - internal_context->peer->pg) - < internal_context->peer->pg->max_concurrent_ssh))) + if ((internal_context->peer->pg->starting < + internal_context->peer->pg->max_concurrent_ssh) || + ((internal_context->hostname != NULL) && + (count_outstanding_at_host + (internal_context->hostname, + internal_context->peer->pg) < + internal_context->peer->pg->max_concurrent_ssh))) { if (internal_context->hostname != NULL) increment_outstanding_at_host (internal_context->hostname, @@ -5599,8 +5588,9 @@ churn_start_callback (void *cls, const struct GNUNET_PeerIdentity *id, churn_ctx->num_to_start--; } - total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) - + (churn_ctx->num_to_start - churn_ctx->num_failed_start); + total_left = + (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) + + (churn_ctx->num_to_start - churn_ctx->num_failed_start); if (total_left == 0) { @@ -5630,8 +5620,8 @@ schedule_churn_restart (void *cls, { if (startup_ctx->churn_ctx->service != NULL) GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon, - startup_ctx-> - churn_ctx->service, + startup_ctx->churn_ctx-> + service, startup_ctx->timeout, &churn_start_callback, startup_ctx); @@ -5655,8 +5645,7 @@ schedule_churn_restart (void *cls, * */ void -service_start_callback (void *cls, - const struct GNUNET_PeerIdentity *id, +service_start_callback (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -5693,8 +5682,7 @@ schedule_service_start (void *cls, else { - GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, - startup_ctx->service, + GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, startup_ctx->service, startup_ctx->timeout, &service_start_callback, startup_ctx); GNUNET_free (peer_ctx); @@ -5712,29 +5700,29 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } - if ((internal_context->peer->pg->starting - < internal_context->peer->pg->max_concurrent_ssh) - || ((internal_context->hostname != NULL) - && (count_outstanding_at_host (internal_context->hostname, - internal_context->peer->pg) - < internal_context->peer->pg->max_concurrent_ssh))) + if ((internal_context->peer->pg->starting < + internal_context->peer->pg->max_concurrent_ssh) || + ((internal_context->hostname != NULL) && + (count_outstanding_at_host + (internal_context->hostname, + internal_context->peer->pg) < + internal_context->peer->pg->max_concurrent_ssh))) { if (internal_context->hostname != NULL) increment_outstanding_at_host (internal_context->hostname, internal_context->peer->pg); internal_context->peer->pg->starting++; - internal_context->peer->daemon - = GNUNET_TESTING_daemon_start (internal_context->peer->cfg, - internal_context->timeout, - GNUNET_NO, - internal_context->hostname, - internal_context->username, - internal_context->sshport, - internal_context->hostkey, - &internal_hostkey_callback, - internal_context, - &internal_startup_callback, - internal_context); + internal_context->peer->daemon = + GNUNET_TESTING_daemon_start (internal_context->peer->cfg, + internal_context->timeout, GNUNET_NO, + internal_context->hostname, + internal_context->username, + internal_context->sshport, + internal_context->hostkey, + &internal_hostkey_callback, + internal_context, + &internal_startup_callback, + internal_context); } else { @@ -5822,8 +5810,9 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_asprintf (&arg, "%s", helper->host->hostname); /* FIXME: Doesn't support ssh_port option! */ - helper->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, - "peerStartHelper.pl", tempdir, NULL); + helper->proc = + GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, + "peerStartHelper.pl", tempdir, NULL); GNUNET_assert (helper->proc != NULL); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "starting peers with cmd ssh %s %s %s\n", arg, @@ -5891,9 +5880,9 @@ call_hostkey_callbacks (void *cls, for (i = 0; i < pg->total; i++) { if (pg->peers[i].internal_context.hostkey_callback != NULL) - pg->peers[i].internal_context.hostkey_callback (pg->peers - [i]. - internal_context.hostkey_cls, + pg->peers[i].internal_context.hostkey_callback (pg-> + peers[i].internal_context. + hostkey_cls, &pg->peers[i].daemon->id, pg->peers[i].daemon, NULL); @@ -6044,16 +6033,17 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, if (pg->hosts[i].sshport != 0) { GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport); - proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", - ssh_port_str, + proc = + GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", ssh_port_str, #if !DEBUG_TESTING - "-q", + "-q", #endif - arg, "mkdir -p", tmpdir, NULL); + arg, "mkdir -p", tmpdir, NULL); } else - proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, - "mkdir -p", tmpdir, NULL); + proc = + GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, "mkdir -p", + tmpdir, NULL); GNUNET_assert (proc != NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating remote dir with command ssh %s %s %s\n", arg, @@ -6066,9 +6056,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (baseservicehome); baseservicehome = NULL; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", - "HOSTKEYSFILE", - &hostkeys_file)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE", + &hostkeys_file)) { if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -6076,12 +6066,12 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, else { /* Check hostkey file size, read entire thing into memory */ - fd = GNUNET_DISK_file_open (hostkeys_file, - GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); + fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (NULL == fd) { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "open", hostkeys_file); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", + hostkeys_file); GNUNET_free (hostkeys_file); for (i = 0; i < pg->num_hosts; i++) { @@ -6126,8 +6116,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, hostname = pg->hosts[off % hostcnt].hostname; username = pg->hosts[off % hostcnt].username; sshport = pg->hosts[off % hostcnt].sshport; - pcfg = make_config (cfg, off, &pg->hosts[off % hostcnt].minport, - &upnum, hostname, &fdnum); + pcfg = + make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum, + hostname, &fdnum); } else { @@ -6146,10 +6137,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, continue; } - if (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", - "SERVICEHOME", - &baseservicehome)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", "SERVICEHOME", + &baseservicehome)) { if (hostname != NULL) GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, @@ -6181,9 +6171,8 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, pg->peers[off].internal_context.username = username; pg->peers[off].internal_context.sshport = sshport; if (pg->hostkey_data != NULL) - pg->peers[off].internal_context.hostkey = &pg->hostkey_data[off - * - HOSTKEYFILESIZE]; + pg->peers[off].internal_context.hostkey = + &pg->hostkey_data[off * HOSTKEYFILESIZE]; pg->peers[off].internal_context.hostkey_callback = hostkey_callback; pg->peers[off].internal_context.hostkey_cls = hostkey_cls; pg->peers[off].internal_context.start_cb = cb; @@ -6194,19 +6183,14 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, #else if ((pg->hostkey_data != NULL) && (hostcnt > 0)) { - pg->peers[off].daemon - = GNUNET_TESTING_daemon_start (pcfg, - timeout, - GNUNET_YES, - hostname, - username, - sshport, - pg->peers[off]. - internal_context.hostkey, - &internal_hostkey_callback, - &pg->peers[off].internal_context, - &internal_startup_callback, - &pg->peers[off].internal_context); + pg->peers[off].daemon = + GNUNET_TESTING_daemon_start (pcfg, timeout, GNUNET_YES, hostname, + username, sshport, + pg->peers[off].internal_context.hostkey, + &internal_hostkey_callback, + &pg->peers[off].internal_context, + &internal_startup_callback, + &pg->peers[off].internal_context); /** * At this point, given that we had a hostkeyfile, * we can call the hostkey callback! @@ -6245,10 +6229,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, sshport = 0; } - if (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", - "SERVICEHOME", - &baseservicehome)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", + &baseservicehome)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "baseservice home is %s\n", baseservicehome); @@ -6273,17 +6256,16 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } if (NULL != username) - GNUNET_asprintf (&arg, - "%s@%s:%s", - username, pg->hosts[off].hostname, newservicehome); + GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname, + newservicehome); else - GNUNET_asprintf (&arg, - "%s:%s", pg->hosts[off].hostname, newservicehome); + GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname, + newservicehome); /* FIXME: Doesn't support ssh_port option! */ - proc = GNUNET_OS_start_process (NULL, NULL, - "rsync", - "rsync", "-r", newservicehome, arg, NULL); + proc = + GNUNET_OS_start_process (NULL, NULL, "rsync", "rsync", "-r", + newservicehome, arg, NULL); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "copying directory with command rsync -r %s %s\n", @@ -6338,8 +6320,9 @@ GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg, for (i = 0; i < pg->total; i++) { - if (0 == memcmp (&pg->peers[i].daemon->id, peer_id, - sizeof (struct GNUNET_PeerIdentity))) + if (0 == + memcmp (&pg->peers[i].daemon->id, peer_id, + sizeof (struct GNUNET_PeerIdentity))) return pg->peers[i].daemon; } return NULL; @@ -6376,8 +6359,8 @@ restart_callback (void *cls, const struct GNUNET_PeerIdentity *id, restart_context->callback (restart_context->callback_cls, NULL); GNUNET_free (restart_context); } - else if (restart_context->peers_restart_failed - + restart_context->peers_restarted == + else if (restart_context->peers_restart_failed + + restart_context->peers_restarted == restart_context->peer_group->total) { restart_context->callback (restart_context->callback_cls, @@ -6417,8 +6400,9 @@ churn_stop_callback (void *cls, const char *emsg) churn_ctx->num_to_stop--; } - total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) - + (churn_ctx->num_to_start - churn_ctx->num_failed_start); + total_left = + (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) + + (churn_ctx->num_to_start - churn_ctx->num_failed_start); if (total_left == 0) { @@ -6523,8 +6507,8 @@ schedule_churn_shutdown_task (void *cls, */ void GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, - char *service, - unsigned int voff, unsigned int von, + char *service, unsigned int voff, + unsigned int von, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) { @@ -6634,11 +6618,11 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, stopped_permute = NULL; if (running > 0) - running_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, - running); + running_permute = + GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, running); if (stopped > 0) - stopped_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, - stopped); + stopped_permute = + GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, stopped); total_running = running; total_stopped = stopped; @@ -6707,8 +6691,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, #endif GNUNET_assert (running_arr != NULL); peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext)); - peer_shutdown_ctx->daemon - = pg->peers[running_arr[running_permute[i]]].daemon; + peer_shutdown_ctx->daemon = + pg->peers[running_arr[running_permute[i]]].daemon; peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ctx); } @@ -6730,8 +6714,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_assert (stopped_arr != NULL); peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext)); peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; - peer_restart_ctx->daemon - = pg->peers[stopped_arr[stopped_permute[i]]].daemon; + peer_restart_ctx->daemon = + pg->peers[stopped_arr[stopped_permute[i]]].daemon; GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx); } @@ -6812,8 +6796,8 @@ GNUNET_TESTING_daemons_restart (struct GNUNET_TESTING_PeerGroup *pg, for (off = 0; off < pg->total; off++) { - GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, - &restart_callback, restart_context); + GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, &restart_callback, + restart_context); } } } @@ -6851,8 +6835,8 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg, churn_ctx->cb_cls = cb_cls; shutdown_ctx->cb_cls = churn_ctx; GNUNET_TESTING_daemon_stop (pg->peers[offset].daemon, timeout, - &churn_stop_callback, shutdown_ctx, - GNUNET_NO, GNUNET_YES); + &churn_stop_callback, shutdown_ctx, GNUNET_NO, + GNUNET_YES); } } else if (GNUNET_YES == desired_status) @@ -6866,9 +6850,8 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg, churn_ctx->cb = cb; churn_ctx->cb_cls = cb_cls; startup_ctx->churn_ctx = churn_ctx; - GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, - timeout, &churn_start_callback, - startup_ctx); + GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, timeout, + &churn_start_callback, startup_ctx); } } else @@ -6908,9 +6891,9 @@ internal_shutdown_callback (void *cls, const char *emsg) shutdown_ctx->peers_failed++; } - if ((shutdown_ctx->cb != NULL) && (shutdown_ctx->peers_down - + shutdown_ctx->peers_failed == - shutdown_ctx->total_peers)) + if ((shutdown_ctx->cb != NULL) && + (shutdown_ctx->peers_down + shutdown_ctx->peers_failed == + shutdown_ctx->total_peers)) { if (shutdown_ctx->peers_failed > 0) shutdown_ctx->cb (shutdown_ctx->cb_cls, @@ -6957,11 +6940,11 @@ schedule_shutdown_task (void *cls, shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; GNUNET_assert (shutdown_ctx != NULL); - if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) - || ((peer_shutdown_ctx->daemon->hostname != NULL) - && (count_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, - shutdown_ctx->pg) - < shutdown_ctx->pg->max_concurrent_ssh))) + if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) || + ((peer_shutdown_ctx->daemon->hostname != NULL) && + (count_outstanding_at_host + (peer_shutdown_ctx->daemon->hostname, + shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh))) { if (peer_shutdown_ctx->daemon->hostname != NULL) increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, @@ -7001,9 +6984,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg) int ret; /* Check for a hostfile containing user@host:port triples */ - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", - &hostfile)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", + &hostfile)) return NULL; hosts = NULL; @@ -7012,8 +6995,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg) if (hostfile != NULL) { if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) - GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_fn_write (hostfile, NULL, 0, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -7045,9 +7029,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg) { data[count] = '\0'; temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); - ret = sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", - &temphost->username, &temphost->hostname, - &temphost->port); + ret = + sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", + &temphost->username, &temphost->hostname, &temphost->port); if (3 == ret) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -7100,9 +7084,8 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_assert (pg->total > 0); shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext)); - shutdown_ctx->delete_files = GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, - "TESTING", - "DELETE_FILES"); + shutdown_ctx->delete_files = + GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "DELETE_FILES"); shutdown_ctx->cb = cb; shutdown_ctx->cb_cls = cb_cls; shutdown_ctx->total_peers = pg->total; diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c index e81e9fad8..a76c7cc26 100644 --- a/src/testing/testing_peergroup.c +++ b/src/testing/testing_peergroup.c @@ -203,8 +203,8 @@ update_meter (struct ProgressMeter *meter) fprintf (stdout, "%sProgress: [0%%", meter->startup_string); } else - fprintf (stdout, "%d%%", (int) (((float) meter->completed - / meter->total) * 100)); + fprintf (stdout, "%d%%", + (int) (((float) meter->completed / meter->total) * 100)); } else if (meter->completed % meter->dotnum == 0) fprintf (stdout, "."); @@ -304,8 +304,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * failure (peers failed to connect). */ static void -internal_topology_callback (void *cls, - const struct GNUNET_PeerIdentity *first, +internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, @@ -332,9 +331,9 @@ internal_topology_callback (void *cls, #endif #if TIMING - if (GNUNET_TIME_absolute_get_difference (connect_last_time, - GNUNET_TIME_absolute_get - ()).rel_value > + if (GNUNET_TIME_absolute_get_difference + (connect_last_time, + GNUNET_TIME_absolute_get ()).rel_value > GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, CONN_UPDATE_DURATION).rel_value) { @@ -345,14 +344,14 @@ internal_topology_callback (void *cls, new_failed_connections = failed_connections - previous_failed_connections; /* Get duration in seconds */ - duration - = GNUNET_TIME_absolute_get_difference (connect_last_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; + duration = + GNUNET_TIME_absolute_get_difference (connect_last_time, + GNUNET_TIME_absolute_get ()). + rel_value / 1000; total_duration = GNUNET_TIME_absolute_get_difference (connect_start_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; + GNUNET_TIME_absolute_get ()). + rel_value / 1000; failed_conns_per_sec_recent = (double) new_failed_connections / duration; failed_conns_per_sec_total = (double) failed_connections / total_duration; @@ -360,9 +359,8 @@ internal_topology_callback (void *cls, conns_per_sec_total = (double) total_connections / total_duration; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Recent: %.2f/s, Total: %.2f/s, Recent failed: %.2f/s, total failed %.2f/s\n", - conns_per_sec_recent, CONN_UPDATE_DURATION, - conns_per_sec_total, failed_conns_per_sec_recent, - failed_conns_per_sec_total); + conns_per_sec_recent, CONN_UPDATE_DURATION, conns_per_sec_total, + failed_conns_per_sec_recent, failed_conns_per_sec_total); connect_last_time = GNUNET_TIME_absolute_get (); previous_connections = total_connections; previous_failed_connections = failed_connections; @@ -410,11 +408,9 @@ internal_topology_callback (void *cls, GNUNET_assert (pg_start_ctx->connect_meter != NULL); if (pg_start_ctx->connect_cb != NULL) - pg_start_ctx->connect_cb (pg_start_ctx->cls, first, - second, - distance, - first_cfg, - second_cfg, first_daemon, second_daemon, emsg); + pg_start_ctx->connect_cb (pg_start_ctx->cls, first, second, distance, + first_cfg, second_cfg, first_daemon, + second_daemon, emsg); if (GNUNET_YES == update_meter (pg_start_ctx->connect_meter)) { #if VERBOSE @@ -424,10 +420,10 @@ internal_topology_callback (void *cls, #endif #if TIMING - total_duration - = GNUNET_TIME_absolute_get_difference (connect_start_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; + total_duration = + GNUNET_TIME_absolute_get_difference (connect_start_time, + GNUNET_TIME_absolute_get ()). + rel_value / 1000; failed_conns_per_sec_total = (double) failed_connections / total_duration; conns_per_sec_total = (double) total_connections / total_duration; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -494,20 +490,21 @@ internal_peers_started_callback (void *cls, if ((pg_start_ctx->pg != NULL) && (pg_start_ctx->peers_left == 0)) { pg_start_ctx->connect_start_time = GNUNET_TIME_absolute_get (); - pg_start_ctx->expected_connections - = GNUNET_TESTING_connect_topology (pg_start_ctx->pg, - pg_start_ctx->connect_topology, - pg_start_ctx->connect_topology_option, - pg_start_ctx->connect_topology_option_modifier, - DEFAULT_CONNECT_TIMEOUT, - pg_start_ctx->connect_attempts, - NULL, NULL); - - pg_start_ctx->connect_meter - = create_meter (pg_start_ctx->expected_connections, - "Peer connection ", pg_start_ctx->verbose); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Have %d expected connections\n", + pg_start_ctx->expected_connections = + GNUNET_TESTING_connect_topology (pg_start_ctx->pg, + pg_start_ctx->connect_topology, + pg_start_ctx-> + connect_topology_option, + pg_start_ctx-> + connect_topology_option_modifier, + DEFAULT_CONNECT_TIMEOUT, + pg_start_ctx->connect_attempts, NULL, + NULL); + + pg_start_ctx->connect_meter = + create_meter (pg_start_ctx->expected_connections, "Peer connection ", + pg_start_ctx->verbose); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", pg_start_ctx->expected_connections); } @@ -553,8 +550,8 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, #if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Hostkey (%d/%d) created for peer `%s'\n", - num_peers - peers_left, num_peers, GNUNET_i2s (id)); + "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, + num_peers, GNUNET_i2s (id)); #endif pg_start_ctx->peers_left--; @@ -583,13 +580,13 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, else { GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); - pg_start_ctx->die_task = GNUNET_SCHEDULER_add_now (&end_badly, - "from create topology (bad return)"); + pg_start_ctx->die_task = + GNUNET_SCHEDULER_add_now (&end_badly, + "from create topology (bad return)"); } GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); - pg_start_ctx->die_task - = + pg_start_ctx->die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (pg_start_ctx->timeout), &end_badly, "from continue startup (timeout)"); @@ -608,8 +605,7 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, * @param emsg error message (NULL on success) */ void -write_topology_cb (void *cls, - const struct GNUNET_PeerIdentity *first, +write_topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, const char *emsg) { struct TopologyOutputContext *topo_ctx; @@ -727,9 +723,9 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, pg_start_ctx = GNUNET_malloc (sizeof (struct PeerGroupStartupContext)); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "connect_attempts", - &pg_start_ctx->connect_attempts)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts", + &pg_start_ctx->connect_attempts)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts"); @@ -737,10 +733,11 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "max_outstanding_connections", - &pg_start_ctx->max_concurrent_connections)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", + "max_outstanding_connections", + &pg_start_ctx-> + max_concurrent_connections)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections"); @@ -748,9 +745,10 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "max_concurrent_ssh", - &pg_start_ctx->max_concurrent_ssh)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", + "max_concurrent_ssh", + &pg_start_ctx->max_concurrent_ssh)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_concurrent_ssh"); @@ -769,9 +767,10 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", - "peergroup_timeout", - &temp_config_number)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "testing", + "peergroup_timeout", + &temp_config_number)) pg_start_ctx->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, @@ -787,11 +786,11 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, /* Read topology related options from the configuration file */ temp_str = NULL; - if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "topology", - &temp_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_get (&pg_start_ctx->topology, temp_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", + &temp_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&pg_start_ctx->topology, temp_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid topology `%s' given for section %s option %s\n", @@ -821,9 +820,9 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (temp_str); } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", - &temp_str)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", + &temp_str)) pg_start_ctx->topology_percentage = 0.5; else { @@ -831,9 +830,9 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (temp_str); } - if (GNUNET_OK - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", - &temp_str)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", + &temp_str)) pg_start_ctx->topology_probability = 0.5; else { @@ -841,13 +840,11 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (temp_str); } - if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "connect_topology", - &temp_str)) - && (GNUNET_NO == - GNUNET_TESTING_topology_get (&pg_start_ctx->connect_topology, - temp_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "connect_topology", &temp_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_get (&pg_start_ctx->connect_topology, temp_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology `%s' given for section %s option %s\n", @@ -855,14 +852,13 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } GNUNET_free_non_null (temp_str); - if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "connect_topology_option", - &temp_str)) - && (GNUNET_NO - == - GNUNET_TESTING_topology_option_get - (&pg_start_ctx->connect_topology_option, temp_str))) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "connect_topology_option", + &temp_str)) && + (GNUNET_NO == + GNUNET_TESTING_topology_option_get (&pg_start_ctx-> + connect_topology_option, temp_str))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid connect topology option `%s' given for section %s option %s\n", @@ -871,14 +867,13 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } GNUNET_free_non_null (temp_str); - if (GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, - "testing", - "connect_topology_option_modifier", - &temp_str)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "connect_topology_option_modifier", + &temp_str)) { - if (sscanf (temp_str, "%lf", - &pg_start_ctx->connect_topology_option_modifier) != 1) + if (sscanf + (temp_str, "%lf", &pg_start_ctx->connect_topology_option_modifier) != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -891,17 +886,17 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (temp_str); } - if (GNUNET_YES - != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "blacklist_transports", - &pg_start_ctx->restrict_transports)) + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "blacklist_transports", + &pg_start_ctx-> + restrict_transports)) pg_start_ctx->restrict_transports = NULL; pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE; - if ((GNUNET_YES - == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", - "blacklist_topology", - &temp_str)) + if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (cfg, "testing", + "blacklist_topology", &temp_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get (&pg_start_ctx->restrict_topology, temp_str))) @@ -928,23 +923,21 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, pg_start_ctx->verbose); /* Make compilers happy */ reset_meter (pg_start_ctx->peer_start_meter); - pg_start_ctx->die_task - = + pg_start_ctx->die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (pg_start_ctx->timeout), &end_badly, "didn't generate all hostkeys within allowed startup time!"); - pg_start_ctx->pg - = GNUNET_TESTING_daemons_start (pg_start_ctx->cfg, - pg_start_ctx->peers_left, - pg_start_ctx->max_concurrent_connections, - pg_start_ctx->max_concurrent_ssh, - GNUNET_TIME_absolute_get_remaining - (pg_start_ctx->timeout), - &internal_hostkey_callback, pg_start_ctx, - &internal_peers_started_callback, - pg_start_ctx, &internal_topology_callback, - pg_start_ctx, pg_start_ctx->hostnames); + pg_start_ctx->pg = + GNUNET_TESTING_daemons_start (pg_start_ctx->cfg, pg_start_ctx->peers_left, + pg_start_ctx->max_concurrent_connections, + pg_start_ctx->max_concurrent_ssh, + GNUNET_TIME_absolute_get_remaining + (pg_start_ctx->timeout), + &internal_hostkey_callback, pg_start_ctx, + &internal_peers_started_callback, + pg_start_ctx, &internal_topology_callback, + pg_start_ctx, pg_start_ctx->hostnames); return pg_start_ctx->pg; } diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 91d0ed12d..8f86619fd 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -247,8 +247,8 @@ blacklist_check (void *cls, const struct GNUNET_PeerIdentity *pid) pos = GNUNET_CONTAINER_multihashmap_get (peers, &pid->hashPubKey); if ((pos != NULL) && (pos->is_friend == GNUNET_YES)) return GNUNET_OK; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# peers blacklisted"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# peers blacklisted"), 1, + GNUNET_NO); return GNUNET_SYSERR; } @@ -292,8 +292,8 @@ connect_completed_callback (void *cls, int success) static int is_connection_allowed (struct Peer *peer) { - if (0 == memcmp (&my_identity, - &peer->pid, sizeof (struct GNUNET_PeerIdentity))) + if (0 == + memcmp (&my_identity, &peer->pid, sizeof (struct GNUNET_PeerIdentity))) return GNUNET_SYSERR; /* disallow connections to self */ if (peer->is_friend) return GNUNET_OK; @@ -355,8 +355,9 @@ free_peer (void *cls, const GNUNET_HashCode * pid, void *value) * @param cls 'struct Peer' to greylist * @param tc scheduler context */ -static void -remove_from_greylist (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void remove_from_greylist (void *cls, + const struct GNUNET_SCHEDULER_TaskContext + *tc); /** @@ -392,19 +393,18 @@ attempt_connect (struct Peer *pos) pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem); if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (pos->greylist_clean_task); - pos->greylist_clean_task - = GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); + pos->greylist_clean_task = + GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); #if DEBUG_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Asking to connect to `%s'\n", GNUNET_i2s (&pos->pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to connect to `%s'\n", + GNUNET_i2s (&pos->pid)); #endif GNUNET_STATISTICS_update (stats, gettext_noop ("# connect requests issued to core"), 1, GNUNET_NO); - pos->connect_req = GNUNET_CORE_peer_request_connect (handle, - &pos->pid, - &connect_completed_callback, - pos); + pos->connect_req = + GNUNET_CORE_peer_request_connect (handle, &pos->pid, + &connect_completed_callback, pos); } @@ -429,11 +429,11 @@ remove_from_greylist (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } else { - pos->greylist_clean_task - = GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); + pos->greylist_clean_task = + GNUNET_SCHEDULER_add_delayed (rem, &remove_from_greylist, pos); } - if ((GNUNET_NO == pos->is_friend) && - (GNUNET_NO == pos->is_connected) && (NULL == pos->hello)) + if ((GNUNET_NO == pos->is_friend) && (GNUNET_NO == pos->is_connected) && + (NULL == pos->hello)) { free_peer (NULL, &pos->pid.hashPubKey, pos); return; @@ -450,8 +450,7 @@ remove_from_greylist (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return the new entry */ static struct Peer * -make_peer (const struct - GNUNET_PeerIdentity *peer, +make_peer (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, int is_friend) { struct Peer *ret; @@ -465,8 +464,7 @@ make_peer (const struct memcpy (ret->hello, hello, GNUNET_HELLO_size (hello)); } GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (peers, - &peer->hashPubKey, + GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, ret, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); return ret; @@ -599,8 +597,8 @@ schedule_next_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) fah.max_size = GNUNET_SERVER_MAX_MESSAGE_SIZE - 1; fah.next_adv = GNUNET_TIME_UNIT_FOREVER_REL; GNUNET_CONTAINER_multihashmap_iterate (peers, &find_advertisable_hello, &fah); - pl->hello_delay_task - = GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); + pl->hello_delay_task = + GNUNET_SCHEDULER_add_delayed (fah.next_adv, &schedule_next_hello, pl); if (fah.result == NULL) return; next_want = GNUNET_HELLO_size (fah.result->hello); @@ -608,14 +606,11 @@ schedule_next_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (delay.rel_value == 0) { /* now! */ - pl->hello_req = GNUNET_CORE_notify_transmit_ready (handle, - GNUNET_YES, - 0, - GNUNET_CONSTANTS_SERVICE_TIMEOUT, - &pl->pid, - next_want, - &hello_advertising_ready, - pl); + pl->hello_req = + GNUNET_CORE_notify_transmit_ready (handle, GNUNET_YES, 0, + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + &pl->pid, next_want, + &hello_advertising_ready, pl); } } @@ -650,8 +645,8 @@ reschedule_hellos (void *cls, const GNUNET_HashCode * pid, void *value) GNUNET_SCHEDULER_cancel (peer->hello_delay_task); peer->hello_delay_task = GNUNET_SCHEDULER_NO_TASK; } - peer->hello_delay_task - = GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); + peer->hello_delay_task = + GNUNET_SCHEDULER_add_now (&schedule_next_hello, peer); return GNUNET_YES; } @@ -664,9 +659,7 @@ reschedule_hellos (void *cls, const GNUNET_HashCode * pid, void *value) * @param atsi performance data */ static void -connect_notify (void *cls, - const struct - GNUNET_PeerIdentity *peer, +connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { struct Peer *pos; @@ -680,8 +673,7 @@ connect_notify (void *cls, return; connection_count++; - GNUNET_STATISTICS_set (stats, - gettext_noop ("# peers connected"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# peers connected"), connection_count, GNUNET_NO); pos = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); if (pos == NULL) @@ -702,8 +694,7 @@ connect_notify (void *cls, (GNUNET_YES != friends_only)) whitelist_peers (); friend_count++; - GNUNET_STATISTICS_set (stats, - gettext_noop ("# friends connected"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# friends connected"), friend_count, GNUNET_NO); } reschedule_hellos (NULL, &peer->hashPubKey, pos); @@ -784,14 +775,12 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) GNUNET_SCHEDULER_cancel (pos->hello_delay_task); pos->hello_delay_task = GNUNET_SCHEDULER_NO_TASK; } - GNUNET_STATISTICS_set (stats, - gettext_noop ("# peers connected"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# peers connected"), connection_count, GNUNET_NO); if (pos->is_friend) { friend_count--; - GNUNET_STATISTICS_set (stats, - gettext_noop ("# friends connected"), + GNUNET_STATISTICS_set (stats, gettext_noop ("# friends connected"), friend_count, GNUNET_NO); } if (((connection_count < target_connection_count) || @@ -814,10 +803,9 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) * @return GNUNET_SYSERR always, to terminate iteration */ static int -address_iterator (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +address_iterator (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { int *flag = cls; @@ -850,8 +838,8 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) if (0 == memcmp (&pid, &my_identity, sizeof (struct GNUNET_PeerIdentity))) return; /* that's me! */ have_address = GNUNET_NO; - GNUNET_HELLO_iterate_addresses (hello, - GNUNET_NO, &address_iterator, &have_address); + GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &address_iterator, + &have_address); if (GNUNET_NO == have_address) return; /* no point in advertising this one... */ peer = GNUNET_CONTAINER_multihashmap_get (peers, &pid.hashPubKey); @@ -867,8 +855,8 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) } #if DEBUG_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found `%s' from peer `%s' for advertising\n", - "HELLO", GNUNET_i2s (&pid)); + "Found `%s' from peer `%s' for advertising\n", "HELLO", + GNUNET_i2s (&pid)); #endif if (peer->hello != NULL) { @@ -901,8 +889,7 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) * @param err_msg NULL if successful, otherwise contains error message */ static void -process_peer (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_peer (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { struct Peer *pos; @@ -932,11 +919,10 @@ process_peer (void *cls, GNUNET_CONTAINER_bloomfilter_free (pos->filter); pos->filter = NULL; } - if ((!pos->is_connected) && - (!pos->is_friend) && + if ((!pos->is_connected) && (!pos->is_friend) && (0 == - GNUNET_TIME_absolute_get_remaining (pos-> - greylisted_until).rel_value)) + GNUNET_TIME_absolute_get_remaining (pos->greylisted_until). + rel_value)) free_peer (NULL, &pos->pid.hashPubKey, pos); } return; @@ -949,22 +935,22 @@ process_peer (void *cls, if (GNUNET_YES == pos->is_connected) { #if DEBUG_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Already connected to peer `%s'\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already connected to peer `%s'\n", + GNUNET_i2s (peer)); #endif return; } if (GNUNET_TIME_absolute_get_remaining (pos->greylisted_until).rel_value > 0) { #if DEBUG_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Already tried peer `%s' recently\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Already tried peer `%s' recently\n", + GNUNET_i2s (peer)); #endif return; /* peer still greylisted */ } #if DEBUG_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Considering connecting to peer `%s'\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Considering connecting to peer `%s'\n", + GNUNET_i2s (peer)); #endif attempt_connect (pos); } @@ -980,8 +966,7 @@ process_peer (void *cls, * @param publicKey public key of this peer, NULL if we failed */ static void -core_init (void *cls, - struct GNUNET_CORE_Handle *server, +core_init (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_id, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) { @@ -1021,14 +1006,14 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) GNUNET_CONFIGURATION_get_value_filename (cfg, "TOPOLOGY", "FRIENDS", &fn)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Option `%s' in section `%s' not specified!\n"), - "FRIENDS", "TOPOLOGY"); + _("Option `%s' in section `%s' not specified!\n"), "FRIENDS", + "TOPOLOGY"); return; } if (GNUNET_OK != GNUNET_DISK_file_test (fn)) GNUNET_DISK_fn_write (fn, NULL, 0, - GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (0 != STAT (fn, &frstat)) { if ((friends_only) || (minimum_friend_count > 0)) @@ -1039,8 +1024,8 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) } if (frstat.st_size == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Friends file `%s' is empty.\n"), fn); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Friends file `%s' is empty.\n"), + fn); GNUNET_free (fn); return; } @@ -1071,8 +1056,8 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) { memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); if (!isspace - ((unsigned char) - enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) + ((unsigned char) enc. + encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -1115,8 +1100,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) } GNUNET_free (data); GNUNET_free (fn); - GNUNET_STATISTICS_update (stats, - gettext_noop ("# friends in configuration"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# friends in configuration"), entries_found, GNUNET_NO); if ((minimum_friend_count > entries_found) && (friends_only == GNUNET_NO)) { @@ -1147,8 +1131,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) * GNUNET_SYSERR to close it (signal serious error) */ static int -handle_encrypted_hello (void *cls, - const struct GNUNET_PeerIdentity *other, +handle_encrypted_hello (void *cls, const struct GNUNET_PeerIdentity *other, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi) { @@ -1156,8 +1139,7 @@ handle_encrypted_hello (void *cls, struct GNUNET_PeerIdentity pid; #if DEBUG_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received encrypted `%s' from peer `%s'", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received encrypted `%s' from peer `%s'", "HELLO", GNUNET_i2s (other)); #endif if (GNUNET_OK != @@ -1166,8 +1148,7 @@ handle_encrypted_hello (void *cls, GNUNET_break_op (0); return GNUNET_SYSERR; } - GNUNET_STATISTICS_update (stats, - gettext_noop ("# HELLO messages received"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# HELLO messages received"), 1, GNUNET_NO); peer = GNUNET_CONTAINER_multihashmap_get (peers, &pid.hashPubKey); if (peer == NULL) @@ -1220,12 +1201,12 @@ hello_advertising_ready (void *cls, size_t size, void *buf) memcpy (buf, fah.result->hello, want); GNUNET_CONTAINER_bloomfilter_add (fah.result->filter, &pl->pid.hashPubKey); #if DEBUG_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending `%s' with %u bytes", "HELLO", (unsigned int) want); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' with %u bytes", "HELLO", + (unsigned int) want); #endif GNUNET_STATISTICS_update (stats, - gettext_noop ("# HELLO messages gossipped"), - 1, GNUNET_NO); + gettext_noop ("# HELLO messages gossipped"), 1, + GNUNET_NO); } if (pl->hello_delay_task != GNUNET_SCHEDULER_NO_TASK) @@ -1284,9 +1265,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { static struct GNUNET_CORE_MessageHandler handlers[] = { {&handle_encrypted_hello, GNUNET_MESSAGE_TYPE_HELLO, 0}, @@ -1296,21 +1276,17 @@ run (void *cls, cfg = c; stats = GNUNET_STATISTICS_create ("topology", cfg); - autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "TOPOLOGY", - "AUTOCONNECT"); - friends_only = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "TOPOLOGY", - "FRIENDS-ONLY"); + autoconnect = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "TOPOLOGY", "AUTOCONNECT"); + friends_only = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "TOPOLOGY", "FRIENDS-ONLY"); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - "TOPOLOGY", - "MINIMUM-FRIENDS", &opt)) + GNUNET_CONFIGURATION_get_value_number (cfg, "TOPOLOGY", "MINIMUM-FRIENDS", + &opt)) opt = 0; minimum_friend_count = (unsigned int) opt; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - "TOPOLOGY", + GNUNET_CONFIGURATION_get_value_number (cfg, "TOPOLOGY", "TARGET-CONNECTION-COUNT", &opt)) opt = 16; target_connection_count = (unsigned int) opt; @@ -1321,23 +1297,18 @@ run (void *cls, #if DEBUG_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Topology would like %u connections with at least %u friends (%s)\n", - target_connection_count, - minimum_friend_count, + target_connection_count, minimum_friend_count, autoconnect ? "autoconnect enabled" : "autoconnect disabled"); #endif if ((friend_count < minimum_friend_count) && (blacklist == NULL)) blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL); transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); - handle = GNUNET_CORE_connect (cfg, - 1, - NULL, - &core_init, - &connect_notify, - &disconnect_notify, - NULL, - NULL, GNUNET_NO, NULL, GNUNET_NO, handlers); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleaning_task, NULL); + handle = + GNUNET_CORE_connect (cfg, 1, NULL, &core_init, &connect_notify, + &disconnect_notify, NULL, NULL, GNUNET_NO, NULL, + GNUNET_NO, handlers); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, + NULL); if (NULL == transport) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1370,13 +1341,12 @@ main (int argc, char *const *argv) }; int ret; - ret = (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-daemon-topology", - _ - ("GNUnet topology control (maintaining P2P mesh and F2F constraints)"), - options, &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-topology", + _ + ("GNUnet topology control (maintaining P2P mesh and F2F constraints)"), + options, &run, NULL)) ? 0 : 1; return ret; } diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c index 9d0c055cb..c9a43ecd7 100644 --- a/src/topology/test_gnunet_daemon_topology.c +++ b/src/topology/test_gnunet_daemon_topology.c @@ -80,8 +80,7 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -notify_connect_complete (void *cls, - const struct GNUNET_PeerIdentity *first, +notify_connect_complete (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, unsigned int distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, @@ -108,8 +107,7 @@ notify_connect_complete (void *cls, static void -my_cb (void *cls, - const struct GNUNET_PeerIdentity *id, +my_cb (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -134,22 +132,17 @@ my_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { ok = 1; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); #endif peers_left = NUM_PEERS; - pg = GNUNET_TESTING_daemons_start (cfg, - peers_left, - peers_left, - peers_left, - TIMEOUT, - NULL, NULL, - &my_cb, NULL, NULL, NULL, NULL); + pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left, peers_left, + TIMEOUT, NULL, NULL, &my_cb, NULL, NULL, + NULL, NULL); GNUNET_assert (pg != NULL); } @@ -169,9 +162,9 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-gnunet-daemon-topology", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-gnunet-daemon-topology", "nohelp", options, &run, + &ok); return ok; } diff --git a/src/transport/gnunet-service-transport-new.c b/src/transport/gnunet-service-transport-new.c index 8ceffd86c..6c2b396dc 100644 --- a/src/transport/gnunet-service-transport-new.c +++ b/src/transport/gnunet-service-transport-new.c @@ -85,16 +85,13 @@ struct GNUNET_ATS_Handle *GST_ats; * @param ats_count number of records in ats (unused) */ static void -transmit_our_hello (void *cls, - const struct GNUNET_PeerIdentity *target, +transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { const struct GNUNET_MessageHeader *hello = cls; - GST_neighbours_send (target, - (const char *) hello, - ntohs (hello->size), + GST_neighbours_send (target, (const char *) hello, ntohs (hello->size), GST_HELLO_ADDRESS_EXPIRATION, NULL, NULL); } @@ -123,8 +120,8 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) * GNUNET_NO if not */ static void -try_connect_if_allowed (void *cls, - const struct GNUNET_PeerIdentity *peer, int result) +try_connect_if_allowed (void *cls, const struct GNUNET_PeerIdentity *peer, + int result) { if (GNUNET_OK != result) return; /* not allowed */ @@ -156,8 +153,7 @@ try_connect_if_allowed (void *cls, * (plugins that do not support this, can ignore the return value) */ static struct GNUNET_TIME_Relative -plugin_env_receive_callback (void *cls, - const struct GNUNET_PeerIdentity *peer, +plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count, struct Session *session, @@ -182,33 +178,29 @@ plugin_env_receive_callback (void *cls, case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Processing `%s' from `%s'\n", - "PING", - (sender_address != NULL) - ? GST_plugins_a2s (plugin_name, - sender_address, - sender_address_len) : ""); + "Processing `%s' from `%s'\n", "PING", + (sender_address != NULL) ? GST_plugins_a2s (plugin_name, + sender_address, + sender_address_len) + : ""); #endif - GST_validation_handle_ping (peer, - message, - plugin_name, - session, sender_address, sender_address_len); + GST_validation_handle_ping (peer, message, plugin_name, session, + sender_address, sender_address_len); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Processing `%s' from `%s'\n", - "PONG", - (sender_address != NULL) - ? GST_plugins_a2s (plugin_name, - sender_address, - sender_address_len) : ""); + "Processing `%s' from `%s'\n", "PONG", + (sender_address != NULL) ? GST_plugins_a2s (plugin_name, + sender_address, + sender_address_len) + : ""); #endif GST_validation_handle_pong (peer, message); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT: - (void) GST_blacklist_test_allowed (peer, - NULL, &try_connect_if_allowed, NULL); + (void) GST_blacklist_test_allowed (peer, NULL, &try_connect_if_allowed, + NULL); /* TODO: if 'session != NULL', maybe notify ATS that this is now the preferred * way to communicate with this peer (other peer switched transport) */ break; @@ -223,20 +215,19 @@ plugin_env_receive_callback (void *cls, default: /* should be payload */ do_forward = GNUNET_SYSERR; - ret = GST_neighbours_calculate_receive_delay (peer, - (message == NULL) - ? 0 - : ntohs (message->size), - &do_forward); + ret = + GST_neighbours_calculate_receive_delay (peer, + (message == + NULL) ? 0 : ntohs (message-> + size), + &do_forward); if (do_forward == GNUNET_YES) GST_clients_broadcast (message, GNUNET_YES); break; } } GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (), /* valid at least until right now... */ - plugin_name, - session, - sender_address, + plugin_name, session, sender_address, sender_address_len, ats, ats_count); return ret; @@ -255,8 +246,7 @@ plugin_env_receive_callback (void *cls, * @param addrlen length of the address */ static void -plugin_env_address_change_notification (void *cls, - int add_remove, +plugin_env_address_change_notification (void *cls, int add_remove, const void *addr, size_t addrlen) { const char *plugin_name = cls; @@ -279,8 +269,7 @@ plugin_env_address_change_notification (void *cls, * @param session which session is being destoyed */ static void -plugin_env_session_end (void *cls, - const struct GNUNET_PeerIdentity *peer, +plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, struct Session *session) { GST_neighbours_session_terminated (peer, session); @@ -303,17 +292,12 @@ plugin_env_session_end (void *cls, * @param bandwidth assigned outbound bandwidth for the connection */ static void -ats_request_address_change (void *cls, - const struct GNUNET_PeerIdentity *peer, - const char *plugin_name, - struct Session *session, - const void *plugin_addr, - size_t plugin_addr_len, +ats_request_address_change (void *cls, const struct GNUNET_PeerIdentity *peer, + const char *plugin_name, struct Session *session, + const void *plugin_addr, size_t plugin_addr_len, struct GNUNET_BANDWIDTH_Value32NBO bandwidth) { - GST_neighbours_switch_to_address (peer, - plugin_name, - plugin_addr, + GST_neighbours_switch_to_address (peer, plugin_name, plugin_addr, plugin_addr_len, session, NULL, 0); GST_neighbours_set_incoming_quota (peer, bandwidth); } @@ -417,8 +401,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { char *keyfile; @@ -426,8 +409,8 @@ run (void *cls, /* setup globals */ GST_cfg = c; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", "HOSTKEY", &keyfile)) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -447,10 +430,10 @@ run (void *cls, GST_stats = GNUNET_STATISTICS_create ("transport", c); GST_peerinfo = GNUNET_PEERINFO_connect (c); GNUNET_CRYPTO_rsa_key_get_public (GST_my_private_key, &GST_my_public_key); - GNUNET_CRYPTO_hash (&GST_my_public_key, - sizeof (GST_my_public_key), &GST_my_identity.hashPubKey); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_CRYPTO_hash (&GST_my_public_key, sizeof (GST_my_public_key), + &GST_my_identity.hashPubKey); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); if (GST_peerinfo == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -466,8 +449,7 @@ run (void *cls, &plugin_env_address_change_notification, &plugin_env_session_end); GST_ats = GNUNET_ATS_init (GST_cfg, &ats_request_address_change, NULL); - GST_neighbours_start (NULL, - &neighbours_connect_notification, + GST_neighbours_start (NULL, &neighbours_connect_notification, &neighbours_disconnect_notification); GST_clients_start (server); GST_validation_start (); @@ -485,9 +467,7 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "transport", + GNUNET_SERVICE_run (argc, argv, "transport", GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; } diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 4f962d117..5b0a58fac 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -1065,8 +1065,7 @@ is_blacklisted (const struct GNUNET_PeerIdentity *peer, (plugin->blacklist, &peer->hashPubKey) == GNUNET_YES) { #if DEBUG_BLACKLIST - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%s:%s' is blacklisted!\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s:%s' is blacklisted!\n", plugin->short_name, GNUNET_i2s (peer)); #endif if (stats != NULL) @@ -1097,8 +1096,7 @@ add_peer_to_blacklist (struct GNUNET_PeerIdentity *peer, char *transport_name) plugin->blacklist = GNUNET_CONTAINER_multihashmap_create (TRANSPORT_BLACKLIST_HT_SIZE); GNUNET_assert (plugin->blacklist != NULL); - GNUNET_CONTAINER_multihashmap_put (plugin->blacklist, &peer->hashPubKey, - NULL, + GNUNET_CONTAINER_multihashmap_put (plugin->blacklist, &peer->hashPubKey, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); } @@ -1124,8 +1122,7 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) char *transport_name; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "TRANSPORT", + GNUNET_CONFIGURATION_get_value_filename (cfg, "TRANSPORT", "BLACKLIST_FILE", &fn)) { #if DEBUG_TRANSPORT @@ -1136,8 +1133,9 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) return; } if (GNUNET_OK != GNUNET_DISK_file_test (fn)) - GNUNET_DISK_fn_write (fn, NULL, 0, GNUNET_DISK_PERM_USER_READ - | GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_fn_write (fn, NULL, 0, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (0 != STAT (fn, &frstat)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1148,8 +1146,8 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) if (frstat.st_size == 0) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklist file `%s' is empty.\n"), fn); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"), + fn); #endif GNUNET_free (fn); return; @@ -1225,8 +1223,8 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) #endif memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); if (!isspace - ((unsigned char) - enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) + ((unsigned char) enc. + encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -1338,11 +1336,11 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) if (NULL != q) { GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); - client->th = GNUNET_SERVER_notify_transmit_ready (client->client, - msize, - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_client_callback, - client); + client->th = + GNUNET_SERVER_notify_transmit_ready (client->client, msize, + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_client_callback, + client); GNUNET_assert (client->th != NULL); } return tsize; @@ -1419,11 +1417,10 @@ timeout_hello_validation (void *cls, va->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_STATISTICS_update (stats, - gettext_noop ("# address validation timeouts"), - 1, GNUNET_NO); + gettext_noop ("# address validation timeouts"), 1, + GNUNET_NO); GNUNET_CRYPTO_hash (&va->publicKey, - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pid.hashPubKey); GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (validation_map, @@ -1464,8 +1461,8 @@ transmit_to_client (struct TransportClient *client, GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"), - ntohs (msg->type), - ntohs (msg->size), client->message_count, MAX_PENDING); + ntohs (msg->type), ntohs (msg->size), client->message_count, + MAX_PENDING); GNUNET_STATISTICS_update (stats, gettext_noop ("# messages dropped due to slow client"), 1, @@ -1481,11 +1478,11 @@ transmit_to_client (struct TransportClient *client, client->message_count++; if (client->th == NULL) { - client->th = GNUNET_SERVER_notify_transmit_ready (client->client, - msize, - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_client_callback, - client); + client->th = + GNUNET_SERVER_notify_transmit_ready (client->client, msize, + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_client_callback, + client); GNUNET_assert (client->th != NULL); } } @@ -1501,8 +1498,7 @@ transmit_to_client (struct TransportClient *client, * @param result status code for the transmission request */ static void -transmit_send_ok (struct TransportClient *client, - struct NeighbourMapEntry *n, +transmit_send_ok (struct TransportClient *client, struct NeighbourMapEntry *n, const struct GNUNET_PeerIdentity *target, int result) { struct SendOkMessage send_ok_msg; @@ -1561,8 +1557,7 @@ retry_transmission_task (void *cls, * more messages */ static void -transmit_send_continuation (void *cls, - const struct GNUNET_PeerIdentity *target, +transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target, int result) { struct MessageQueue *mq = cls; @@ -1606,8 +1601,7 @@ transmit_send_continuation (void *cls, mq->specific_address->addr, mq->specific_address->addrlen)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connected addresses"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, GNUNET_NO); mq->specific_address->connected = GNUNET_NO; } @@ -1698,13 +1692,13 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) GNUNET_NO); if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->retry_task); - n->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, - &retry_transmission_task, n); + n->retry_task = + GNUNET_SCHEDULER_add_delayed (timeout, &retry_transmission_task, n); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", - mq->message_buf_size, - GNUNET_i2s (&mq->neighbour_id), timeout.rel_value); + mq->message_buf_size, GNUNET_i2s (&mq->neighbour_id), + timeout.rel_value); #endif /* FIXME: might want to trigger peerinfo lookup here * (unless that's already pending...) */ @@ -1720,13 +1714,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message of size %u for `%4s' to `%s' via plugin `%s'\n", - mq->message_buf_size, - GNUNET_i2s (&n->id), - (mq->specific_address->addr != NULL) - ? a2s (mq->plugin->short_name, - mq->specific_address->addr, - mq->specific_address->addrlen) - : "", rl->plugin->short_name); + mq->message_buf_size, GNUNET_i2s (&n->id), + (mq->specific_address->addr != + NULL) ? a2s (mq->plugin->short_name, mq->specific_address->addr, + mq->specific_address->addrlen) : "", + rl->plugin->short_name); #endif GNUNET_STATISTICS_update (stats, gettext_noop @@ -1738,16 +1730,15 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) GNUNET_CONTAINER_DLL_insert (n->cont_head, n->cont_tail, mq); - ret = rl->plugin->api->send (rl->plugin->api->cls, - &mq->neighbour_id, - mq->message_buf, - mq->message_buf_size, - mq->priority, - GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, - mq->specific_address->session, - mq->specific_address->addr, - mq->specific_address->addrlen, - force_address, &transmit_send_continuation, mq); + ret = + rl->plugin->api->send (rl->plugin->api->cls, &mq->neighbour_id, + mq->message_buf, mq->message_buf_size, + mq->priority, + GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + mq->specific_address->session, + mq->specific_address->addr, + mq->specific_address->addrlen, force_address, + &transmit_send_continuation, mq); if (ret == -1) { /* failure, but 'send' would not call continuation in this case, @@ -1773,10 +1764,8 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) static void transmit_to_peer (struct TransportClient *client, struct ForeignAddressList *peer_address, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - const char *message_buf, - size_t message_buf_size, + unsigned int priority, struct GNUNET_TIME_Relative timeout, + const char *message_buf, size_t message_buf_size, int is_internal, struct NeighbourMapEntry *neighbour) { struct MessageQueue *mq; @@ -1865,12 +1854,11 @@ transmit_plain_ping (struct NeighbourMapEntry *n) continue; ve = GNUNET_malloc (sizeof (struct ValidationEntry)); ve->transport_name = GNUNET_strdup (plugin->short_name); - ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, - UINT_MAX); + ve->challenge = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX); ve->send_time = GNUNET_TIME_absolute_get (); ve->session = fal->session; - memcpy (&ve->publicKey, - &n->publicKey, + memcpy (&ve->publicKey, &n->publicKey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); ve->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, @@ -1919,8 +1907,8 @@ mark_address_connected (struct ForeignAddressList *fal) while (pos != NULL) { /* Already have inbound address, and this is also an inbound address, don't switch!! */ - if ((GNUNET_YES == pos->connected) && - (0 == pos->addrlen) && (0 == fal->addrlen)) + if ((GNUNET_YES == pos->connected) && (0 == pos->addrlen) && + (0 == fal->addrlen)) return; if ((0 == pos->addrlen) && (GNUNET_YES == pos->connected)) inbound = pos; @@ -1931,8 +1919,8 @@ mark_address_connected (struct ForeignAddressList *fal) while (pos != NULL) { /* Already have outbound address, and this is also an outbound address, don't switch!! */ - if ((GNUNET_YES == pos->connected) && - (0 < pos->addrlen) && (0 < fal->addrlen)) + if ((GNUNET_YES == pos->connected) && (0 < pos->addrlen) && + (0 < fal->addrlen)) return; if ((0 < pos->addrlen) && (GNUNET_YES == pos->connected)) outbound = pos; @@ -1949,14 +1937,11 @@ mark_address_connected (struct ForeignAddressList *fal) #endif /* Have an inbound connection to this peer which is valid; our id is lower, ignore outbound connection! */ - if ((inbound != NULL) && (0 != fal->addrlen) && (1 - == - GNUNET_CRYPTO_hash_xorcmp - (&inbound-> - ready_list->neighbour->id. - hashPubKey, - &my_identity.hashPubKey, - &null_hash))) + if ((inbound != NULL) && (0 != fal->addrlen) && + (1 == + GNUNET_CRYPTO_hash_xorcmp (&inbound->ready_list->neighbour-> + id.hashPubKey, &my_identity.hashPubKey, + &null_hash))) { #if DEBUG_INBOUND fprintf (stderr, "Peer: %s, had inbound connection, ignoring outbound!\n", @@ -1964,13 +1949,11 @@ mark_address_connected (struct ForeignAddressList *fal) #endif return; } - else if ((outbound != NULL) && (0 == fal->addrlen) && ((-1 - == - GNUNET_CRYPTO_hash_xorcmp - (&outbound->ready_list->neighbour-> - id.hashPubKey, - &my_identity.hashPubKey, - &null_hash)))) + else if ((outbound != NULL) && (0 == fal->addrlen) && + ((-1 == + GNUNET_CRYPTO_hash_xorcmp (&outbound->ready_list->neighbour->id. + hashPubKey, &my_identity.hashPubKey, + &null_hash)))) { #if DEBUG_INBOUND fprintf (stderr, "Peer: %s, have outbound connection, ignoring inbound!\n", @@ -1991,22 +1974,20 @@ mark_address_connected (struct ForeignAddressList *fal) pos->addrlen)); #endif #if DEBUG_INBOUND - fprintf (stderr, - "Peer: %s, setting %s connection to disconnected.\n", + fprintf (stderr, "Peer: %s, setting %s connection to disconnected.\n", GNUNET_i2s (&my_identity), (0 == pos->addrlen) ? "INBOUND" : "OUTBOUND"); #endif pos->connected = GNUNET_NO; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connected addresses"), -1, - GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), + -1, GNUNET_NO); } pos = pos->next; } GNUNET_assert (GNUNET_NO == fal->connected); fal->connected = GNUNET_YES; - GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), 1, + GNUNET_NO); } @@ -2044,8 +2025,7 @@ find_ready_address (struct NeighbourMapEntry *neighbour) "Marking long-time inactive connection to `%4s' as down.\n", GNUNET_i2s (&neighbour->id)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connected addresses"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, GNUNET_NO); addresses->connected = GNUNET_NO; } @@ -2059,14 +2039,10 @@ find_ready_address (struct NeighbourMapEntry *neighbour) if (addresses->addr != NULL) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have address `%s' for peer `%4s' (status: %d, %d, %d, %u, %llums, %u)\n", - a2s (head->plugin->short_name, - addresses->addr, - addresses->addrlen), - GNUNET_i2s (&neighbour->id), - addresses->connected, - addresses->in_transmit, - addresses->validated, - addresses->connect_attempts, + a2s (head->plugin->short_name, addresses->addr, + addresses->addrlen), GNUNET_i2s (&neighbour->id), + addresses->connected, addresses->in_transmit, + addresses->validated, addresses->connect_attempts, (unsigned long long) addresses->timeout.abs_value, (unsigned int) addresses->distance); #endif @@ -2077,12 +2053,13 @@ find_ready_address (struct NeighbourMapEntry *neighbour) (addresses->latency.rel_value < unix_address->latency.rel_value))) unix_address = addresses; } - if (((best_address == NULL) || - (addresses->connected == GNUNET_YES) || + if (((best_address == NULL) || (addresses->connected == GNUNET_YES) || (best_address->connected == GNUNET_NO)) && - (addresses->in_transmit == GNUNET_NO) && - ((best_address == NULL) || - (addresses->latency.rel_value < best_address->latency.rel_value))) + (addresses->in_transmit == GNUNET_NO) && ((best_address == NULL) || + (addresses->latency. + rel_value < + best_address->latency. + rel_value))) best_address = addresses; /* FIXME: also give lower-latency addresses that are not * connected a chance some times... */ @@ -2105,11 +2082,11 @@ find_ready_address (struct NeighbourMapEntry *neighbour) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Best address found (`%s') has latency of %llu ms.\n", - (best_address->addrlen > 0) - ? a2s (best_address->ready_list->plugin->short_name, - best_address->addr, - best_address->addrlen) - : "", best_address->latency.rel_value); + (best_address->addrlen > + 0) ? a2s (best_address->ready_list->plugin->short_name, + best_address->addr, + best_address->addrlen) : "", + best_address->latency.rel_value); #endif } else @@ -2154,10 +2131,10 @@ address_generator (void *cls, size_t max, void *buf) return 0; } - ret = GNUNET_HELLO_add_address (gc->plug_pos->short_name, - gc->expiration, - &gc->addr_pos[1], - gc->addr_pos->addrlen, buf, max); + ret = + GNUNET_HELLO_add_address (gc->plug_pos->short_name, gc->expiration, + &gc->addr_pos[1], gc->addr_pos->addrlen, buf, + max); gc->addr_pos = gc->addr_pos->next; return ret; } @@ -2173,8 +2150,8 @@ transmit_our_hello_if_pong (void *cls, const GNUNET_HashCode * key, void *value) return GNUNET_OK; #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Transmitting updated `%s' to neighbour `%4s'\n", - "HELLO", GNUNET_i2s (&npos->id)); + "Transmitting updated `%s' to neighbour `%4s'\n", "HELLO", + GNUNET_i2s (&npos->id)); #endif GNUNET_STATISTICS_update (stats, gettext_noop @@ -2211,15 +2188,14 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Refreshed my `%s', new size is %d\n", "HELLO", GNUNET_HELLO_size (hello)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# refreshed my HELLO"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# refreshed my HELLO"), 1, + GNUNET_NO); cpos = clients; while (cpos != NULL) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting my HELLO to client!\n"); - transmit_to_client (cpos, - (const struct GNUNET_MessageHeader *) hello, GNUNET_NO); + transmit_to_client (cpos, (const struct GNUNET_MessageHeader *) hello, + GNUNET_NO); cpos = cpos->next; } @@ -2320,9 +2296,8 @@ try_fast_reconnect (struct TransportPlugin *p, struct NeighbourMapEntry *nl) /* No reconnect, signal disconnect instead! */ #if DEBUG_TRANSPORT #endif - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&nl->id), - "try_fast_reconnect"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", + GNUNET_i2s (&nl->id), "try_fast_reconnect"); GNUNET_STATISTICS_update (stats, gettext_noop @@ -2346,8 +2321,7 @@ try_fast_reconnect (struct TransportPlugin *p, struct NeighbourMapEntry *nl) * @param session which session is being destoyed */ static void -plugin_env_session_end (void *cls, - const struct GNUNET_PeerIdentity *peer, +plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, struct Session *session) { struct TransportPlugin *p = cls; @@ -2357,8 +2331,7 @@ plugin_env_session_end (void *cls, struct ForeignAddressList *prev; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Session ended with peer `%4s', %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session ended with peer `%4s', %s\n", GNUNET_i2s (peer), "plugin_env_session_end"); #endif GNUNET_CONTAINER_multihashmap_iterate (validation_map, @@ -2435,9 +2408,8 @@ plugin_env_session_end (void *cls, if (GNUNET_YES == pos->connected) { pos->connected = GNUNET_NO; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connected addresses"), - -1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, + GNUNET_NO); } if (GNUNET_SCHEDULER_NO_TASK != pos->revalidate_task) { @@ -2491,16 +2463,15 @@ plugin_env_session_end (void *cls, return; } pos->connected = GNUNET_NO; - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connected addresses"), - -1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, + GNUNET_NO); GNUNET_free (pos); if (nl->received_pong == GNUNET_NO) { GNUNET_STATISTICS_update (stats, - gettext_noop ("# disconnects due to NO pong"), - 1, GNUNET_NO); + gettext_noop ("# disconnects due to NO pong"), 1, + GNUNET_NO); disconnect_neighbour (nl, GNUNET_YES); return; /* nothing to do, never connected... */ } @@ -2522,8 +2493,7 @@ plugin_env_session_end (void *cls, /* no valid addresses left, signal disconnect! */ #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s', %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", GNUNET_i2s (peer), "plugin_env_session_end"); #endif /* FIXME: This doesn't mean there are no addresses left for this PEER, @@ -2553,8 +2523,8 @@ plugin_env_session_end (void *cls, * @param addrlen length of the address */ static void -plugin_env_notify_address (void *cls, - int add_remove, const void *addr, size_t addrlen) +plugin_env_notify_address (void *cls, int add_remove, const void *addr, + size_t addrlen) { struct TransportPlugin *p = cls; struct OwnAddressList *al; @@ -2563,9 +2533,9 @@ plugin_env_notify_address (void *cls, GNUNET_assert (p->api != NULL); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - (add_remove == GNUNET_YES) - ? "Adding `%s':%s to the set of our addresses\n" - : "Removing `%s':%s from the set of our addresses\n", + (add_remove == + GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" : + "Removing `%s':%s from the set of our addresses\n", a2s (p->short_name, addr, addrlen), p->short_name); #endif GNUNET_assert (addr != NULL); @@ -2622,8 +2592,8 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer, "Notifying clients about connection with `%s'\n", GNUNET_i2s (peer)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# peers connected"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), 1, + GNUNET_NO); ats_count = 2; size = @@ -2679,8 +2649,8 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer) "Notifying clients about lost connection to `%s'\n", GNUNET_i2s (peer)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# peers connected"), -1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), -1, + GNUNET_NO); dim.header.size = htons (sizeof (struct DisconnectInfoMessage)); dim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); dim.reserved = htonl (0); @@ -2718,8 +2688,7 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer) * @return NULL if no such entry exists */ static struct ForeignAddressList * -find_peer_address (struct NeighbourMapEntry *neighbour, - const char *tname, +find_peer_address (struct NeighbourMapEntry *neighbour, const char *tname, struct Session *session, const char *addr, uint16_t addrlen) { struct ReadyList *head; @@ -2761,8 +2730,7 @@ find_peer_address (struct NeighbourMapEntry *neighbour, * @return NULL if we do not have a transport plugin for 'tname' */ static struct ForeignAddressList * -add_peer_address (struct NeighbourMapEntry *neighbour, - const char *tname, +add_peer_address (struct NeighbourMapEntry *neighbour, const char *tname, struct Session *session, const char *addr, uint16_t addrlen) { struct ReadyList *head; @@ -2841,11 +2809,13 @@ add_peer_address (struct NeighbourMapEntry *neighbour, GNUNET_malloc (available_quality_metrics * sizeof (struct ATS_quality_entry)); ret->addrlen = addrlen; - ret->expires = GNUNET_TIME_relative_to_absolute + ret->expires = + GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); ret->latency = GNUNET_TIME_relative_get_forever (); ret->distance = -1; - ret->timeout = GNUNET_TIME_relative_to_absolute + ret->timeout = + GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); ret->ready_list = head; ret->next = head->addresses; @@ -2950,8 +2920,7 @@ check_address_exists (void *cls, const GNUNET_HashCode * key, void *value) struct CheckAddressExistsClosure *caec = cls; struct ValidationEntry *ve = value; - if ((0 == strcmp (caec->tname, - ve->transport_name)) && + if ((0 == strcmp (caec->tname, ve->transport_name)) && (caec->addrlen == ve->addrlen) && (0 == memcmp (caec->addr, ve->addr, caec->addrlen))) { @@ -2978,8 +2947,8 @@ neighbour_timeout_task (void *cls, "Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id)); #endif GNUNET_STATISTICS_update (stats, - gettext_noop ("# disconnects due to timeout"), - 1, GNUNET_NO); + gettext_noop ("# disconnects due to timeout"), 1, + GNUNET_NO); n->timeout_task = GNUNET_SCHEDULER_NO_TASK; disconnect_neighbour (n, GNUNET_NO); } @@ -3006,8 +2975,7 @@ static void schedule_next_ping (struct ForeignAddressList *fal); * @return GNUNET_OK (always) */ static int -add_to_foreign_address_list (void *cls, - const char *tname, +add_to_foreign_address_list (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration, const void *addr, uint16_t addrlen) { @@ -3026,8 +2994,8 @@ add_to_foreign_address_list (void *cls, #if DEBUG_TRANSPORT_HELLO GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding address `%s' (%s) for peer `%4s' due to PEERINFO data for %llums.\n", - a2s (tname, addr, addrlen), - tname, GNUNET_i2s (&n->id), expiration.abs_value); + a2s (tname, addr, addrlen), tname, GNUNET_i2s (&n->id), + expiration.abs_value); #endif fal = add_peer_address (n, tname, NULL, addr, addrlen); if (fal == NULL) @@ -3086,8 +3054,7 @@ add_to_foreign_address_list (void *cls, * @param err_msg NULL if successful, otherwise contains error message */ static void -add_hello_for_peer (void *cls, - const struct GNUNET_PeerIdentity *peer, +add_hello_for_peer (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *h, const char *err_msg) { struct NeighbourMapEntry *n = cls; @@ -3122,8 +3089,8 @@ add_hello_for_peer (void *cls, GNUNET_HELLO_get_key (h, &n->publicKey); n->public_key_valid = GNUNET_YES; } - GNUNET_HELLO_iterate_addresses (h, - GNUNET_NO, &add_to_foreign_address_list, n); + GNUNET_HELLO_iterate_addresses (h, GNUNET_NO, &add_to_foreign_address_list, + n); } @@ -3143,15 +3110,15 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, int do_hello) struct TransportPlugin *tp; struct ReadyList *rl; - GNUNET_assert (0 != memcmp (peer, - &my_identity, - sizeof (struct GNUNET_PeerIdentity))); + GNUNET_assert (0 != + memcmp (peer, &my_identity, + sizeof (struct GNUNET_PeerIdentity))); #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Setting up state for neighbour `%4s'\n", GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up state for neighbour `%4s'\n", + GNUNET_i2s (peer)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# active neighbours"), 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"), 1, + GNUNET_NO); n = GNUNET_malloc (sizeof (struct NeighbourMapEntry)); n->id = *peer; n->peer_timeout = @@ -3199,8 +3166,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer, int do_hello) gettext_noop ("# HELLO's sent to new neighbors"), 1, GNUNET_NO); if (NULL != our_hello) - transmit_to_peer (NULL, NULL, 0, - HELLO_ADDRESS_EXPIRATION, + transmit_to_peer (NULL, NULL, 0, HELLO_ADDRESS_EXPIRATION, (const char *) our_hello, GNUNET_HELLO_size (our_hello), GNUNET_NO, n); } @@ -3329,8 +3295,8 @@ static struct BlacklistCheck *bc_tail; * @param cls the 'struct BlacklistCheck*' * @param tc unused */ -static void -do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void do_blacklist_check (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** * Transmit blacklist query to the client. @@ -3401,12 +3367,11 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (bl->bc == NULL) { bl->bc = bc; - bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, - sizeof (struct - BlacklistMessage), - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_blacklist_message, - bc); + bc->th = + GNUNET_SERVER_notify_transmit_ready (bl->client, + sizeof (struct BlacklistMessage), + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_blacklist_message, bc); } } @@ -3425,8 +3390,8 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ static void setup_peer_check_blacklist (const struct GNUNET_PeerIdentity *peer, - int do_hello, - SetupContinuation cont, void *cont_cls) + int do_hello, SetupContinuation cont, + void *cont_cls) { struct NeighbourMapEntry *n; struct BlacklistCheck *bc; @@ -3476,9 +3441,8 @@ confirm_or_drop_neighbour (void *cls, struct NeighbourMapEntry *n) if (n == NULL) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&orig->id), - "confirm_or_drop_neighboUr"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", + GNUNET_i2s (&orig->id), "confirm_or_drop_neighboUr"); #endif GNUNET_STATISTICS_update (stats, gettext_noop ("# disconnects due to blacklist"), @@ -3530,8 +3494,7 @@ test_connection_ok (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ static void -handle_blacklist_init (void *cls, - struct GNUNET_SERVER_Client *client, +handle_blacklist_init (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct Blacklisters *bl; @@ -3567,8 +3530,7 @@ handle_blacklist_init (void *cls, * @param message the actual message */ static void -handle_blacklist_reply (void *cls, - struct GNUNET_SERVER_Client *client, +handle_blacklist_reply (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct BlacklistMessage *msg = @@ -3658,8 +3620,8 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) caec.session = peer_address->session; caec.exists = GNUNET_NO; - GNUNET_CONTAINER_multihashmap_iterate (validation_map, - &check_address_exists, &caec); + GNUNET_CONTAINER_multihashmap_iterate (validation_map, &check_address_exists, + &caec); if (caec.exists == GNUNET_YES) { /* During validation attempts we will likely trigger the other @@ -3669,19 +3631,19 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_TRANSPORT > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Some validation of address `%s' via `%s' for peer `%4s' already in progress.\n", - (peer_address->addr != NULL) - ? a2s (tp->short_name, - peer_address->addr, - peer_address->addrlen) - : "", tp->short_name, GNUNET_i2s (&neighbour->id)); + (peer_address->addr != NULL) ? a2s (tp->short_name, + peer_address->addr, + peer_address-> + addrlen) : "", + tp->short_name, GNUNET_i2s (&neighbour->id)); #endif schedule_next_ping (peer_address); return; } va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen); va->transport_name = GNUNET_strdup (tp->short_name); - va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, - UINT_MAX); + va->challenge = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX); va->send_time = GNUNET_TIME_absolute_get (); va->session = peer_address->session; if (peer_address->addr != NULL) @@ -3690,15 +3652,13 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) memcpy (&va[1], peer_address->addr, peer_address->addrlen); va->addrlen = peer_address->addrlen; } - memcpy (&va->publicKey, - &neighbour->publicKey, + memcpy (&va->publicKey, &neighbour->publicKey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); - va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, - &timeout_hello_validation, - va); - GNUNET_CONTAINER_multihashmap_put (validation_map, - &neighbour->id.hashPubKey, + va->timeout_task = + GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, + &timeout_hello_validation, va); + GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->id.hashPubKey, va, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); @@ -3729,8 +3689,9 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (peer_address->addr != NULL) { - ping.header.size = htons (sizeof (struct TransportPingMessage) + - peer_address->addrlen + slen); + ping.header.size = + htons (sizeof (struct TransportPingMessage) + peer_address->addrlen + + slen); memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], tp->short_name, slen); memcpy (&message_buf @@ -3742,19 +3703,18 @@ send_periodic_ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ping.header.size = htons (sizeof (struct TransportPingMessage)); } - memcpy (&message_buf[hello_size], - &ping, sizeof (struct TransportPingMessage)); + memcpy (&message_buf[hello_size], &ping, + sizeof (struct TransportPingMessage)); #if DEBUG_TRANSPORT_REVALIDATION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Performing re-validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s'\n", - (peer_address->addr != NULL) - ? a2s (peer_address->plugin->short_name, - peer_address->addr, - peer_address->addrlen) - : "", - tp->short_name, - GNUNET_i2s (&neighbour->id), "HELLO", hello_size, "PING"); + (peer_address->addr != + NULL) ? a2s (peer_address->plugin->short_name, + peer_address->addr, + peer_address->addrlen) : "", + tp->short_name, GNUNET_i2s (&neighbour->id), "HELLO", hello_size, + "PING"); #endif if (peer_address->validated != GNUNET_YES) GNUNET_STATISTICS_update (stats, @@ -3804,8 +3764,9 @@ schedule_next_ping (struct ForeignAddressList *fal) if (GNUNET_YES == fal->connected) { - delay = GNUNET_TIME_relative_min (delay, - CONNECTED_LATENCY_EVALUATION_MAX_DELAY); + delay = + GNUNET_TIME_relative_min (delay, + CONNECTED_LATENCY_EVALUATION_MAX_DELAY); } /* FIXME: also adjust delay based on how close the last * observed latency is to the latency of the best alternative */ @@ -3816,9 +3777,8 @@ schedule_next_ping (struct ForeignAddressList *fal) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); GNUNET_assert (fal->revalidate_task == GNUNET_SCHEDULER_NO_TASK); - fal->revalidate_task = GNUNET_SCHEDULER_add_delayed (delay, - &send_periodic_ping, - fal); + fal->revalidate_task = + GNUNET_SCHEDULER_add_delayed (delay, &send_periodic_ping, fal); } @@ -3845,8 +3805,8 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u and size %u from `%4s', but no pong yet!\n", - ntohs (message->type), - ntohs (message->size), GNUNET_i2s (&n->id)); + ntohs (message->type), ntohs (message->size), + GNUNET_i2s (&n->id)); #endif GNUNET_free_non_null (n->pre_connect_message_buffer); n->pre_connect_message_buffer = GNUNET_malloc (msize); @@ -3857,11 +3817,11 @@ handle_payload_message (const struct GNUNET_MessageHeader *message, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u and size %u from `%4s', sending to all clients.\n", - ntohs (message->type), - ntohs (message->size), GNUNET_i2s (&n->id)); + ntohs (message->type), ntohs (message->size), + GNUNET_i2s (&n->id)); #endif - if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, - (ssize_t) msize)) + if (GNUNET_YES == + GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, (ssize_t) msize)) { n->quota_violation_count++; #if DEBUG_TRANSPORT @@ -3956,12 +3916,10 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) addr = (const char *) &pong[1]; slen = strlen (ve->transport_name) + 1; if ((ps - sizeof (struct TransportPongMessage) < slen) || - (ve->challenge != challenge) || - (addr[slen - 1] != '\0') || + (ve->challenge != challenge) || (addr[slen - 1] != '\0') || (0 != strcmp (addr, ve->transport_name)) || - (ntohl (pong->purpose.size) - != sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + - sizeof (uint32_t) + + (ntohl (pong->purpose.size) != + sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + sizeof (struct GNUNET_PeerIdentity) + ps - sizeof (struct TransportPongMessage))) @@ -3985,8 +3943,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) } if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, - &pong->purpose, - &pong->signature, &ve->publicKey)) + &pong->purpose, &pong->signature, + &ve->publicKey)) { GNUNET_break_op (0); return GNUNET_NO; @@ -3995,15 +3953,14 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Confirmed validity of address, peer `%4s' has address `%s' (%s).\n", - GNUNET_h2s (key), - a2s (ve->transport_name, - (const struct sockaddr *) ve->addr, - ve->addrlen), ve->transport_name); + GNUNET_h2s (key), a2s (ve->transport_name, + (const struct sockaddr *) ve->addr, + ve->addrlen), ve->transport_name); #endif break; case GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING: - if (0 != memcmp (&pong->pid, - &my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (&pong->pid, &my_identity, sizeof (struct GNUNET_PeerIdentity))) { char *peer; @@ -4050,8 +4007,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) } if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING, - &pong->purpose, - &pong->signature, &ve->publicKey)) + &pong->purpose, &pong->signature, + &ve->publicKey)) { GNUNET_break_op (0); return GNUNET_NO; @@ -4060,9 +4017,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Confirmed that peer `%4s' is talking to us using address `%s' (%s) for us.\n", - GNUNET_h2s (key), - a2s (ve->transport_name, - &addr[slen], alen), ve->transport_name); + GNUNET_h2s (key), a2s (ve->transport_name, &addr[slen], alen), + ve->transport_name); #endif break; default: @@ -4077,8 +4033,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) return GNUNET_NO; } GNUNET_STATISTICS_update (stats, - gettext_noop ("# address validation successes"), - 1, GNUNET_NO); + gettext_noop ("# address validation successes"), 1, + GNUNET_NO); /* create the updated HELLO */ GNUNET_CRYPTO_hash (&ve->publicKey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), @@ -4096,9 +4052,9 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) { n->publicKey = ve->publicKey; n->public_key_valid = GNUNET_YES; - fal = add_peer_address (n, - ve->transport_name, - ve->session, ve->addr, ve->addrlen); + fal = + add_peer_address (n, ve->transport_name, ve->session, ve->addr, + ve->addrlen); GNUNET_assert (fal != NULL); fal->expires = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); fal->validated = GNUNET_YES; @@ -4109,9 +4065,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_NO); fal->latency = GNUNET_TIME_absolute_get_duration (ve->send_time); update_addr_value (fal, - GNUNET_TIME_absolute_get_duration (ve-> - send_time).rel_value, - GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); + GNUNET_TIME_absolute_get_duration (ve->send_time). + rel_value, GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); schedule_next_ping (fal); if (n->latency.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) @@ -4142,8 +4097,8 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) /* clean up validation entry */ GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (validation_map, - key, ve)); + GNUNET_CONTAINER_multihashmap_remove (validation_map, key, + ve)); abort_validation (NULL, NULL, ve); return GNUNET_NO; } @@ -4166,26 +4121,24 @@ check_pending_validation (void *cls, const GNUNET_HashCode * key, void *value) */ static void handle_pong (void *cls, const struct GNUNET_MessageHeader *message, - const struct GNUNET_PeerIdentity *peer, - const char *sender_address, size_t sender_address_len) + const struct GNUNET_PeerIdentity *peer, const char *sender_address, + size_t sender_address_len) { if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) { /* PONG send to self, ignore */ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving `%s' message from myself\n", "PONG"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from myself\n", + "PONG"); return; } #if DEBUG_TRANSPORT > 1 /* we get tons of these that just get discarded, only log * if we are quite verbose */ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving `%s' message from `%4s'.\n", "PONG", - GNUNET_i2s (peer)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message from `%4s'.\n", + "PONG", GNUNET_i2s (peer)); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# PONG messages received"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages received"), 1, + GNUNET_NO); if (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple (validation_map, &peer->hashPubKey, @@ -4241,9 +4194,9 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) } neighbour->publicKey = va->publicKey; neighbour->public_key_valid = GNUNET_YES; - peer_address = add_peer_address (neighbour, - va->transport_name, NULL, - (const void *) &va[1], va->addrlen); + peer_address = + add_peer_address (neighbour, va->transport_name, NULL, + (const void *) &va[1], va->addrlen); if (peer_address == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -4268,8 +4221,8 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); memcpy (&ping.target, &neighbour->id, sizeof (struct GNUNET_PeerIdentity)); memcpy (message_buf, our_hello, hello_size); - memcpy (&message_buf[hello_size], - &ping, sizeof (struct TransportPingMessage)); + memcpy (&message_buf[hello_size], &ping, + sizeof (struct TransportPingMessage)); memcpy (&message_buf[hello_size + sizeof (struct TransportPingMessage)], va->transport_name, slen); memcpy (&message_buf @@ -4278,14 +4231,11 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Performing validation of address `%s' via `%s' for peer `%4s' sending `%s' (%u bytes) and `%s' (%u bytes)\n", - (va->addrlen == 0) - ? "" - : a2s (va->transport_name, - (const void *) &va[1], va->addrlen), - va->transport_name, - GNUNET_i2s (&neighbour->id), - "HELLO", hello_size, - "PING", + (va->addrlen == 0) ? "" : a2s (va->transport_name, + (const void *) &va[1], + va->addrlen), + va->transport_name, GNUNET_i2s (&neighbour->id), "HELLO", + hello_size, "PING", sizeof (struct TransportPingMessage) + va->addrlen + slen); #endif @@ -4313,10 +4263,9 @@ transmit_hello_and_ping (void *cls, struct NeighbourMapEntry *neighbour) * @return GNUNET_OK (always) */ static int -run_validation (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +run_validation (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { struct CheckHelloValidatedContext *chvc = cls; struct GNUNET_PeerIdentity id; @@ -4335,8 +4284,7 @@ run_validation (void *cls, tp = find_transport (tname); if (tp == NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO | - GNUNET_ERROR_TYPE_BULK, + GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, _ ("Transport `%s' not loaded, will not try to validate peer address using this transport.\n"), tname); @@ -4363,8 +4311,7 @@ run_validation (void *cls, } GNUNET_HELLO_get_key (chvc->hello, &pk); GNUNET_CRYPTO_hash (&pk, - sizeof (struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &id.hashPubKey); if (is_blacklisted (&id, tp)) @@ -4382,8 +4329,8 @@ run_validation (void *cls, caec.session = NULL; caec.tname = tname; caec.exists = GNUNET_NO; - GNUNET_CONTAINER_multihashmap_iterate (validation_map, - &check_address_exists, &caec); + GNUNET_CONTAINER_multihashmap_iterate (validation_map, &check_address_exists, + &caec); if (caec.exists == GNUNET_YES) { /* During validation attempts we will likely trigger the other @@ -4405,19 +4352,17 @@ run_validation (void *cls, va->chvc = chvc; chvc->ve_count++; va->transport_name = GNUNET_strdup (tname); - va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, - UINT_MAX); + va->challenge = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT_MAX); va->send_time = GNUNET_TIME_absolute_get (); va->addr = (const void *) &va[1]; memcpy (&va[1], addr, addrlen); va->addrlen = addrlen; GNUNET_HELLO_get_key (chvc->hello, &va->publicKey); - va->timeout_task = GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, - &timeout_hello_validation, - va); - GNUNET_CONTAINER_multihashmap_put (validation_map, - &id.hashPubKey, - va, + va->timeout_task = + GNUNET_SCHEDULER_add_delayed (HELLO_VERIFICATION_TIMEOUT, + &timeout_hello_validation, va); + GNUNET_CONTAINER_multihashmap_put (validation_map, &id.hashPubKey, va, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); setup_peer_check_blacklist (&id, GNUNET_NO, &transmit_hello_and_ping, va); return GNUNET_OK; @@ -4434,8 +4379,7 @@ run_validation (void *cls, * @param err_msg NULL if successful, otherwise contains error message */ static void -check_hello_validated (void *cls, - const struct GNUNET_PeerIdentity *peer, +check_hello_validated (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *h, const char *err_msg) { @@ -4515,8 +4459,8 @@ check_hello_validated (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling hello_iterate_addresses for %s!\n", GNUNET_i2s (peer)); #endif - GNUNET_HELLO_iterate_addresses (h, - GNUNET_NO, &add_to_foreign_address_list, n); + GNUNET_HELLO_iterate_addresses (h, GNUNET_NO, &add_to_foreign_address_list, + n); try_transmission_to_peer (n); } else @@ -4533,8 +4477,7 @@ check_hello_validated (void *cls, GNUNET_STATISTICS_update (stats, gettext_noop ("# HELLO validations (update case)"), 1, GNUNET_NO); - GNUNET_HELLO_iterate_new_addresses (chvc->hello, - h, + GNUNET_HELLO_iterate_new_addresses (chvc->hello, h, GNUNET_TIME_relative_to_absolute (HELLO_REVALIDATION_START_TIME), &run_validation, chvc); @@ -4579,8 +4522,8 @@ process_hello (struct TransportPlugin *plugin, { #if DEBUG_TRANSPORT_HELLO GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Unable to get public key from `%s' for `%4s'!\n", - "HELLO", GNUNET_i2s (&target)); + "Unable to get public key from `%s' for `%4s'!\n", "HELLO", + GNUNET_i2s (&target)); #endif GNUNET_break_op (0); return GNUNET_SYSERR; @@ -4590,8 +4533,7 @@ process_hello (struct TransportPlugin *plugin, &target.hashPubKey); #if DEBUG_TRANSPORT_HELLO - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' message for `%4s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for `%4s'\n", "HELLO", GNUNET_i2s (&target)); #endif if (0 == memcmp (&my_identity, &target, sizeof (struct GNUNET_PeerIdentity))) @@ -4619,8 +4561,8 @@ process_hello (struct TransportPlugin *plugin, GNUNET_NO); #if DEBUG_TRANSPORT_HELLO GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Ignoring `%s' for `%4s', load too high.\n", - "HELLO", GNUNET_i2s (&target)); + "Ignoring `%s' for `%4s', load too high.\n", "HELLO", + GNUNET_i2s (&target)); #endif return GNUNET_OK; } @@ -4629,9 +4571,8 @@ process_hello (struct TransportPlugin *plugin, chvc = chvc_head; while (NULL != chvc) { - if (GNUNET_HELLO_equals (hello, - chvc->hello, - GNUNET_TIME_absolute_get ()).abs_value > 0) + if (GNUNET_HELLO_equals (hello, chvc->hello, GNUNET_TIME_absolute_get ()). + abs_value > 0) { #if DEBUG_TRANSPORT_HELLO > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -4641,8 +4582,8 @@ process_hello (struct TransportPlugin *plugin, return GNUNET_OK; /* validation already pending */ } if (GNUNET_HELLO_size (hello) == GNUNET_HELLO_size (chvc->hello)) - GNUNET_break (0 != memcmp (hello, chvc->hello, - GNUNET_HELLO_size (hello))); + GNUNET_break (0 != + memcmp (hello, chvc->hello, GNUNET_HELLO_size (hello))); chvc = chvc->next; } @@ -4663,10 +4604,8 @@ process_hello (struct TransportPlugin *plugin, my_id = GNUNET_strdup (GNUNET_i2s (plugin->env.my_identity)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Starting validation of `%s' message for `%4s' via '%s' of size %u\n", - my_id, - "HELLO", - GNUNET_i2s (&target), - plugin->short_name, GNUNET_HELLO_size (hello)); + my_id, "HELLO", GNUNET_i2s (&target), plugin->short_name, + GNUNET_HELLO_size (hello)); GNUNET_free (my_id); #endif } @@ -4768,8 +4707,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) rpos->addresses = peer_pos->next; if (peer_pos->connected == GNUNET_YES) { - GNUNET_STATISTICS_update (stats, - gettext_noop ("# connected addresses"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# connected addresses"), -1, GNUNET_NO); peer_pos->connected = GNUNET_NO; } @@ -4804,8 +4742,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) ("# bytes discarded due to disconnect"), mq->message_buf_size, GNUNET_NO); GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq); - GNUNET_assert (0 == memcmp (&mq->neighbour_id, - &n->id, sizeof (struct GNUNET_PeerIdentity))); + GNUNET_assert (0 == + memcmp (&mq->neighbour_id, &n->id, + sizeof (struct GNUNET_PeerIdentity))); GNUNET_free (mq); } @@ -4813,8 +4752,9 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) { GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq); - GNUNET_assert (0 == memcmp (&mq->neighbour_id, - &n->id, sizeof (struct GNUNET_PeerIdentity))); + GNUNET_assert (0 == + memcmp (&mq->neighbour_id, &n->id, + sizeof (struct GNUNET_PeerIdentity))); GNUNET_free (mq); } @@ -4842,9 +4782,8 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) GNUNET_CONTAINER_multihashmap_remove (neighbours, &n->id.hashPubKey, n)); /* finally, free n itself */ - GNUNET_STATISTICS_update (stats, - gettext_noop ("# active neighbours"), - -1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# active neighbours"), -1, + GNUNET_NO); GNUNET_free_non_null (n->pre_connect_message_buffer); GNUNET_free (n); } @@ -4856,8 +4795,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n, int check) */ static int handle_ping (void *cls, const struct GNUNET_MessageHeader *message, - const struct GNUNET_PeerIdentity *peer, - struct Session *session, + const struct GNUNET_PeerIdentity *peer, struct Session *session, const char *sender_address, uint16_t sender_address_len) { struct TransportPlugin *plugin = cls; @@ -4880,9 +4818,9 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, } ping = (struct TransportPingMessage *) message; - if (0 != memcmp (&ping->target, - plugin->env.my_identity, - sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (&ping->target, plugin->env.my_identity, + sizeof (struct GNUNET_PeerIdentity))) { #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -4898,16 +4836,15 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, } #if DEBUG_PING_PONG GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, - "Processing `%s' from `%s'\n", - "PING", - (sender_address != NULL) - ? a2s (plugin->short_name, - (const struct sockaddr *) sender_address, - sender_address_len) : ""); + "Processing `%s' from `%s'\n", "PING", + (sender_address != NULL) ? a2s (plugin->short_name, + (const struct sockaddr *) + sender_address, + sender_address_len) : + ""); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# PING messages received"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, gettext_noop ("# PING messages received"), 1, + GNUNET_NO); addr = (const char *) &ping[1]; alen = ntohs (message->size) - sizeof (struct TransportPingMessage); slen = strlen (plugin->short_name) + 1; @@ -4930,8 +4867,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating PONG indicating that we received a connection at our address `%s' from `%s'.\n", - a2s (plugin->short_name, - sender_address, sender_address_len), GNUNET_i2s (peer)); + a2s (plugin->short_name, sender_address, sender_address_len), + GNUNET_i2s (peer)); pong = GNUNET_malloc (sizeof (struct TransportPongMessage) + @@ -4942,8 +4879,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); pong->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + - sizeof (uint32_t) + - sizeof (struct GNUNET_TIME_AbsoluteNBO) + + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + sizeof (struct GNUNET_PeerIdentity) + sender_address_len + slen); pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING); @@ -4953,9 +4889,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, memcpy (&pong[1], plugin->short_name, slen); if ((sender_address != NULL) && (sender_address_len > 0)) memcpy (&((char *) &pong[1])[slen], sender_address, sender_address_len); - if (GNUNET_TIME_absolute_get_remaining - (session_header->pong_sig_expires).rel_value < - PONG_SIGNATURE_LIFETIME.rel_value / 4) + if (GNUNET_TIME_absolute_get_remaining (session_header->pong_sig_expires). + rel_value < PONG_SIGNATURE_LIFETIME.rel_value / 4) { /* create / update cached sig */ #if DEBUG_TRANSPORT @@ -4975,8 +4910,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, pong->expiration = GNUNET_TIME_absolute_hton (session_header->pong_sig_expires); } - memcpy (&pong->signature, - &session_header->pong_signature, + memcpy (&pong->signature, &session_header->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); @@ -5007,8 +4941,7 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); pong->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + - sizeof (uint32_t) + - sizeof (struct GNUNET_TIME_AbsoluteNBO) + + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + sizeof (struct GNUNET_PeerIdentity) + alen + slen); pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); pong->challenge = ping->challenge; @@ -5029,11 +4962,10 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (my_private_key, - &pong->purpose, + GNUNET_CRYPTO_rsa_sign (my_private_key, &pong->purpose, &oal->pong_signature)); - memcpy (&pong->signature, - &oal->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); + memcpy (&pong->signature, &oal->pong_signature, + sizeof (struct GNUNET_CRYPTO_RsaSignature)); } else if (oal == NULL) { @@ -5049,8 +4981,8 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, { /* can used cached version */ pong->expiration = GNUNET_TIME_absolute_hton (oal->pong_sig_expires); - memcpy (&pong->signature, - &oal->pong_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); + memcpy (&pong->signature, &oal->pong_signature, + sizeof (struct GNUNET_CRYPTO_RsaSignature)); } } n = find_neighbour (peer); @@ -5063,15 +4995,13 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, fal = rl->addresses; while (fal != NULL) { - if (-1 != rl->plugin->api->send (rl->plugin->api->cls, - peer, - (const char *) pong, - ntohs (pong->header.size), - TRANSPORT_PONG_PRIORITY, - HELLO_VERIFICATION_TIMEOUT, - fal->session, - fal->addr, - fal->addrlen, GNUNET_SYSERR, NULL, NULL)) + if (-1 != + rl->plugin->api->send (rl->plugin->api->cls, peer, + (const char *) pong, ntohs (pong->header.size), + TRANSPORT_PONG_PRIORITY, + HELLO_VERIFICATION_TIMEOUT, fal->session, + fal->addr, fal->addrlen, GNUNET_SYSERR, NULL, + NULL)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitted PONG to `%s' via reliable mechanism\n", @@ -5102,13 +5032,11 @@ handle_ping (void *cls, const struct GNUNET_MessageHeader *message, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting PONG to `%s' via unreliable mechanism `%s':%s\n", - GNUNET_i2s (peer), - a2s (rl->plugin->short_name, - fal->addr, fal->addrlen), rl->plugin->short_name); - transmit_to_peer (NULL, fal, - TRANSPORT_PONG_PRIORITY, - HELLO_VERIFICATION_TIMEOUT, - (const char *) pong, + GNUNET_i2s (peer), a2s (rl->plugin->short_name, fal->addr, + fal->addrlen), + rl->plugin->short_name); + transmit_to_peer (NULL, fal, TRANSPORT_PONG_PRIORITY, + HELLO_VERIFICATION_TIMEOUT, (const char *) pong, ntohs (pong->header.size), GNUNET_YES, n); did_pong = GNUNET_YES; fal = fal->next; @@ -5146,8 +5074,7 @@ static struct GNUNET_TIME_Relative plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats_data, - uint32_t ats_count, - struct Session *session, + uint32_t ats_count, struct Session *session, const char *sender_address, uint16_t sender_address_len) { struct TransportPlugin *plugin = cls; @@ -5185,10 +5112,9 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, if (message != NULL) { if ((session != NULL) || (sender_address != NULL)) - peer_address = add_peer_address (n, - plugin->short_name, - session, - sender_address, sender_address_len); + peer_address = + add_peer_address (n, plugin->short_name, session, sender_address, + sender_address_len); if (peer_address != NULL) { update_addr_ats (peer_address, ats_data, ats_count); @@ -5216,8 +5142,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_SCHEDULER_add_now (&send_periodic_ping, peer_address); } - peer_address->timeout - = + peer_address->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); } @@ -5239,8 +5164,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, if (n->quota_violation_count > QUOTA_VIOLATION_DROP_THRESHOLD) { /* dropping message due to frequent inbound volume violations! */ - GNUNET_log (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _ ("Dropping incoming message due to repeated bandwidth quota (%u b/s) violations (total of %u).\n"), n->in_tracker.available_bytes_per_s__, @@ -5277,8 +5201,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, #if DEBUG_PING_PONG GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u and size %u from `%4s', sending to all clients.\n", - ntohs (message->type), - ntohs (message->size), GNUNET_i2s (peer)); + ntohs (message->type), ntohs (message->size), + GNUNET_i2s (peer)); #endif switch (ntohs (message->type)) { @@ -5311,13 +5235,12 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", - (unsigned long long) n-> - in_tracker.consumption_since_last_update__, + (unsigned long long) n->in_tracker. + consumption_since_last_update__, (unsigned int) n->in_tracker.available_bytes_per_s__, (unsigned long long) ret.rel_value); #endif - GNUNET_STATISTICS_update (stats, - gettext_noop ("# ms throttling suggested"), + GNUNET_STATISTICS_update (stats, gettext_noop ("# ms throttling suggested"), (int64_t) ret.rel_value, GNUNET_NO); } return ret; @@ -5325,8 +5248,8 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, static int -notify_client_about_neighbour (void *cls, - const GNUNET_HashCode * key, void *value) +notify_client_about_neighbour (void *cls, const GNUNET_HashCode * key, + void *value) { struct TransportClient *c = cls; struct NeighbourMapEntry *n = value; @@ -5371,8 +5294,7 @@ notify_client_about_neighbour (void *cls, * @param message the actual message */ static void -handle_start (void *cls, - struct GNUNET_SERVER_Client *client, +handle_start (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct StartMessage *start; @@ -5380,8 +5302,8 @@ handle_start (void *cls, start = (const struct StartMessage *) message; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received `%s' request from client\n", "START"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client\n", + "START"); #endif c = clients; while (c != NULL) @@ -5396,8 +5318,9 @@ handle_start (void *cls, c = c->next; } if ((GNUNET_NO != ntohl (start->do_check)) && - (0 != memcmp (&start->self, - &my_identity, sizeof (struct GNUNET_PeerIdentity)))) + (0 != + memcmp (&start->self, &my_identity, + sizeof (struct GNUNET_PeerIdentity)))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -5413,11 +5336,10 @@ handle_start (void *cls, if (our_hello != NULL) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending our own `%s' to new client\n", "HELLO"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending our own `%s' to new client\n", + "HELLO"); #endif - transmit_to_client (c, - (const struct GNUNET_MessageHeader *) our_hello, + transmit_to_client (c, (const struct GNUNET_MessageHeader *) our_hello, GNUNET_NO); /* tell new client about all existing connections */ GNUNET_CONTAINER_multihashmap_iterate (neighbours, @@ -5443,15 +5365,14 @@ handle_start (void *cls, * @param message the actual message */ static void -handle_hello (void *cls, - struct GNUNET_SERVER_Client *client, +handle_hello (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { int ret; GNUNET_STATISTICS_update (stats, - gettext_noop ("# HELLOs received from clients"), - 1, GNUNET_NO); + gettext_noop ("# HELLOs received from clients"), 1, + GNUNET_NO); ret = process_hello (NULL, message); GNUNET_SERVER_receive_done (client, ret); } @@ -5521,8 +5442,7 @@ transmit_client_message (void *cls, struct NeighbourMapEntry *n) * @param message the actual message */ static void -handle_send (void *cls, - struct GNUNET_SERVER_Client *client, +handle_send (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct OutboundMessage *obm; @@ -5560,8 +5480,8 @@ handle_send (void *cls, /* FIXME: this memcpy can be up to 7% of our total runtime */ memcpy (&tcmc[1], obmm, msize); GNUNET_SERVER_client_keep (client); - setup_peer_check_blacklist (&obm->peer, GNUNET_YES, - &transmit_client_message, tcmc); + setup_peer_check_blacklist (&obm->peer, GNUNET_YES, &transmit_client_message, + tcmc); } @@ -5573,8 +5493,7 @@ handle_send (void *cls, * @param message the actual message */ static void -handle_request_connect (void *cls, - struct GNUNET_SERVER_Client *client, +handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct TransportRequestConnectMessage *trcm = @@ -5602,16 +5521,15 @@ handle_request_connect (void *cls, * @param message the actual message */ static void -handle_set_quota (void *cls, - struct GNUNET_SERVER_Client *client, +handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct QuotaSetMessage *qsm = (const struct QuotaSetMessage *) message; struct NeighbourMapEntry *n; GNUNET_STATISTICS_update (stats, - gettext_noop ("# SET QUOTA messages received"), - 1, GNUNET_NO); + gettext_noop ("# SET QUOTA messages received"), 1, + GNUNET_NO); n = find_neighbour (&qsm->peer); if (n == NULL) { @@ -5625,8 +5543,7 @@ handle_set_quota (void *cls, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request (new quota %u, old quota %u) from client for peer `%4s'\n", - "SET_QUOTA", - (unsigned int) ntohl (qsm->quota.value__), + "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__), (unsigned int) n->in_tracker.available_bytes_per_s__, GNUNET_i2s (&qsm->peer)); #endif @@ -5634,9 +5551,8 @@ handle_set_quota (void *cls, if (0 == ntohl (qsm->quota.value__)) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&n->id), - "SET_QUOTA"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", + GNUNET_i2s (&n->id), "SET_QUOTA"); #endif GNUNET_STATISTICS_update (stats, gettext_noop ("# disconnects due to quota of 0"), @@ -5683,8 +5599,7 @@ transmit_address_to_client (void *cls, const char *address) * @param message the actual message */ static void -handle_address_lookup (void *cls, - struct GNUNET_SERVER_Client *client, +handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct AddressLookupMessage *alum; @@ -5734,11 +5649,8 @@ handle_address_lookup (void *cls, } GNUNET_SERVER_disable_receive_done_warning (client); tc = GNUNET_SERVER_transmit_context_create (client); - lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, - nameTransport, - address, addressLen, - numeric, - rtimeout, + lsPlugin->api->address_pretty_printer (lsPlugin->api->cls, nameTransport, + address, addressLen, numeric, rtimeout, &transmit_address_to_client, tc); } @@ -5750,8 +5662,7 @@ handle_address_lookup (void *cls, * @param message the actual message */ static void -handle_peer_address_lookup (void *cls, - struct GNUNET_SERVER_Client *client, +handle_peer_address_lookup (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct PeerAddressLookupMessage *peer_address_lookup; @@ -5804,22 +5715,20 @@ handle_peer_address_lookup (void *cls, a2s (transport_plugin->short_name, foreign_address_iterator->addr, foreign_address_iterator->addrlen), - (foreign_address_iterator->connected - == GNUNET_YES) ? "CONNECTED" - : "DISCONNECTED", - (foreign_address_iterator->validated - == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); + (foreign_address_iterator->connected == + GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", + (foreign_address_iterator->validated == + GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); transmit_address_to_client (tc, addr_buf); GNUNET_free (addr_buf); } else if (foreign_address_iterator->addrlen == 0) { GNUNET_asprintf (&addr_buf, "%s --- %s, %s", "", - (foreign_address_iterator->connected - == GNUNET_YES) ? "CONNECTED" - : "DISCONNECTED", - (foreign_address_iterator->validated - == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); + (foreign_address_iterator->connected == + GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", + (foreign_address_iterator->validated == + GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); transmit_address_to_client (tc, addr_buf); GNUNET_free (addr_buf); } @@ -5859,24 +5768,21 @@ output_addresses (void *cls, const GNUNET_HashCode * key, void *value) a2s (transport_plugin->short_name, foreign_address_iterator->addr, foreign_address_iterator->addrlen), - (foreign_address_iterator->connected - == GNUNET_YES) ? "CONNECTED" - : "DISCONNECTED", - (foreign_address_iterator->validated - == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); + (foreign_address_iterator->connected == + GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", + (foreign_address_iterator->validated == + GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); transmit_address_to_client (tc, addr_buf); GNUNET_free (addr_buf); } else if (foreign_address_iterator->addrlen == 0) { GNUNET_asprintf (&addr_buf, "%s:%s --- %s, %s", - GNUNET_i2s (&neighbor_iterator->id), - "", - (foreign_address_iterator->connected - == GNUNET_YES) ? "CONNECTED" - : "DISCONNECTED", - (foreign_address_iterator->validated - == GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); + GNUNET_i2s (&neighbor_iterator->id), "", + (foreign_address_iterator->connected == + GNUNET_YES) ? "CONNECTED" : "DISCONNECTED", + (foreign_address_iterator->validated == + GNUNET_YES) ? "VALIDATED" : "UNVALIDATED"); transmit_address_to_client (tc, addr_buf); GNUNET_free (addr_buf); } @@ -5897,8 +5803,7 @@ output_addresses (void *cls, const GNUNET_HashCode * key, void *value) * @param message the actual message */ static void -handle_address_iterate (void *cls, - struct GNUNET_SERVER_Client *client, +handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_SERVER_TransmitContext *tc; @@ -5954,8 +5859,8 @@ start_transport (struct GNUNET_SERVER_Handle *server, const char *name) struct TransportPlugin *plug; char *libname; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' transport plugin\n"), name); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), + name); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", name); plug = GNUNET_malloc (sizeof (struct TransportPlugin)); create_environment (plug); @@ -6062,8 +5967,8 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) GNUNET_free (mqe); } if (NULL != neighbours) - GNUNET_CONTAINER_multihashmap_iterate (neighbours, - &null_mq_client_pointers, pos); + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &null_mq_client_pointers, + pos); if (prev == NULL) clients = pos->next; else @@ -6089,8 +5994,7 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value) struct NeighbourMapEntry *n = value; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s', %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); #endif disconnect_neighbour (n, GNUNET_NO); @@ -6113,8 +6017,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct CheckHelloValidatedContext *chvc; shutdown_in_progress = GNUNET_YES; - GNUNET_CONTAINER_multihashmap_iterate (neighbours, - &disconnect_all_neighbours, NULL); + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours, + NULL); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport service is unloading plugins...\n"); @@ -6141,8 +6045,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CRYPTO_rsa_key_free (my_private_key); GNUNET_free_non_null (our_hello); - GNUNET_CONTAINER_multihashmap_iterate (validation_map, - &abort_validation, NULL); + GNUNET_CONTAINER_multihashmap_iterate (validation_map, &abort_validation, + NULL); GNUNET_CONTAINER_multihashmap_destroy (validation_map); validation_map = NULL; @@ -6290,8 +6194,8 @@ setup_ats_problem (void *cls, const GNUNET_HashCode * key, void *value) static void -create_ats_information (struct ATS_peer **p, - int *c_p, struct ATS_mechanism **m, int *c_m) +create_ats_information (struct ATS_peer **p, int *c_p, struct ATS_mechanism **m, + int *c_m) { struct AtsBuildContext abc; @@ -6301,8 +6205,8 @@ create_ats_information (struct ATS_peer **p, #endif abc.c_peers = 0; abc.c_mechs = 0; - GNUNET_CONTAINER_multihashmap_iterate (neighbours, - &find_and_count_addresses, &abc); + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &find_and_count_addresses, + &abc); #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found %u peers with % u transport mechanisms\n", c_peers, @@ -6369,8 +6273,8 @@ schedule_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif last_ats_execution = GNUNET_TIME_absolute_get (); - ats_task = GNUNET_SCHEDULER_add_delayed (ats_regular_interval, - &schedule_ats, ats); + ats_task = + GNUNET_SCHEDULER_add_delayed (ats_regular_interval, &schedule_ats, ats); } #endif @@ -6390,8 +6294,7 @@ get_preferred_ats_address (struct NeighbourMapEntry *n) * @param c configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -6436,14 +6339,11 @@ run (void *cls, neighbours = GNUNET_CONTAINER_multihashmap_create (256); /* parse configuration */ if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "TRANSPORT", - "NEIGHBOUR_LIMIT", + GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", &tneigh)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", - "HOSTKEY", &keyfile))) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -6499,18 +6399,18 @@ run (void *cls, return; } GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); - GNUNET_CRYPTO_hash (&my_public_key, - sizeof (my_public_key), &my_identity.hashPubKey); + GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), + &my_identity.hashPubKey); /* setup notification */ - GNUNET_SERVER_disconnect_notify (server, - &client_disconnect_notification, NULL); + GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification, + NULL); /* load plugins... */ no_transports = 1; if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (c, "TRANSPORT", "PLUGINS", &plugs)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Starting transport plugins `%s'\n"), plugs); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"), + plugs); pos = strtok (plugs, " "); while (pos != NULL) { @@ -6520,8 +6420,8 @@ run (void *cls, } GNUNET_free (plugs); } - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + NULL); if (no_transports) refresh_hello (); @@ -6547,9 +6447,9 @@ run (void *cls, GNUNET_asprintf (§ion, "%s_UP", ressources[co].cfg_param); if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) { - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, - "transport", - section, &value)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "transport", section, + &value)) { #if DEBUG_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -6562,9 +6462,9 @@ run (void *cls, GNUNET_asprintf (§ion, "%s_DOWN", ressources[co].cfg_param); if (GNUNET_CONFIGURATION_have_value (cfg, "transport", section)) { - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, - "transport", - section, &value)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (cfg, "transport", section, + &value)) { #if DEBUG_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -6576,18 +6476,16 @@ run (void *cls, GNUNET_free (section); } #if HAVE_LIBGLPK - ats = ats_init (D, U, R, v_b_min, v_n_min, - ATS_MAX_ITERATIONS, ATS_MAX_EXEC_DURATION, - &create_ats_information, ats_result_cb); + ats = + ats_init (D, U, R, v_b_min, v_n_min, ATS_MAX_ITERATIONS, + ATS_MAX_EXEC_DURATION, &create_ats_information, ats_result_cb); ats_set_logging_options (ats, stats, cfg); GNUNET_break (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_time (cfg, - "transport", + GNUNET_CONFIGURATION_get_value_time (cfg, "transport", "ATS_EXEC_INTERVAL", &ats_regular_interval)); GNUNET_break (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_time (cfg, - "transport", + GNUNET_CONFIGURATION_get_value_time (cfg, "transport", "ATS_MIN_INTERVAL", &ats_minimum_interval)); if (ats != NULL) @@ -6617,9 +6515,7 @@ main (int argc, char *const *argv) { a2s (NULL, NULL, 0); /* make compiler happy */ return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "transport", + GNUNET_SERVICE_run (argc, argv, "transport", GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; } diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c index 34d1791b9..2e859f1db 100644 --- a/src/transport/gnunet-service-transport_ats.c +++ b/src/transport/gnunet-service-transport_ats.c @@ -317,8 +317,8 @@ _lp_simplex (glp_prob *P, void *parm) } static void -_lp_load_matrix (glp_prob *P, int ne, const int ia[], - const int ja[], const double ar[]) +_lp_load_matrix (glp_prob *P, int ne, const int ia[], const int ja[], + const double ar[]) { #if HAVE_LIBGLPK glp_load_matrix (P, ne, ia, ja, ar); @@ -510,13 +510,8 @@ _dummy2 () */ struct ATS_Handle * -ats_init (double D, - double U, - double R, - int v_b_min, - int v_n_min, - int max_iterations, - struct GNUNET_TIME_Relative max_duration, +ats_init (double D, double U, double R, int v_b_min, int v_n_min, + int max_iterations, struct GNUNET_TIME_Relative max_duration, GNUNET_TRANSPORT_ATS_AddressNotification address_not, GNUNET_TRANSPORT_ATS_ResultCallback res_cb) { @@ -561,10 +556,9 @@ ats_init (double D, * @return GNUNET_SYSERR if glpk is not available, number of mechanisms used */ int -ats_create_problem (struct ATS_Handle *ats, - struct ATS_internals *stat, - struct ATS_peer *peers, - int c_p, struct ATS_mechanism *mechanisms, int c_m) +ats_create_problem (struct ATS_Handle *ats, struct ATS_internals *stat, + struct ATS_peer *peers, int c_p, + struct ATS_mechanism *mechanisms, int c_m) { if ((c_p == 0) || (c_m == 0)) return GNUNET_SYSERR; @@ -591,8 +585,9 @@ ats_create_problem (struct ATS_Handle *ats, c_p, c_m, c_c_ressources, c_q_metrics); #endif - int size = 1 + 3 + 10 * c_m + c_p + - (c_q_metrics * c_m) + c_q_metrics + c_c_ressources * c_m; + int size = + 1 + 3 + 10 * c_m + c_p + (c_q_metrics * c_m) + c_q_metrics + + c_c_ressources * c_m; int row_index; int array_index = 1; int *ia = GNUNET_malloc (size * sizeof (int)); @@ -609,8 +604,8 @@ ats_create_problem (struct ATS_Handle *ats, /* adding b_t cols */ for (c = 1; c <= c_m; c++) { - GNUNET_asprintf (&name, - "p_%s_b%i", GNUNET_i2s (&(mechanisms[c].peer->peer)), c); + GNUNET_asprintf (&name, "p_%s_b%i", + GNUNET_i2s (&(mechanisms[c].peer->peer)), c); _lp_set_col_name (ats->prob, c, name); GNUNET_free (name); _lp_set_col_bnds (ats->prob, c, GLP_LO, 0.0, 0.0); @@ -621,9 +616,8 @@ ats_create_problem (struct ATS_Handle *ats, /* adding n_t cols */ for (c = c_m + 1; c <= 2 * c_m; c++) { - GNUNET_asprintf (&name, - "p_%s_n%i", GNUNET_i2s (&(mechanisms[c - c_m].peer->peer)), - (c - c_m)); + GNUNET_asprintf (&name, "p_%s_n%i", + GNUNET_i2s (&(mechanisms[c - c_m].peer->peer)), (c - c_m)); _lp_set_col_name (ats->prob, c, name); GNUNET_free (name); _lp_set_col_bnds (ats->prob, c, GLP_DB, 0.0, 1.0); @@ -653,8 +647,8 @@ ats_create_problem (struct ATS_Handle *ats, ar[array_index] = 1; #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n", - array_index, - ia[array_index], ja[array_index], ar[array_index]); + array_index, ia[array_index], ja[array_index], + ar[array_index]); #endif array_index++; m = m->next; @@ -754,8 +748,8 @@ ats_create_problem (struct ATS_Handle *ats, ar[array_index] = value; #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n", - array_index, ia[array_index], - ja[array_index], ar[array_index]); + array_index, ia[array_index], ja[array_index], + ar[array_index]); #endif array_index++; } @@ -893,9 +887,8 @@ ats_create_problem (struct ATS_Handle *ats, ar[array_index] = (mechanisms[c2].peer->f) * value; #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n", - array_index, - qm[c - 1].name, - ia[array_index], ja[array_index], ar[array_index]); + array_index, qm[c - 1].name, ia[array_index], ja[array_index], + ar[array_index]); #endif array_index++; } @@ -970,8 +963,8 @@ ats_create_problem (struct ATS_Handle *ats, ar[array_index] = 1 / mechanisms[c].peer->f; #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n", - array_index, - ia[array_index], ja[array_index], ar[array_index]); + array_index, ia[array_index], ja[array_index], + ar[array_index]); #endif array_index++; m = m->next; @@ -1076,10 +1069,8 @@ ats_modify_problem_state (struct ATS_Handle *ats, enum ATS_problem_state s) } void -ats_solve_problem (struct ATS_Handle *ats, - unsigned int max_it, - unsigned int max_dur, - unsigned int c_peers, +ats_solve_problem (struct ATS_Handle *ats, unsigned int max_it, + unsigned int max_dur, unsigned int c_peers, unsigned int c_mechs, struct ATS_internals *stat) { int result = GNUNET_SYSERR; @@ -1127,8 +1118,8 @@ ats_solve_problem (struct ATS_Handle *ats, lp_solution = _lp_get_status (ats->prob); // TODO: Remove if this does not appear until release - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "" - "EXECUTED SIMPLEX WITH PRESOLVER! %i \n", lp_solution); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "" "EXECUTED SIMPLEX WITH PRESOLVER! %i \n", lp_solution); if (ats_evaluate_results (result, lp_solution, "LP") != GNUNET_YES) { @@ -1136,10 +1127,8 @@ ats_solve_problem (struct ATS_Handle *ats, "After execution simplex with presolver: STILL INVALID!\n"); char *filename; - GNUNET_asprintf (&filename, - "ats_mlp_p%i_m%i_%llu.mlp", - ats->internal.c_peers, - ats->internal.c_mechs, + GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp", + ats->internal.c_peers, ats->internal.c_mechs, GNUNET_TIME_absolute_get ().abs_value); _lp_write_lp ((void *) ats->prob, NULL, filename); GNUNET_free (filename); @@ -1227,10 +1216,12 @@ ats_update_problem_qm (struct ATS_Handle *ats) int c, c2; int c_q_metrics = available_quality_metrics; - int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + - available_quality_metrics) * sizeof (int)); - double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + - available_quality_metrics) * sizeof (double)); + int *ja = + GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + + available_quality_metrics) * sizeof (int)); + double *ar = + GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + + available_quality_metrics) * sizeof (double)); #if DEBUG_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); #endif @@ -1289,8 +1280,8 @@ ats_update_problem_qm (struct ATS_Handle *ats) ar[array_index] = (ats->mechanisms[c2].peer->f) * value; #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: %s [%i,%i]=%f \n", - array_index, - qm[c - 1].name, row_index, ja[array_index], ar[array_index]); + array_index, qm[c - 1].name, row_index, ja[array_index], + ar[array_index]); #endif array_index++; } @@ -1332,8 +1323,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats) ats->internal.simplex_rerun_required = GNUNET_NO; start = GNUNET_TIME_absolute_get (); - if ((ats->internal.recreate_problem == GNUNET_YES) || - (ats->prob == NULL) || (ats->internal.valid == GNUNET_NO)) + if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob == NULL) || + (ats->internal.valid == GNUNET_NO)) { text = "new"; ats->internal.recreate_problem = GNUNET_YES; @@ -1381,10 +1372,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats) ats->internal.solution = GLP_UNDEF; if (ats->internal.valid == GNUNET_YES) { - ats_solve_problem (ats, - ats->max_iterations, - ats->max_exec_duration.rel_value, - ats->internal.c_peers, + ats_solve_problem (ats, ats->max_iterations, + ats->max_exec_duration.rel_value, ats->internal.c_peers, ats->internal.c_mechs, &ats->internal); } solving = @@ -1402,11 +1391,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats) #endif GNUNET_log (msg_type, "MLP %s: creation time: %llu, execution time: %llu, %i peers, %i mechanisms, simplex rerun: %s, solution %s\n", - text, - creation.rel_value, - solving.rel_value, - ats->internal.c_peers, - ats->internal.c_mechs, + text, creation.rel_value, solving.rel_value, + ats->internal.c_peers, ats->internal.c_mechs, (ats->internal.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES", (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID"); @@ -1449,9 +1435,8 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats) } } - GNUNET_STATISTICS_set (ats->stats, - "ATS duration", solving.rel_value + creation.rel_value, - GNUNET_NO); + GNUNET_STATISTICS_set (ats->stats, "ATS duration", + solving.rel_value + creation.rel_value, GNUNET_NO); GNUNET_STATISTICS_set (ats->stats, "ATS mechanisms", ats->internal.c_mechs, GNUNET_NO); GNUNET_STATISTICS_set (ats->stats, "ATS peers", ats->internal.c_peers, @@ -1470,15 +1455,14 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats) if (ats->dump_overwrite == GNUNET_NO) { GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.mlp", - ats->internal.c_peers, - ats->internal.c_mechs, - text, GNUNET_TIME_absolute_get ().abs_value); + ats->internal.c_peers, ats->internal.c_mechs, text, + GNUNET_TIME_absolute_get ().abs_value); _lp_write_lp ((void *) ats->prob, NULL, filename); } else { - GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.mlp", - ats->internal.c_peers, ats->internal.c_mechs); + GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.mlp", ats->internal.c_peers, + ats->internal.c_mechs); _lp_write_lp ((void *) ats->prob, NULL, filename); } GNUNET_free (filename); @@ -1492,15 +1476,14 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle *ats) if (ats->dump_overwrite == GNUNET_NO) { GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.sol", - ats->internal.c_peers, - ats->internal.c_mechs, - text, GNUNET_TIME_absolute_get ().abs_value); + ats->internal.c_peers, ats->internal.c_mechs, text, + GNUNET_TIME_absolute_get ().abs_value); _lp_print_sol (ats->prob, filename); } else { - GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.sol", - ats->internal.c_peers, ats->internal.c_mechs); + GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.sol", ats->internal.c_peers, + ats->internal.c_mechs); _lp_print_sol (ats->prob, filename); } GNUNET_free (filename); @@ -1545,8 +1528,8 @@ ats_evaluate_results (int result, int solution, char *problem) break; case GLP_EITLIM: /* iteration limit exceeded */ #if DEBUG_ATS || VERBOSE_ATS - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "%s Iteration limit exceeded\n", problem); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s Iteration limit exceeded\n", + problem); #endif break; case GLP_ETMLIM: /* time limit exceeded */ @@ -1602,8 +1585,8 @@ ats_evaluate_results (int result, int solution, char *problem) break; case GLP_NOFEAS: #if DEBUG_ATS || VERBOSE_ATS - GNUNET_log (error_kind, "%s problem has no %sfeasible solution\n", - problem, (0 == strcmp (problem, "LP") ? "" : "integer ")); + GNUNET_log (error_kind, "%s problem has no %sfeasible solution\n", problem, + (0 == strcmp (problem, "LP") ? "" : "integer ")); #endif break; case GLP_INFEAS: @@ -1629,10 +1612,12 @@ ats_update_problem_cr (struct ATS_Handle *ats) int c, c2; double ct_max, ct_min; - int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + - available_quality_metrics) * sizeof (int)); - double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + - available_quality_metrics) * sizeof (double)); + int *ja = + GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + + available_quality_metrics) * sizeof (int)); + double *ar = + GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + + available_quality_metrics) * sizeof (double)); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics\n"); row_index = ats->internal.begin_cr; @@ -1685,23 +1670,19 @@ ats_set_logging_options (struct ATS_Handle *ats, if (ats == NULL) return; - log_problem = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "transport", "DUMP_MLP"); - log_solution = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "transport", - "DUMP_SOLUTION"); - overwrite_dump = GNUNET_CONFIGURATION_get_value_yesno (cfg, - "transport", - "DUMP_OVERWRITE"); + log_problem = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport", "DUMP_MLP"); + log_solution = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport", "DUMP_SOLUTION"); + overwrite_dump = + GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport", "DUMP_OVERWRITE"); if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number (cfg, - "transport", - "DUMP_MIN_PEERS", &value)) + GNUNET_CONFIGURATION_get_value_number (cfg, "transport", "DUMP_MIN_PEERS", + &value)) minimum_peers = (int) value; if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number (cfg, - "transport", - "DUMP_MIN_ADDRS", &value)) + GNUNET_CONFIGURATION_get_value_number (cfg, "transport", "DUMP_MIN_ADDRS", + &value)) minimum_addresses = (int) value; @@ -1725,10 +1706,12 @@ ats_update_problem_qm_TEST () int old_ja[ats->internal.c_mechs + 2]; double old_ar[ats->internal.c_mechs + 2]; - int *ja = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + - available_quality_metrics) * sizeof (int)); - double *ar = GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + - available_quality_metrics) * sizeof (double)); + int *ja = + GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + + available_quality_metrics) * sizeof (int)); + double *ar = + GNUNET_malloc ((1 + ats->internal.c_mechs * 2 + 3 + + available_quality_metrics) * sizeof (double)); #if DEBUG_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics TEST\n"); @@ -1753,8 +1736,7 @@ ats_update_problem_qm_TEST () ar[c2] = old_ar[c2]; #if VERBOSE_ATS GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "[index]=[%i]: old [%i,%i]=%f new [%i,%i]=%f\n", - c2, + "[index]=[%i]: old [%i,%i]=%f new [%i,%i]=%f\n", c2, row_index, old_ja[c2], old_ar[c2], row_index, ja[c2], ar[c2]); #endif } diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 7720e467f..abb536414 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c @@ -161,8 +161,8 @@ static struct GNUNET_CONTAINER_MultiHashMap *blacklist; * @param cls the 'struct BlacklistCheck*' * @param tc unused */ -static void -do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void do_blacklist_check (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -227,8 +227,7 @@ read_blacklist_file () char *transport_name; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (GST_cfg, - "TRANSPORT", + GNUNET_CONFIGURATION_get_value_filename (GST_cfg, "TRANSPORT", "BLACKLIST_FILE", &fn)) { #if DEBUG_TRANSPORT @@ -252,8 +251,8 @@ read_blacklist_file () if (frstat.st_size == 0) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklist file `%s' is empty.\n"), fn); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Blacklist file `%s' is empty.\n"), + fn); #endif GNUNET_free (fn); return; @@ -278,8 +277,7 @@ read_blacklist_file () frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) { colon_pos = pos; - while ((colon_pos < frstat.st_size) && - (data[colon_pos] != ':') && + while ((colon_pos < frstat.st_size) && (data[colon_pos] != ':') && (!isspace ((unsigned char) data[colon_pos]))) colon_pos++; if (colon_pos >= frstat.st_size) @@ -330,8 +328,8 @@ read_blacklist_file () #endif memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); if (!isspace - ((unsigned char) - enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) + ((unsigned char) enc. + encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -354,8 +352,8 @@ read_blacklist_file () } else { - if (0 != memcmp (&pid, - &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (&pid, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) { entries_found++; GST_blacklist_add_peer (&pid, transport_name); @@ -372,8 +370,7 @@ read_blacklist_file () while ((pos < frstat.st_size) && isspace ((unsigned char) data[pos])) pos++; } - GNUNET_STATISTICS_update (GST_stats, - "# Transport entries blacklisted", + GNUNET_STATISTICS_update (GST_stats, "# Transport entries blacklisted", entries_found, GNUNET_NO); GNUNET_free (data); GNUNET_free (fn); @@ -389,8 +386,8 @@ void GST_blacklist_start (struct GNUNET_SERVER_Handle *server) { read_blacklist_file (); - GNUNET_SERVER_disconnect_notify (server, - &client_disconnect_notification, NULL); + GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification, + NULL); } @@ -420,8 +417,8 @@ GST_blacklist_stop () { if (NULL != blacklist) { - GNUNET_CONTAINER_multihashmap_iterate (blacklist, - &free_blacklist_entry, NULL); + GNUNET_CONTAINER_multihashmap_iterate (blacklist, &free_blacklist_entry, + NULL); GNUNET_CONTAINER_multihashmap_destroy (blacklist); blacklist = NULL; } @@ -498,12 +495,11 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((bl->bc != NULL) || (bl->waiting_for_reply != GNUNET_NO)) return; /* someone else busy with this client */ bl->bc = bc; - bc->th = GNUNET_SERVER_notify_transmit_ready (bl->client, - sizeof (struct - BlacklistMessage), - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_blacklist_message, - bc); + bc->th = + GNUNET_SERVER_notify_transmit_ready (bl->client, + sizeof (struct BlacklistMessage), + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_blacklist_message, bc); } @@ -517,14 +513,14 @@ do_blacklist_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * GNUNET_NO if we must shutdown the connection */ static void -confirm_or_drop_neighbour (void *cls, - const struct GNUNET_PeerIdentity *peer, int allowed) +confirm_or_drop_neighbour (void *cls, const struct GNUNET_PeerIdentity *peer, + int allowed) { if (GNUNET_OK == allowed) return; /* we're done */ GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# disconnects due to blacklist"), - 1, GNUNET_NO); + gettext_noop ("# disconnects due to blacklist"), 1, + GNUNET_NO); GST_neighbours_force_disconnect (peer); } @@ -556,8 +552,7 @@ struct TestConnectionContext * @param ats_count number of entries in ats (excluding 0-termination) */ static void -test_connection_ok (void *cls, - const struct GNUNET_PeerIdentity *neighbour, +test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -591,8 +586,7 @@ test_connection_ok (void *cls, * @param message the blacklist-init message that was sent */ void -GST_blacklist_handle_init (void *cls, - struct GNUNET_SERVER_Client *client, +GST_blacklist_handle_init (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct Blacklisters *bl; @@ -629,8 +623,7 @@ GST_blacklist_handle_init (void *cls, * @param message the blacklist-init message that was sent */ void -GST_blacklist_handle_reply (void *cls, - struct GNUNET_SERVER_Client *client, +GST_blacklist_handle_reply (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct BlacklistMessage *msg = @@ -752,8 +745,7 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, if ((blacklist != NULL) && (GNUNET_SYSERR == - GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, - &peer->hashPubKey, + GNUNET_CONTAINER_multihashmap_get_multiple (blacklist, &peer->hashPubKey, &test_blacklisted, (void *) transport_name))) { diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 542e3e00b..3ad2149bb 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -205,8 +205,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) "Transmitting message of type %u to client.\n", ntohs (msg->type)); #endif - GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, - tc->message_queue_tail, q); + GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail, + q); tc->message_count--; memcpy (&cbuf[tsize], msg, msize); GNUNET_free (q); @@ -215,11 +215,10 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) if (NULL != q) { GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); - tc->th = GNUNET_SERVER_notify_transmit_ready (tc->client, - msize, - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_client_callback, - tc); + tc->th = + GNUNET_SERVER_notify_transmit_ready (tc->client, msize, + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_client_callback, tc); GNUNET_assert (tc->th != NULL); } return tsize; @@ -234,8 +233,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf) * @param may_drop GNUNET_YES if the message can be dropped */ static void -unicast (struct TransportClient *tc, - const struct GNUNET_MessageHeader *msg, int may_drop) +unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, + int may_drop) { struct ClientMessageQueueEntry *q; uint16_t msize; @@ -262,11 +261,10 @@ unicast (struct TransportClient *tc, tc->message_count++; if (tc->th != NULL) return; - tc->th = GNUNET_SERVER_notify_transmit_ready (tc->client, - msize, - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_to_client_callback, - tc); + tc->th = + GNUNET_SERVER_notify_transmit_ready (tc->client, msize, + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_to_client_callback, tc); GNUNET_assert (tc->th != NULL); } @@ -295,8 +293,8 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client) #endif while (NULL != (mqe = tc->message_queue_head)) { - GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, - tc->message_queue_tail, mqe); + GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail, + mqe); tc->message_count--; GNUNET_free (mqe); } @@ -339,8 +337,8 @@ notify_client_about_neighbour (void *cls, cim->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); cim->ats_count = htonl (ats_count); cim->id = *peer; - memcpy (&cim->ats, - ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); + memcpy (&cim->ats, ats, + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); unicast (tc, &cim->header, GNUNET_NO); GNUNET_free (cim); } @@ -356,8 +354,7 @@ notify_client_about_neighbour (void *cls, * @param message the start message that was sent */ static void -clients_handle_start (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct StartMessage *start; @@ -373,8 +370,9 @@ clients_handle_start (void *cls, } start = (const struct StartMessage *) message; if ((GNUNET_NO != ntohl (start->do_check)) && - (0 != memcmp (&start->self, - &GST_my_identity, sizeof (struct GNUNET_PeerIdentity)))) + (0 != + memcmp (&start->self, &GST_my_identity, + sizeof (struct GNUNET_PeerIdentity)))) { /* client thinks this is a different peer, reject */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -399,8 +397,7 @@ clients_handle_start (void *cls, * @param message the HELLO message */ static void -clients_handle_hello (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_hello (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GST_validation_handle_hello (message); @@ -458,8 +455,7 @@ handle_send_transmit_continuation (void *cls, int success) * @param message the send message that was sent */ static void -clients_handle_send (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct OutboundMessage *obm; @@ -509,8 +505,7 @@ clients_handle_send (void *cls, stcc->target = obm->peer; stcc->client = client; GNUNET_SERVER_client_keep (client); - GST_neighbours_send (&obm->peer, - obmm, msize, + GST_neighbours_send (&obm->peer, obmm, msize, GNUNET_TIME_relative_ntoh (obm->timeout), &handle_send_transmit_continuation, stcc); } @@ -526,8 +521,8 @@ clients_handle_send (void *cls, * GNUNET_NO if not */ static void -try_connect_if_allowed (void *cls, - const struct GNUNET_PeerIdentity *peer, int result) +try_connect_if_allowed (void *cls, const struct GNUNET_PeerIdentity *peer, + int result) { if (GNUNET_OK != result) return; /* not allowed */ @@ -543,8 +538,7 @@ try_connect_if_allowed (void *cls, * @param message the actual message */ static void -clients_handle_request_connect (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_request_connect (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct TransportRequestConnectMessage *trcm = @@ -559,8 +553,8 @@ clients_handle_request_connect (void *cls, "Received a request connect message for peer `%s'\n", GNUNET_i2s (&trcm->peer)); #endif - (void) GST_blacklist_test_allowed (&trcm->peer, NULL, - &try_connect_if_allowed, NULL); + (void) GST_blacklist_test_allowed (&trcm->peer, NULL, &try_connect_if_allowed, + NULL); GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -573,21 +567,19 @@ clients_handle_request_connect (void *cls, * @param message the quota changing message */ static void -clients_handle_set_quota (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_set_quota (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct QuotaSetMessage *qsm; qsm = (const struct QuotaSetMessage *) message; GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# SET QUOTA messages received"), - 1, GNUNET_NO); + gettext_noop ("# SET QUOTA messages received"), 1, + GNUNET_NO); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request (new quota %u) from client for peer `%4s'\n", - "SET_QUOTA", - (unsigned int) ntohl (qsm->quota.value__), + "SET_QUOTA", (unsigned int) ntohl (qsm->quota.value__), GNUNET_i2s (&qsm->peer)); #endif GST_neighbours_set_incoming_quota (&qsm->peer, qsm->quota); @@ -614,8 +606,7 @@ transmit_address_to_client (void *cls, const char *address) GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); return; } - GNUNET_SERVER_transmit_context_append_data (tc, - address, strlen (address) + 1, + GNUNET_SERVER_transmit_context_append_data (tc, address, strlen (address) + 1, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); } @@ -628,8 +619,7 @@ transmit_address_to_client (void *cls, const char *address) * @param message the resolution request */ static void -clients_handle_address_lookup (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_address_lookup (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { const struct AddressLookupMessage *alum; @@ -659,8 +649,8 @@ clients_handle_address_lookup (void *cls, } address = (const char *) &alum[1]; plugin_name = (const char *) &address[address_len]; - if (plugin_name - [size - sizeof (struct AddressLookupMessage) - address_len - 1] != '\0') + if (plugin_name[size - sizeof (struct AddressLookupMessage) - address_len - 1] + != '\0') { GNUNET_break (0); GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); @@ -678,11 +668,9 @@ clients_handle_address_lookup (void *cls, return; } GNUNET_SERVER_disable_receive_done_warning (client); - papi->address_pretty_printer (papi->cls, - plugin_name, - address, address_len, - numeric, - rtimeout, &transmit_address_to_client, tc); + papi->address_pretty_printer (papi->cls, plugin_name, address, address_len, + numeric, rtimeout, &transmit_address_to_client, + tc); } @@ -714,12 +702,11 @@ send_address_to_client (void *cls, /* FIXME: move to a binary format!!! */ GNUNET_asprintf (&addr_buf, "%s --- %s, %s", - GST_plugins_a2s (plugin_name, - plugin_address, + GST_plugins_a2s (plugin_name, plugin_address, plugin_address_len), - (GNUNET_YES == GST_neighbours_test_connected (target)) - ? "CONNECTED" - : "DISCONNECTED", + (GNUNET_YES == + GST_neighbours_test_connected (target)) ? "CONNECTED" : + "DISCONNECTED", (GNUNET_TIME_absolute_get_remaining (valid_until).rel_value > 0) ? "VALIDATED" : "UNVALIDATED"); transmit_address_to_client (tc, addr_buf); @@ -749,8 +736,7 @@ clients_handle_peer_address_lookup (void *cls, tc = GNUNET_SERVER_transmit_context_create (client); GST_validation_get_addresses (&peer_address_lookup->peer, &send_address_to_client, tc); - GNUNET_SERVER_transmit_context_append_data (tc, - NULL, 0, + GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); } @@ -765,8 +751,7 @@ clients_handle_peer_address_lookup (void *cls, * @param ats_count number of entries in ats (excluding 0-termination) */ static void -output_addresses (void *cls, - const struct GNUNET_PeerIdentity *neighbour, +output_addresses (void *cls, const struct GNUNET_PeerIdentity *neighbour, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -774,9 +759,8 @@ output_addresses (void *cls, char *addr_buf; /* FIXME: move to a binary format!!! */ - GNUNET_asprintf (&addr_buf, - "%s: %s", - GNUNET_i2s (neighbour), GST_plugins_a2s ("FIXME", NULL, 0)); + GNUNET_asprintf (&addr_buf, "%s: %s", GNUNET_i2s (neighbour), + GST_plugins_a2s ("FIXME", NULL, 0)); transmit_address_to_client (tc, addr_buf); GNUNET_free (addr_buf); } @@ -791,8 +775,7 @@ output_addresses (void *cls, * @param message the peer address information request */ static void -clients_handle_address_iterate (void *cls, - struct GNUNET_SERVER_Client *client, +clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_SERVER_TransmitContext *tc; @@ -843,8 +826,8 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) {NULL, NULL, 0, 0} }; GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SERVER_disconnect_notify (server, - &client_disconnect_notification, NULL); + GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification, + NULL); } diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index a2d0d966c..3c51c5df2 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c @@ -141,10 +141,10 @@ address_generator (void *cls, size_t max, void *buf) if (NULL == gc->addr_pos) return 0; - ret = GNUNET_HELLO_add_address (gc->addr_pos->plugin_name, - gc->expiration, - &gc->addr_pos[1], - gc->addr_pos->addrlen, buf, max); + ret = + GNUNET_HELLO_add_address (gc->addr_pos->plugin_name, gc->expiration, + &gc->addr_pos[1], gc->addr_pos->addrlen, buf, + max); gc->addr_pos = gc->addr_pos->next; return ret; } @@ -173,15 +173,14 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Refreshed my `%s', new size is %d\n", "HELLO", GNUNET_HELLO_size (our_hello)); #endif - GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# refreshed my HELLO"), - 1, GNUNET_NO); + GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# refreshed my HELLO"), 1, + GNUNET_NO); if (NULL != hello_cb) hello_cb (hello_cb_cls, GST_hello_get ()); GNUNET_PEERINFO_add_peer (GST_peerinfo, our_hello); - hello_task - = GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, - &refresh_hello_task, NULL); + hello_task = + GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, &refresh_hello_task, + NULL); } @@ -257,8 +256,7 @@ GST_hello_get () * @param plugin_address_len number of bytes in plugin_address */ void -GST_hello_modify_addresses (int addremove, - const char *plugin_name, +GST_hello_modify_addresses (int addremove, const char *plugin_name, const void *plugin_address, size_t plugin_address_len) { @@ -266,9 +264,9 @@ GST_hello_modify_addresses (int addremove, #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - (add_remove == GNUNET_YES) - ? "Adding `%s':%s to the set of our addresses\n" - : "Removing `%s':%s from the set of our addresses\n", + (add_remove == + GNUNET_YES) ? "Adding `%s':%s to the set of our addresses\n" : + "Removing `%s':%s from the set of our addresses\n", GST_plugins_a2s (plugin_name, addr, addrlen), p->short_name); #endif GNUNET_assert (plugin_address != NULL); @@ -311,8 +309,7 @@ GST_hello_modify_addresses (int addremove, * GNUNET_NO if not */ int -GST_hello_test_address (const char *plugin_name, - const void *plugin_address, +GST_hello_test_address (const char *plugin_name, const void *plugin_address, size_t plugin_address_len, struct GNUNET_CRYPTO_RsaSignature **sig, struct GNUNET_TIME_Absolute **sig_expiration) diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 386894d48..251b4c356 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -246,8 +246,8 @@ lookup_neighbour (const struct GNUNET_PeerIdentity *pid) * @param cls the 'struct NeighbourMapEntry' * @param tc scheduler context */ -static void -transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void transmission_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -318,15 +318,11 @@ try_transmission_to_peer (struct NeighbourMapEntry *n) GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq); n->is_active = mq; mq->n = n; - ret = papi->send (papi->cls, - &n->id, - mq->message_buf, - mq->message_buf_size, - 0 /* priority -- remove from plugin API? */ , - timeout, - n->session, - n->addr, - n->addrlen, GNUNET_YES, &transmit_send_continuation, mq); + ret = + papi->send (papi->cls, &n->id, mq->message_buf, mq->message_buf_size, + 0 /* priority -- remove from plugin API? */ , + timeout, n->session, n->addr, n->addrlen, GNUNET_YES, + &transmit_send_continuation, mq); if (ret == -1) { /* failure, but 'send' would not call continuation in this case, @@ -361,8 +357,7 @@ transmission_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param disconnect_cb function to call if we disconnect from a peer */ void -GST_neighbours_start (void *cls, - GNUNET_TRANSPORT_NotifyConnect connect_cb, +GST_neighbours_start (void *cls, GNUNET_TRANSPORT_NotifyConnect connect_cb, GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb) { callback_cls = cls; @@ -466,8 +461,7 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value) struct NeighbourMapEntry *n = value; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s', %s\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s', %s\n", GNUNET_i2s (&n->id), "SHUTDOWN_TASK"); #endif disconnect_neighbour (n); @@ -481,8 +475,8 @@ disconnect_all_neighbours (void *cls, const GNUNET_HashCode * key, void *value) void GST_neighbours_stop () { - GNUNET_CONTAINER_multihashmap_iterate (neighbours, - &disconnect_all_neighbours, NULL); + GNUNET_CONTAINER_multihashmap_iterate (neighbours, &disconnect_all_neighbours, + NULL); GNUNET_CONTAINER_multihashmap_destroy (neighbours); neighbours = NULL; callback_cls = NULL; @@ -506,10 +500,8 @@ GST_neighbours_stop () */ void GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, - const char *plugin_name, - const void *address, - size_t address_len, - struct Session *session, + const char *plugin_name, const void *address, + size_t address_len, struct Session *session, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -528,8 +520,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, n->addrlen = address_len; n->session = session; GNUNET_array_grow (n->ats, n->ats_count, ats_count); - memcpy (n->ats, - ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); + memcpy (n->ats, ats, + ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)); GNUNET_free_non_null (n->plugin_name); n->plugin_name = GNUNET_strdup (plugin_name); GNUNET_SCHEDULER_cancel (n->timeout_task); @@ -538,9 +530,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, &neighbour_timeout_task, n); connect_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); connect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); - GST_neighbours_send (peer, - &connect_msg, - sizeof (connect_msg), + GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg), GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL); } @@ -558,10 +548,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer, * @param ats_count number of performance records in 'ats' */ static void -try_connect_using_address (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *plugin_name, - const void *plugin_address, +try_connect_using_address (void *cls, const struct GNUNET_PeerIdentity *target, + const char *plugin_name, const void *plugin_address, size_t plugin_address_len, struct GNUNET_BANDWIDTH_Value32NBO bandwidth, const struct GNUNET_TRANSPORT_ATS_Information *ats, @@ -570,9 +558,7 @@ try_connect_using_address (void *cls, struct NeighbourMapEntry *n = cls; n->asc = NULL; - GST_neighbours_switch_to_address (target, - plugin_name, - plugin_address, + GST_neighbours_switch_to_address (target, plugin_name, plugin_address, plugin_address_len, NULL, ats, ats_count); if (GNUNET_YES == n->is_connected) return; @@ -591,9 +577,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) { struct NeighbourMapEntry *n; - GNUNET_assert (0 != memcmp (target, - &GST_my_identity, - sizeof (struct GNUNET_PeerIdentity))); + GNUNET_assert (0 != + memcmp (target, &GST_my_identity, + sizeof (struct GNUNET_PeerIdentity))); n = lookup_neighbour (target); if ((NULL != n) && (GNUNET_YES == n->is_connected)) return; /* already connected */ @@ -614,8 +600,9 @@ GST_neighbours_try_connect (const struct GNUNET_PeerIdentity *target) } if (n->asc != NULL) return; /* already trying */ - n->asc = GNUNET_ATS_suggest_address (GST_ats, - target, &try_connect_using_address, n); + n->asc = + GNUNET_ATS_suggest_address (GST_ats, target, &try_connect_using_address, + n); } @@ -684,10 +671,8 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer, * @param cont_cls closure for 'cont' */ void -GST_neighbours_send (const struct GNUNET_PeerIdentity *target, - const void *msg, - size_t msg_size, - struct GNUNET_TIME_Relative timeout, +GST_neighbours_send (const struct GNUNET_PeerIdentity *target, const void *msg, + size_t msg_size, struct GNUNET_TIME_Relative timeout, GST_NeighbourSendContinuation cont, void *cont_cls) { struct NeighbourMapEntry *n; @@ -785,8 +770,8 @@ GST_neighbours_calculate_receive_delay (const struct GNUNET_PeerIdentity #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Throttling read (%llu bytes excess at %u b/s), waiting %llu ms before reading more.\n", - (unsigned long long) n-> - in_tracker.consumption_since_last_update__, + (unsigned long long) n->in_tracker. + consumption_since_last_update__, (unsigned int) n->in_tracker.available_bytes_per_s__, (unsigned long long) ret.rel_value); #endif @@ -850,13 +835,12 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour, if (0 != ntohl (quota.value__)) return; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Disconnecting peer `%4s' due to `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n", GNUNET_i2s (&n->id), "SET_QUOTA"); #endif GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# disconnects due to quota of 0"), - 1, GNUNET_NO); + gettext_noop ("# disconnects due to quota of 0"), 1, + GNUNET_NO); disconnect_neighbour (n); } @@ -939,13 +923,11 @@ GST_neighbours_force_disconnect (const struct GNUNET_PeerIdentity *target) disconnect_msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); papi = GST_plugins_find (n->plugin_name); if (papi != NULL) - papi->send (papi->cls, - target, - (const void *) &disconnect_msg, + papi->send (papi->cls, target, (const void *) &disconnect_msg, sizeof (struct GNUNET_MessageHeader), UINT32_MAX /* priority */ , - GNUNET_TIME_UNIT_FOREVER_REL, - n->session, n->addr, n->addrlen, GNUNET_YES, NULL, NULL); + GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->addr, n->addrlen, + GNUNET_YES, NULL, NULL); } disconnect_neighbour (n); } diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index 87901d2cc..c32ac3acc 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c @@ -102,8 +102,7 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, char *pos; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (GST_cfg, - "TRANSPORT", + GNUNET_CONFIGURATION_get_value_number (GST_cfg, "TRANSPORT", "NEIGHBOUR_LIMIT", &tneigh)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -111,15 +110,15 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, return; } if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (GST_cfg, - "TRANSPORT", "PLUGINS", &plugs)) + GNUNET_CONFIGURATION_get_value_string (GST_cfg, "TRANSPORT", "PLUGINS", + &plugs)) return; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Starting transport plugins `%s'\n"), plugs); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting transport plugins `%s'\n"), + plugs); for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " ")) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading `%s' transport plugin\n"), pos); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), + pos); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos); plug = GNUNET_malloc (sizeof (struct TransportPlugin)); plug->short_name = GNUNET_strdup (pos); diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index f618a2b1a..9a3914814 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -361,13 +361,11 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded ve->addr = (void *) &ve[1]; ve->public_key = *public_key; ve->pid = *neighbour; - ve->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, - UINT32_MAX); + ve->challenge = + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); memcpy (&ve[1], addr, addrlen); ve->addrlen = addrlen; - GNUNET_CONTAINER_multihashmap_put (validation_map, - &neighbour->hashPubKey, - ve, + GNUNET_CONTAINER_multihashmap_put (validation_map, &neighbour->hashPubKey, ve, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); return ve; } @@ -385,10 +383,9 @@ find_validation_entry (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded * @return GNUNET_OK (keep the address) */ static int -add_valid_address (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +add_valid_address (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { const struct GNUNET_HELLO_Message *hello = cls; struct ValidationEntry *ve; @@ -397,8 +394,7 @@ add_valid_address (void *cls, if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) return GNUNET_OK; /* expired */ - if ((GNUNET_OK != - GNUNET_HELLO_get_id (hello, &pid)) || + if ((GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) || (GNUNET_OK != GNUNET_HELLO_get_key (hello, &public_key))) { GNUNET_break (0); @@ -406,10 +402,8 @@ add_valid_address (void *cls, } ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); - GNUNET_ATS_address_update (GST_ats, - &pid, - ve->valid_until, - tname, NULL, addr, addrlen, NULL, 0); + GNUNET_ATS_address_update (GST_ats, &pid, ve->valid_until, tname, NULL, addr, + addrlen, NULL, 0); return GNUNET_OK; } @@ -423,8 +417,7 @@ add_valid_address (void *cls, * @param error message */ static void -process_peerinfo_hello (void *cls, - const struct GNUNET_PeerIdentity *peer, +process_peerinfo_hello (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg) { @@ -432,8 +425,7 @@ process_peerinfo_hello (void *cls, if (NULL == hello) return; GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (hello, - GNUNET_NO, + GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &add_valid_address, (void *) hello)); } @@ -517,8 +509,8 @@ timeout_hello_validation (void *cls, ve->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# address records discarded"), - 1, GNUNET_NO); + gettext_noop ("# address records discarded"), 1, + GNUNET_NO); cleanup_validation_entry (NULL, &ve->pid.hashPubKey, ve); } @@ -553,14 +545,9 @@ multicast_pong (void *cls, papi = GST_plugins_find (plugin_name); if (papi == NULL) return; - (void) papi->send (papi->cls, - target, - (const char *) pong, - ntohs (pong->header.size), - PONG_PRIORITY, - HELLO_REVALIDATION_START_TIME, - NULL, - plugin_address, + (void) papi->send (papi->cls, target, (const char *) pong, + ntohs (pong->header.size), PONG_PRIORITY, + HELLO_REVALIDATION_START_TIME, NULL, plugin_address, plugin_address_len, GNUNET_YES, NULL, NULL); } @@ -579,8 +566,7 @@ multicast_pong (void *cls, void GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *hdr, - const char *plugin_name, - struct Session *session, + const char *plugin_name, struct Session *session, const void *sender_address, size_t sender_address_len) { @@ -601,15 +587,16 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, return; } ping = (const struct TransportPingMessage *) hdr; - if (0 != memcmp (&ping->target, - &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (&ping->target, &GST_my_identity, + sizeof (struct GNUNET_PeerIdentity))) { GNUNET_break_op (0); return; } GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# PING messages received"), - 1, GNUNET_NO); + gettext_noop ("# PING messages received"), 1, + GNUNET_NO); addr = (const char *) &ping[1]; alen = ntohs (hdr->size) - sizeof (struct TransportPingMessage); /* peer wants to confirm that this is one of our addresses, this is what is @@ -641,8 +628,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG); pong->purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + - sizeof (uint32_t) + - sizeof (struct GNUNET_TIME_AbsoluteNBO) + alen + slen); + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + + alen + slen); pong->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN); pong->challenge = ping->challenge; pong->addrlen = htonl (alen + slen); @@ -659,8 +646,8 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, *sig_cache_exp = GNUNET_TIME_relative_to_absolute (PONG_SIGNATURE_LIFETIME); pong->expiration = GNUNET_TIME_absolute_hton (*sig_cache_exp); GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_rsa_sign (GST_my_private_key, - &pong->purpose, sig_cache)); + GNUNET_CRYPTO_rsa_sign (GST_my_private_key, &pong->purpose, + sig_cache)); } else { @@ -674,15 +661,11 @@ GST_validation_handle_ping (const struct GNUNET_PeerIdentity *sender, if (papi == NULL) ret = -1; else - ret = papi->send (papi->cls, - sender, - (const char *) pong, - ntohs (pong->header.size), - PONG_PRIORITY, - HELLO_REVALIDATION_START_TIME, - session, - sender_address, - sender_address_len, GNUNET_SYSERR, NULL, NULL); + ret = + papi->send (papi->cls, sender, (const char *) pong, + ntohs (pong->header.size), PONG_PRIORITY, + HELLO_REVALIDATION_START_TIME, session, sender_address, + sender_address_len, GNUNET_SYSERR, NULL, NULL); if (ret != -1) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -733,8 +716,8 @@ struct ValidateAddressContext * @param result GNUNET_OK if the connection is allowed, GNUNET_NO if not */ static void -transmit_ping_if_allowed (void *cls, - const struct GNUNET_PeerIdentity *pid, int result) +transmit_ping_if_allowed (void *cls, const struct GNUNET_PeerIdentity *pid, + int result) { struct ValidationEntry *ve = cls; struct TransportPingMessage ping; @@ -746,8 +729,8 @@ transmit_ping_if_allowed (void *cls, uint16_t hsize; ve->bc = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting plain PING to `%s'\n", GNUNET_i2s (pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting plain PING to `%s'\n", + GNUNET_i2s (pid)); ping.header.size = htons (sizeof (struct TransportPingMessage)); ping.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PING); ping.challenge = htonl (ve->challenge); @@ -780,13 +763,10 @@ transmit_ping_if_allowed (void *cls, if (papi == NULL) ret = -1; else - ret = papi->send (papi->cls, - pid, - message_buf, - tsize, - PING_PRIORITY, - HELLO_REVALIDATION_START_TIME, NULL /* no session */ , - ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL); + ret = + papi->send (papi->cls, pid, message_buf, tsize, PING_PRIORITY, + HELLO_REVALIDATION_START_TIME, NULL /* no session */ , + ve->addr, ve->addrlen, GNUNET_YES, NULL, NULL); } if (-1 != ret) { @@ -811,10 +791,9 @@ transmit_ping_if_allowed (void *cls, * @return GNUNET_OK (keep the address) */ static int -validate_address (void *cls, - const char *tname, - struct GNUNET_TIME_Absolute expiration, - const void *addr, uint16_t addrlen) +validate_address (void *cls, const char *tname, + struct GNUNET_TIME_Absolute expiration, const void *addr, + uint16_t addrlen) { const struct ValidateAddressContext *vac = cls; const struct GNUNET_PeerIdentity *pid = &vac->pid; @@ -861,18 +840,17 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (delay.rel_value > 0) { /* should wait a bit longer */ - ve->timeout_task = GNUNET_SCHEDULER_add_delayed (delay, - &revalidate_address, ve); + ve->timeout_task = + GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); return; } GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# address revalidations started"), - 1, GNUNET_NO); + gettext_noop ("# address revalidations started"), 1, + GNUNET_NO); vac.pid = ve->pid; vac.public_key = ve->public_key; - validate_address (&vac, - ve->transport_name, - ve->valid_until, ve->addr, (uint16_t) ve->addrlen); + validate_address (&vac, ve->transport_name, ve->valid_until, ve->addr, + (uint16_t) ve->addrlen); } @@ -888,8 +866,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf) { struct ValidationEntry *ve = cls; - return GNUNET_HELLO_add_address (ve->transport_name, - ve->valid_until, + return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until, ve->addr, ve->addrlen, buf, max); } @@ -921,8 +898,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, return; } GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# PONG messages received"), - 1, GNUNET_NO); + gettext_noop ("# PONG messages received"), 1, + GNUNET_NO); pong = (const struct TransportPongMessage *) hdr; addr = (const char *) &pong[1]; alen = ntohs (hdr->size) - sizeof (struct TransportPongMessage); @@ -962,8 +939,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, } if (GNUNET_OK != GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, - &pong->purpose, - &pong->signature, &ve->public_key)) + &pong->purpose, &pong->signature, + &ve->public_key)) { GNUNET_break_op (0); return; @@ -983,9 +960,10 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, /* randomly delay by up to 1h to avoid synchronous validations */ rdelay = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 60 * 60); - delay = GNUNET_TIME_relative_add (HELLO_REVALIDATION_START_TIME, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, rdelay)); + delay = + GNUNET_TIME_relative_add (HELLO_REVALIDATION_START_TIME, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, rdelay)); ve->timeout_task = GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve); } @@ -1004,8 +982,7 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) (const struct GNUNET_HELLO_Message *) hello; struct ValidateAddressContext vac; - if ((GNUNET_OK != - GNUNET_HELLO_get_id (hm, &vac.pid)) || + if ((GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) || (GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key))) { /* malformed HELLO */ @@ -1013,8 +990,7 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) return; } GNUNET_assert (NULL == - GNUNET_HELLO_iterate_addresses (hm, - GNUNET_NO, + GNUNET_HELLO_iterate_addresses (hm, GNUNET_NO, &validate_address, &vac)); } @@ -1051,10 +1027,7 @@ iterate_addresses (void *cls, const GNUNET_HashCode * key, void *value) struct IteratorContext *ic = cls; struct ValidationEntry *ve = value; - ic->cb (ic->cb_cls, - &ve->public_key, - &ve->pid, - ve->valid_until, + ic->cb (ic->cb_cls, &ve->public_key, &ve->pid, ve->valid_until, ve->validation_block, ve->transport_name, ve->addr, ve->addrlen); return GNUNET_OK; } diff --git a/src/transport/gnunet-transport-certificate-creation.c b/src/transport/gnunet-transport-certificate-creation.c index a63c21c60..9fd62fc9f 100644 --- a/src/transport/gnunet-transport-certificate-creation.c +++ b/src/transport/gnunet-transport-certificate-creation.c @@ -56,10 +56,9 @@ main (int argc, char **argv) close (2); /* eliminate stderr */ /* Create RSA Private Key */ /* openssl genrsa -out $1 1024 2> /dev/null */ - openssl = GNUNET_OS_start_process (NULL, NULL, - "openssl", - "openssl", - "genrsa", "-out", argv[1], "1024", NULL); + openssl = + GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "genrsa", + "-out", argv[1], "1024", NULL); if (openssl == NULL) return 2; GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK); @@ -67,12 +66,10 @@ main (int argc, char **argv) /* Create a self-signed certificate in batch mode using rsa key */ /* openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null */ - openssl = GNUNET_OS_start_process (NULL, NULL, - "openssl", - "openssl", - "req", "-batch", "-days", "365", - "-out", argv[2], "-new", "-x509", "-key", - argv[1], NULL); + openssl = + GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "req", + "-batch", "-days", "365", "-out", argv[2], + "-new", "-x509", "-key", argv[1], NULL); if (openssl == NULL) return 3; GNUNET_assert (GNUNET_OS_process_wait (openssl) == GNUNET_OK); diff --git a/src/transport/gnunet-transport-list-connections.c b/src/transport/gnunet-transport-list-connections.c index d68d2fedf..d31d2febb 100644 --- a/src/transport/gnunet-transport-list-connections.c +++ b/src/transport/gnunet-transport-list-connections.c @@ -72,9 +72,8 @@ process_address (void *cls, const char *address) * @param c configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; @@ -84,8 +83,7 @@ run (void *cls, return; } - GNUNET_TRANSPORT_address_iterate (cfg, - GNUNET_TIME_UNIT_MINUTES, + GNUNET_TRANSPORT_address_iterate (cfg, GNUNET_TIME_UNIT_MINUTES, &process_address, NULL); } @@ -107,9 +105,7 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-list-connections", + GNUNET_PROGRAM_run (argc, argv, "gnunet-list-connections", gettext_noop ("Print information about connected peers."), options, &run, NULL)) ? 0 : 1; diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c index 1cfcf2c4e..b3468791d 100644 --- a/src/transport/gnunet-transport-wlan-helper.c +++ b/src/transport/gnunet-transport-wlan-helper.c @@ -135,10 +135,8 @@ check_crc_buf_osdep (unsigned char *buf, int len) crc = calc_crc_osdep (buf, len); buf += len; - return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && ((crc - >> 16) - & 0xFF) - == buf[2] && ((crc >> 24) & 0xFF) == buf[3]); + return (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && + ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]); } @@ -387,8 +385,7 @@ openraw (struct Hardware_Infos *dev) sll.sll_protocol = htons (ETH_P_ALL); if (-1 == ioctl (dev->fd_raw, SIOCGIFHWADDR, &ifr)) { - fprintf (stderr, - "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n", + fprintf (stderr, "ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n", IFNAMSIZ, dev->iface, strerror (errno)); return 1; } @@ -408,8 +405,7 @@ openraw (struct Hardware_Infos *dev) (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) || (wrq.u.mode != IW_MODE_MONITOR)) { - fprintf (stderr, - "Error: interface `%.*s' is not in monitor mode\n", + fprintf (stderr, "Error: interface `%.*s' is not in monitor mode\n", IFNAMSIZ, dev->iface); return 1; } @@ -432,9 +428,8 @@ openraw (struct Hardware_Infos *dev) /* bind the raw socket to the interface */ if (-1 == bind (dev->fd_raw, (struct sockaddr *) &sll, sizeof (sll))) { - fprintf (stderr, - "Failed to bind interface `%.*s': %s\n", - IFNAMSIZ, dev->iface, strerror (errno)); + fprintf (stderr, "Failed to bind interface `%.*s': %s\n", IFNAMSIZ, + dev->iface, strerror (errno)); return 1; } @@ -453,8 +448,7 @@ openraw (struct Hardware_Infos *dev) (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM) && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL)) { - fprintf (stderr, - "Unsupported hardware link type %d on interface `%.*s'\n", + fprintf (stderr, "Unsupported hardware link type %d on interface `%.*s'\n", ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->iface); return 1; } @@ -467,8 +461,7 @@ openraw (struct Hardware_Infos *dev) setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, sizeof (mr))) { - fprintf (stderr, - "Failed to enable promiscuous mode on interface `%.*s'\n", + fprintf (stderr, "Failed to enable promiscuous mode on interface `%.*s'\n", IFNAMSIZ, dev->iface); return 1; } @@ -494,17 +487,16 @@ wlaninit (struct Hardware_Infos *dev, const char *iface) } if (dev->fd_raw >= FD_SETSIZE) { - fprintf (stderr, - "File descriptor too large for select (%d > %d)\n", + fprintf (stderr, "File descriptor too large for select (%d > %d)\n", dev->fd_raw, FD_SETSIZE); close (dev->fd_raw); return 1; } /* mac80211 stack detection */ - ret = snprintf (strbuf, - sizeof (strbuf), - "/sys/class/net/%s/phy80211/subsystem", iface); + ret = + snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", + iface); if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) { fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface); @@ -634,8 +626,7 @@ maketest (unsigned char *buf, struct Hardware_Infos *dev) static int first = 0; const int rate = 11000000; - static const char - txt[] = + static const char txt[] = "Hallo1Hallo2 Hallo3 Hallo4...998877665544332211Hallo1Hallo2 Hallo3 Hallo4...998877665544332211"; unsigned char u8aRadiotap[] = { 0x00, 0x00, // <-- radiotap version @@ -686,14 +677,14 @@ maketest (unsigned char *buf, struct Hardware_Infos *dev) } tmp16 = (uint16_t *) u8aIeeeHeader.i_dur; - *tmp16 - = + *tmp16 = (uint16_t) htole16 ((sizeof (txt) + sizeof (struct ieee80211_frame) * 1000000) / rate + 290); tmp16 = (uint16_t *) u8aIeeeHeader.i_seq; - *tmp16 = (*tmp16 & IEEE80211_SEQ_FRAG_MASK) | (htole16 (seqenz) - << IEEE80211_SEQ_SEQ_SHIFT); + *tmp16 = + (*tmp16 & IEEE80211_SEQ_FRAG_MASK) | (htole16 (seqenz) << + IEEE80211_SEQ_SEQ_SHIFT); seqenz++; memcpy (buf, u8aRadiotap, sizeof (u8aRadiotap)); @@ -795,9 +786,9 @@ hardwaremode (int argc, char *argv[]) if (FD_ISSET (STDOUT_FILENO, &wfds)) { - ret = write (STDOUT_FILENO, - write_std.buf + write_std.pos, - write_std.size - write_std.pos); + ret = + write (STDOUT_FILENO, write_std.buf + write_std.pos, + write_std.size - write_std.pos); if (0 > ret) { fprintf (stderr, "Failed to write to STDOUT: %s\n", strerror (errno)); @@ -824,9 +815,8 @@ hardwaremode (int argc, char *argv[]) dev.write_pout.pos += ret; if ((dev.write_pout.pos != dev.write_pout.size) && (ret != 0)) { - fprintf (stderr, - "Line %u: Write error, partial send: %u/%u\n", __LINE__, - dev.write_pout.pos, dev.write_pout.size); + fprintf (stderr, "Line %u: Write error, partial send: %u/%u\n", + __LINE__, dev.write_pout.pos, dev.write_pout.size); break; } if (dev.write_pout.pos == dev.write_pout.size) @@ -849,8 +839,8 @@ hardwaremode (int argc, char *argv[]) /* stop reading... */ stdin_open = 0; } - GNUNET_SERVER_mst_receive (stdin_mst, NULL, - readbuf, ret, GNUNET_NO, GNUNET_NO); + GNUNET_SERVER_mst_receive (stdin_mst, NULL, readbuf, ret, GNUNET_NO, + GNUNET_NO); } if (FD_ISSET (dev.fd_raw, &rfds)) @@ -862,10 +852,10 @@ hardwaremode (int argc, char *argv[]) header = (struct GNUNET_MessageHeader *) write_std.buf; rxinfo = (struct Radiotap_rx *) &header[1]; datastart = (struct ieee80211_frame *) &rxinfo[1]; - ret = linux_read (&dev, - (unsigned char *) datastart, - sizeof (write_std.buf) - sizeof (struct Radiotap_rx) - - sizeof (struct GNUNET_MessageHeader), rxinfo); + ret = + linux_read (&dev, (unsigned char *) datastart, + sizeof (write_std.buf) - sizeof (struct Radiotap_rx) - + sizeof (struct GNUNET_MessageHeader), rxinfo); if (0 > ret) { fprintf (stderr, "Read error from raw socket: %s\n", strerror (errno)); diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c index df1ebe950..0be15d255 100644 --- a/src/transport/perf_transport_ats.c +++ b/src/transport/perf_transport_ats.c @@ -170,8 +170,8 @@ bench_simplex_no_optimization (char *file, int executions) exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value; sim_no_opt_avg += exec_time[c]; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Simplex iterations %i: %llu \n", c, exec_time[c]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, + exec_time[c]); } glp_delete_prob (prob); @@ -328,8 +328,7 @@ main (int argc, char *argv[]) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "MLP optimization average per address: %f\n", ((double) mlp_with_opt_avg / EXECS) / 400); - GAUGER ("TRANSPORT", - "GLPK MLP 100 peers 400 addresses with optimization", + GAUGER ("TRANSPORT", "GLPK MLP 100 peers 400 addresses with optimization", ((double) mlp_with_opt_avg / EXECS) / 400, "ms/address"); (void) CLOSE (nullfd); return ret; diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 0c856e4ab..a6b24e73e 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -547,8 +547,7 @@ struct PrettyPrinterContext * @param addrlen length of the address * @return string representing the same address */ -static const char *http_plugin_address_to_string (void *cls, - const void *addr, +static const char *http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen); @@ -618,8 +617,7 @@ create_url (struct Plugin *plugin, const void *addr, size_t addrlen, size_t id) char *addr_str = (char *) http_plugin_address_to_string (NULL, addr, addrlen); GNUNET_assert ((addr != NULL) && (addrlen != 0)); - GNUNET_asprintf (&url, - "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str, + GNUNET_asprintf (&url, "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str, (char *) (&plugin->my_ascii_hash_ident), id); return url; } @@ -634,8 +632,8 @@ create_url (struct Plugin *plugin, const void *addr, size_t addrlen, size_t id) static int remove_http_message (struct Session *ps, struct HTTP_Message *msg) { - GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, - ps->pending_msgs_tail, msg); + GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, ps->pending_msgs_tail, + msg); GNUNET_free (msg); return GNUNET_OK; } @@ -648,8 +646,8 @@ remove_http_message (struct Session *ps, struct HTTP_Message *msg) * @return GNUNET_YES on success */ static int -remove_peer_context_Iterator (void *cls, - const GNUNET_HashCode * key, void *value) +remove_peer_context_Iterator (void *cls, const GNUNET_HashCode * key, + void *value) { struct Plugin *plugin = cls; struct HTTP_PeerContext *pc = value; @@ -659,8 +657,8 @@ remove_peer_context_Iterator (void *cls, struct HTTP_Message *msg_tmp = NULL; #if DEBUG_HTTP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Freeing context for peer `%s'\n", GNUNET_i2s (&pc->identity)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Freeing context for peer `%s'\n", + GNUNET_i2s (&pc->identity)); #endif GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (plugin->peers, @@ -695,8 +693,8 @@ remove_peer_context_Iterator (void *cls, } GNUNET_free (pc); GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# HTTP peers active"), - -1, GNUNET_NO); + gettext_noop ("# HTTP peers active"), -1, + GNUNET_NO); return GNUNET_YES; } @@ -710,18 +708,17 @@ remove_peer_context_Iterator (void *cls, * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success */ static int -remove_session (struct HTTP_PeerContext *pc, - struct Session *ps, int call_msg_cont, int call_msg_cont_result) +remove_session (struct HTTP_PeerContext *pc, struct Session *ps, + int call_msg_cont, int call_msg_cont_result) { struct HTTP_Message *msg; struct Plugin *plugin = ps->peercontext->plugin; #if DEBUG_CONNECTIONS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection %X: removing %s session %X with id %u\n", - ps, - (ps->direction == INBOUND) - ? "inbound" : "outbound", ps, ps->session_id); + "Connection %X: removing %s session %X with id %u\n", ps, + (ps->direction == INBOUND) ? "inbound" : "outbound", ps, + ps->session_id); #endif plugin->env->session_end (plugin, &pc->identity, ps); GNUNET_free_non_null (ps->addr); @@ -746,11 +743,11 @@ remove_session (struct HTTP_PeerContext *pc, { if ((call_msg_cont == GNUNET_YES) && (msg->transmit_cont != NULL)) { - msg->transmit_cont (msg->transmit_cont_cls, - &pc->identity, call_msg_cont_result); + msg->transmit_cont (msg->transmit_cont_cls, &pc->identity, + call_msg_cont_result); } - GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, - ps->pending_msgs_head, msg); + GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, ps->pending_msgs_head, + msg); GNUNET_free (msg); msg = ps->pending_msgs_head; } @@ -795,8 +792,8 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen) else local = GNUNET_YES; #if DEBUG_HTTP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Checking IPv4 address `%s': %s\n", GNUNET_a2s (addr, addrlen), + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking IPv4 address `%s': %s\n", + GNUNET_a2s (addr, addrlen), (local == GNUNET_YES) ? "local" : "global"); #endif break; @@ -809,8 +806,8 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen) else local = GNUNET_NO; #if DEBUG_HTTP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Checking IPv6 address `%s' : %s\n", GNUNET_a2s (addr, addrlen), + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking IPv6 address `%s' : %s\n", + GNUNET_a2s (addr, addrlen), (local == GNUNET_YES) ? "local" : "global"); #endif break; @@ -832,9 +829,7 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen) * @return GNUNET_OK to continue iterating */ static int -process_interfaces (void *cls, - const char *name, - int isDefault, +process_interfaces (void *cls, const char *name, int isDefault, const struct sockaddr *addr, socklen_t addrlen) { struct Plugin *plugin = cls; @@ -847,8 +842,7 @@ process_interfaces (void *cls, if (GNUNET_YES == check_localaddress (addr, addrlen)) { #if DEBUG_HTTP - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - PROTOCOL_PREFIX, + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PROTOCOL_PREFIX, "Not notifying transport of address `%s' (local address)\n", GNUNET_a2s (addr, addrlen)); #endif @@ -859,8 +853,8 @@ process_interfaces (void *cls, GNUNET_assert (cls != NULL); af = addr->sa_family; - if ((af == AF_INET) && - (plugin->use_ipv4 == GNUNET_YES) && (plugin->bind6_address == NULL)) + if ((af == AF_INET) && (plugin->use_ipv4 == GNUNET_YES) && + (plugin->bind6_address == NULL)) { struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr; @@ -879,9 +873,8 @@ process_interfaces (void *cls, { GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, t4); - plugin->env->notify_address (plugin->env->cls, - GNUNET_YES, - t4, sizeof (struct IPv4HttpAddress)); + plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t4, + sizeof (struct IPv4HttpAddress)); return GNUNET_OK; } GNUNET_free (t4); @@ -891,14 +884,13 @@ process_interfaces (void *cls, { GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, t4); - plugin->env->notify_address (plugin->env->cls, - GNUNET_YES, - t4, sizeof (struct IPv4HttpAddress)); + plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t4, + sizeof (struct IPv4HttpAddress)); return GNUNET_OK; } } - if ((af == AF_INET6) && - (plugin->use_ipv6 == GNUNET_YES) && (plugin->bind4_address == NULL)) + if ((af == AF_INET6) && (plugin->use_ipv6 == GNUNET_YES) && + (plugin->bind4_address == NULL)) { struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr; @@ -908,16 +900,15 @@ process_interfaces (void *cls, if (plugin->bind6_address != NULL) { - if (0 == memcmp (&plugin->bind6_address->sin6_addr, - &bnd_cmp6, sizeof (struct in6_addr))) + if (0 == + memcmp (&plugin->bind6_address->sin6_addr, &bnd_cmp6, + sizeof (struct in6_addr))) { - memcpy (&t6->ipv6_addr, - &((struct sockaddr_in6 *) addr)->sin6_addr, + memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); t6->port = htons (plugin->port_inbound); - plugin->env->notify_address (plugin->env->cls, - GNUNET_YES, - t6, sizeof (struct IPv6HttpAddress)); + plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t6, + sizeof (struct IPv6HttpAddress)); GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, t6); return GNUNET_OK; @@ -925,16 +916,14 @@ process_interfaces (void *cls, GNUNET_free (t6); return GNUNET_OK; } - memcpy (&t6->ipv6_addr, - &((struct sockaddr_in6 *) addr)->sin6_addr, + memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); t6->port = htons (plugin->port_inbound); GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, t6); - plugin->env->notify_address (plugin->env->cls, - GNUNET_YES, - t6, sizeof (struct IPv6HttpAddress)); + plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t6, + sizeof (struct IPv6HttpAddress)); } return GNUNET_OK; } @@ -958,8 +947,8 @@ mhd_logger (void *arg, const char *fmt, va_list ap) static void -mhd_termination_cb (void *cls, - struct MHD_Connection *connection, void **httpSessionCache) +mhd_termination_cb (void *cls, struct MHD_Connection *connection, + void **httpSessionCache) { struct Session *ps = *httpSessionCache; @@ -1013,8 +1002,8 @@ mhd_termination_cb (void *cls, * @param message the message to be forwarded to transport service */ static void -mhd_write_mst_cb (void *cls, - void *client, const struct GNUNET_MessageHeader *message) +mhd_write_mst_cb (void *cls, void *client, + const struct GNUNET_MessageHeader *message) { struct Session *ps = cls; struct HTTP_PeerContext *pc; @@ -1026,9 +1015,7 @@ mhd_write_mst_cb (void *cls, #if DEBUG_HTTP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", - ps, - ntohs (message->type), - ntohs (message->size), + ps, ntohs (message->type), ntohs (message->size), GNUNET_i2s (&(ps->peercontext)->identity), http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); #endif @@ -1038,12 +1025,11 @@ mhd_write_mst_cb (void *cls, distance[0].value = htonl (1); distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); distance[1].value = htonl (0); - delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls, - &pc->identity, - message, - (const struct - GNUNET_TRANSPORT_ATS_Information *) - &distance, 2, ps, NULL, 0); + delay = + pc->plugin->env->receive (ps->peercontext->plugin->env->cls, + &pc->identity, message, + (const struct GNUNET_TRANSPORT_ATS_Information + *) &distance, 2, ps, NULL, 0); pc->delay = delay; if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (pc->reset_task); @@ -1142,8 +1128,8 @@ mhd_send_callback (void *cls, uint64_t pos, char *buf, size_t max) } } #if DEBUG_CONNECTIONS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection %X: MHD has sent %u bytes\n", ps, bytes_read); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: MHD has sent %u bytes\n", + ps, bytes_read); #endif return bytes_read; } @@ -1157,13 +1143,10 @@ mhd_send_callback (void *cls, uint64_t pos, char *buf, size_t max) * already exists and create a new one if not. */ static int -mhd_access_cb (void *cls, - struct MHD_Connection *mhd_connection, - const char *url, - const char *method, - const char *version, - const char *upload_data, - size_t * upload_data_size, void **httpSessionCache) +mhd_access_cb (void *cls, struct MHD_Connection *mhd_connection, + const char *url, const char *method, const char *version, + const char *upload_data, size_t * upload_data_size, + void **httpSessionCache) { struct Plugin *plugin = cls; struct MHD_Response *response; @@ -1205,9 +1188,9 @@ mhd_access_cb (void *cls, GNUNET_free (peer); if (GNUNET_SYSERR == res) { - response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE), - HTTP_ERROR_RESPONSE, - MHD_NO, MHD_NO); + response = + MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE), + HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); MHD_destroy_response (response); #if DEBUG_CONNECTIONS @@ -1240,12 +1223,11 @@ mhd_access_cb (void *cls, pc->last_session = NULL; memcpy (&pc->identity, &pi_in, sizeof (struct GNUNET_PeerIdentity)); GNUNET_CONTAINER_multihashmap_put (plugin->peers, - &pc->identity.hashPubKey, - pc, + &pc->identity.hashPubKey, pc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# HTTP peers active"), - 1, GNUNET_NO); + gettext_noop ("# HTTP peers active"), 1, + GNUNET_NO); } conn_info = @@ -1329,9 +1311,7 @@ mhd_access_cb (void *cls, #if DEBUG_HTTP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n", - ps, - method, - GNUNET_i2s (&pc->identity), + ps, method, GNUNET_i2s (&pc->identity), http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); #endif } @@ -1365,9 +1345,9 @@ mhd_access_cb (void *cls, /* Transmission of all data complete */ if ((*upload_data_size == 0) && (ps->recv_active == GNUNET_YES)) { - response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE), - HTTP_PUT_RESPONSE, - MHD_NO, MHD_NO); + response = + MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE), + HTTP_PUT_RESPONSE, MHD_NO, MHD_NO); res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); #if DEBUG_CONNECTIONS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1385,12 +1365,12 @@ mhd_access_cb (void *cls, { #if DEBUG_HTTP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection %X: PUT with %u bytes forwarded to MST\n", - ps, *upload_data_size); + "Connection %X: PUT with %u bytes forwarded to MST\n", ps, + *upload_data_size); #endif - res = GNUNET_SERVER_mst_receive (ps->msgtok, ps, - upload_data, *upload_data_size, - GNUNET_NO, GNUNET_NO); + res = + GNUNET_SERVER_mst_receive (ps->msgtok, ps, upload_data, + *upload_data_size, GNUNET_NO, GNUNET_NO); (*upload_data_size) = 0; } else @@ -1485,11 +1465,10 @@ http_server_daemon_prepare (struct Plugin *plugin, plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK; } - ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, - tv, - wrs, - wws, &http_server_daemon_v4_run, plugin); + ret = + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + &http_server_daemon_v4_run, plugin); } if (daemon_handle == plugin->http_server_daemon_v6) { @@ -1499,11 +1478,10 @@ http_server_daemon_prepare (struct Plugin *plugin, plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; } - ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_TASK, - tv, - wrs, - wws, &http_server_daemon_v6_run, plugin); + ret = + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, + GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, + &http_server_daemon_v6_run, plugin); } GNUNET_NETWORK_fdset_destroy (wrs); GNUNET_NETWORK_fdset_destroy (wws); @@ -1643,8 +1621,8 @@ curl_get_header_cb (void *ptr, size_t size, size_t nmemb, void *stream) if (tmp[len - 2] == 13) tmp[len - 2] = '\0'; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection %X: Header: %s\n", ps, tmp); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: Header: %s\n", ps, + tmp); } GNUNET_free_non_null (tmp); #endif @@ -1791,8 +1769,8 @@ curl_send_cb (void *stream, size_t size, size_t nmemb, void *ptr) static void -curl_receive_mst_cb (void *cls, - void *client, const struct GNUNET_MessageHeader *message) +curl_receive_mst_cb (void *cls, void *client, + const struct GNUNET_MessageHeader *message) { struct Session *ps = cls; struct GNUNET_TIME_Relative delay; @@ -1805,11 +1783,12 @@ curl_receive_mst_cb (void *cls, #if DEBUG_HTTP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", - ps, - ntohs (message->type), - ntohs (message->size), - GNUNET_i2s (&(pc->identity)), - http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); + ps, ntohs (message->type), ntohs (message->size), + GNUNET_i2s (&(pc->identity)), http_plugin_address_to_string (NULL, + ps-> + addr, + ps-> + addrlen)); #endif struct GNUNET_TRANSPORT_ATS_Information distance[2]; @@ -1818,12 +1797,10 @@ curl_receive_mst_cb (void *cls, distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); distance[1].value = htonl (0); - delay = pc->plugin->env->receive (pc->plugin->env->cls, - &pc->identity, - message, - (const struct - GNUNET_TRANSPORT_ATS_Information *) - &distance, 2, ps, ps->addr, ps->addrlen); + delay = + pc->plugin->env->receive (pc->plugin->env->cls, &pc->identity, message, + (const struct GNUNET_TRANSPORT_ATS_Information + *) &distance, 2, ps, ps->addr, ps->addrlen); pc->delay = delay; if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (pc->reset_task); @@ -1865,11 +1842,11 @@ curl_receive_cb (void *stream, size_t size, size_t nmemb, void *ptr) return 0; } #if DEBUG_CONNECTIONS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection %X: %u bytes received\n", ps, size * nmemb); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: %u bytes received\n", ps, + size * nmemb); #endif - GNUNET_SERVER_mst_receive (ps->msgtok, ps, - stream, size * nmemb, GNUNET_NO, GNUNET_NO); + GNUNET_SERVER_mst_receive (ps->msgtok, ps, stream, size * nmemb, GNUNET_NO, + GNUNET_NO); return (size * nmemb); } @@ -1958,8 +1935,7 @@ curl_handle_finished (struct Plugin *plugin) #if DEBUG_CONNECTIONS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", - ps, - GNUNET_i2s (&pc->identity), + ps, GNUNET_i2s (&pc->identity), http_plugin_address_to_string (NULL, ps->addr, ps->addrlen), http_result); #endif @@ -1995,8 +1971,7 @@ curl_handle_finished (struct Plugin *plugin) #if DEBUG_CONNECTIONS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", - ps, - GNUNET_i2s (&pc->identity), + ps, GNUNET_i2s (&pc->identity), http_plugin_address_to_string (NULL, ps->addr, ps->addrlen), http_result); #endif @@ -2081,8 +2056,7 @@ curl_schedule (struct Plugin *plugin) mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_fdset", __FILE__, __LINE__, curl_multi_strerror (mret)); return GNUNET_SYSERR; @@ -2090,8 +2064,7 @@ curl_schedule (struct Plugin *plugin) mret = curl_multi_timeout (plugin->multi_handle, &to); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_timeout", __FILE__, __LINE__, curl_multi_strerror (mret)); return GNUNET_SYSERR; @@ -2129,8 +2102,8 @@ curl_schedule (struct Plugin *plugin) * @return 0 */ static int -curl_logger (CURL * curl, - curl_infotype type, char *data, size_t size, void *cls) +curl_logger (CURL * curl, curl_infotype type, char *data, size_t size, + void *cls) { if (type == CURLINFO_TEXT) { @@ -2217,8 +2190,7 @@ send_check_connections (struct Plugin *plugin, struct Session *ps) if (mret != CURLM_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Connection: %X: %s failed at %s:%d: `%s'\n"), - ps, + _("Connection: %X: %s failed at %s:%d: `%s'\n"), ps, "curl_multi_add_handle", __FILE__, __LINE__, curl_multi_strerror (mret)); return GNUNET_SYSERR; @@ -2330,8 +2302,7 @@ send_check_connections (struct Plugin *plugin, struct Session *ps) if (mret != CURLM_OK) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Connection: %X: %s failed at %s:%d: `%s'\n"), - ps, + _("Connection: %X: %s failed at %s:%d: `%s'\n"), ps, "curl_multi_add_handle", __FILE__, __LINE__, curl_multi_strerror (mret)); return GNUNET_SYSERR; @@ -2371,9 +2342,8 @@ send_check_connections (struct Plugin *plugin, struct Session *ps) * */ static struct Session * -send_select_session (struct HTTP_PeerContext *pc, - const void *addr, size_t addrlen, - int force_address, struct Session *session) +send_select_session (struct HTTP_PeerContext *pc, const void *addr, + size_t addrlen, int force_address, struct Session *session) { struct Session *tmp = NULL; int addr_given = GNUNET_NO; @@ -2534,16 +2504,10 @@ send_select_session (struct HTTP_PeerContext *pc, * and does NOT mean that the message was not transmitted (DV) */ static ssize_t -http_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative to, - struct Session *session, - const void *addr, - size_t addrlen, - int force_address, +http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, + const char *msgbuf, size_t msgbuf_size, unsigned int priority, + struct GNUNET_TIME_Relative to, struct Session *session, + const void *addr, size_t addrlen, int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) { struct Plugin *plugin = cls; @@ -2566,9 +2530,7 @@ http_plugin_send (void *cls, GNUNET_assert (0); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n", - msgbuf_size, - GNUNET_i2s (target), - force, + msgbuf_size, GNUNET_i2s (target), force, http_plugin_address_to_string (NULL, addr, addrlen), session); GNUNET_free (force); #endif @@ -2582,13 +2544,12 @@ http_plugin_send (void *cls, pc->session_id_counter = 1; pc->last_session = NULL; memcpy (&pc->identity, target, sizeof (struct GNUNET_PeerIdentity)); - GNUNET_CONTAINER_multihashmap_put (plugin->peers, - &pc->identity.hashPubKey, + GNUNET_CONTAINER_multihashmap_put (plugin->peers, &pc->identity.hashPubKey, pc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# HTTP peers active"), - 1, GNUNET_NO); + gettext_noop ("# HTTP peers active"), 1, + GNUNET_NO); } ps = send_select_session (pc, addr, addrlen, force_address, session); /* session not existing, but address forced -> creating new session */ @@ -2659,8 +2620,8 @@ http_plugin_send (void *cls, msg->transmit_cont = cont; msg->transmit_cont_cls = cont_cls; memcpy (msg->buf, msgbuf, msgbuf_size); - GNUNET_CONTAINER_DLL_insert (ps->pending_msgs_head, - ps->pending_msgs_tail, msg); + GNUNET_CONTAINER_DLL_insert (ps->pending_msgs_head, ps->pending_msgs_tail, + msg); ps->queue_length_cur += msgbuf_size; if (send_check_connections (plugin, ps) == GNUNET_SYSERR) return GNUNET_SYSERR; @@ -2767,14 +2728,12 @@ append_port (void *cls, const char *hostname) * @param asc_cls closure for asc */ static void -http_plugin_address_pretty_printer (void *cls, - const char *type, - const void *addr, - size_t addrlen, +http_plugin_address_pretty_printer (void *cls, const char *type, + const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, - GNUNET_TRANSPORT_AddressStringCallback - asc, void *asc_cls) + GNUNET_TRANSPORT_AddressStringCallback asc, + void *asc_cls) { struct PrettyPrinterContext *ppc; const void *sb; @@ -2963,16 +2922,15 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) * @param addrlen number of bytes in addr */ static void -try_connection_reversal (void *cls, - const struct sockaddr *addr, socklen_t addrlen) +try_connection_reversal (void *cls, const struct sockaddr *addr, + socklen_t addrlen) { } static void -tcp_nat_cb_add_addr (void *cls, - int add_remove, - const struct sockaddr *addr, socklen_t addrlen) +tcp_nat_cb_add_addr (void *cls, int add_remove, const struct sockaddr *addr, + socklen_t addrlen) { struct Plugin *plugin = cls; struct IPv4HttpAddress *t4 = NULL; @@ -3000,8 +2958,7 @@ tcp_nat_cb_add_addr (void *cls, { w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress)); - memcpy (&t4->ipv4_addr, - &((struct sockaddr_in *) addr)->sin_addr, + memcpy (&t4->ipv4_addr, &((struct sockaddr_in *) addr)->sin_addr, sizeof (struct in_addr)); t4->port = htons (plugin->port_inbound); @@ -3010,9 +2967,8 @@ tcp_nat_cb_add_addr (void *cls, GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, w_t4); } - plugin->env->notify_address (plugin->env->cls, - add_remove, - w_t4->addr, sizeof (struct IPv4HttpAddress)); + plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, + sizeof (struct IPv4HttpAddress)); break; case AF_INET6: @@ -3032,8 +2988,7 @@ tcp_nat_cb_add_addr (void *cls, w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); - memcpy (&t6->ipv6_addr, - &((struct sockaddr_in6 *) addr)->sin6_addr, + memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); t6->port = htons (plugin->port_inbound); @@ -3042,9 +2997,8 @@ tcp_nat_cb_add_addr (void *cls, GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, w_t6); } - plugin->env->notify_address (plugin->env->cls, - add_remove, - w_t6->addr, sizeof (struct IPv6HttpAddress)); + plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, + sizeof (struct IPv6HttpAddress)); break; default: return; @@ -3053,9 +3007,8 @@ tcp_nat_cb_add_addr (void *cls, } static void -tcp_nat_cb_remove_addr (void *cls, - int add_remove, - const struct sockaddr *addr, socklen_t addrlen) +tcp_nat_cb_remove_addr (void *cls, int add_remove, const struct sockaddr *addr, + socklen_t addrlen) { struct Plugin *plugin = cls; struct IPv4HttpAddressWrapper *w_t4 = NULL; @@ -3079,12 +3032,11 @@ tcp_nat_cb_remove_addr (void *cls, } if (w_t4 == NULL) return; - plugin->env->notify_address (plugin->env->cls, - add_remove, - w_t4->addr, sizeof (struct IPv4HttpAddress)); + plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, + sizeof (struct IPv4HttpAddress)); - GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, - plugin->ipv4_addr_tail, w_t4); + GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, + w_t4); GNUNET_free (w_t4->addr); GNUNET_free (w_t4); break; @@ -3102,12 +3054,11 @@ tcp_nat_cb_remove_addr (void *cls, } if (w_t6 == NULL) return; - plugin->env->notify_address (plugin->env->cls, - add_remove, - w_t6->addr, sizeof (struct IPv6HttpAddress)); + plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, + sizeof (struct IPv6HttpAddress)); - GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, - plugin->ipv6_addr_tail, w_t6); + GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, + w_t6); GNUNET_free (w_t6->addr); GNUNET_free (w_t6); break; @@ -3127,14 +3078,12 @@ tcp_nat_cb_remove_addr (void *cls, * @param addrlen actual lenght of the address */ static void -tcp_nat_port_map_callback (void *cls, - int add_remove, +tcp_nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen) { GNUNET_assert (cls != NULL); #if DEBUG_HTTP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "NPMC called to %s address `%s'\n", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "NPMC called to %s address `%s'\n", (add_remove == GNUNET_YES) ? "remove" : "add", GNUNET_a2s (addr, addrlen)); #endif @@ -3242,8 +3191,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) GNUNET_free (plugin); GNUNET_free (api); #if DEBUG_HTTP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Unload %s plugin complete...\n", PROTOCOL_PREFIX); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unload %s plugin complete...\n", + PROTOCOL_PREFIX); #endif return NULL; } @@ -3304,8 +3253,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) GNUNET_assert (cls != NULL); #if DEBUG_HTTP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting %s plugin...\n", PROTOCOL_PREFIX); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %s plugin...\n", + PROTOCOL_PREFIX); #endif GNUNET_asprintf (&component_name, "transport-%s", PROTOCOL_PREFIX); @@ -3333,8 +3282,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - component_name, + GNUNET_CONFIGURATION_get_value_number (env->cfg, component_name, "MAX_CONNECTIONS", &tneigh)) tneigh = 128; plugin->max_connect_per_transport = tneigh; @@ -3343,34 +3291,32 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) /* Use IPv6? */ if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv6")) { - plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, - component_name, - "USE_IPv6"); + plugin->use_ipv6 = + GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name, + "USE_IPv6"); } /* Use IPv4? */ if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv4")) { - plugin->use_ipv4 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, - component_name, - "USE_IPv4"); + plugin->use_ipv4 = + GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name, + "USE_IPv4"); } /* use local addresses? */ - if (GNUNET_CONFIGURATION_have_value (env->cfg, - component_name, "USE_LOCALADDR")) + if (GNUNET_CONFIGURATION_have_value + (env->cfg, component_name, "USE_LOCALADDR")) { - plugin->use_localaddresses = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, - component_name, - "USE_LOCALADDR"); + plugin->use_localaddresses = + GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name, + "USE_LOCALADDR"); } /* Reading port number from config file */ if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - component_name, - "PORT", &port)) || (port > 65535)) + GNUNET_CONFIGURATION_get_value_number (env->cfg, component_name, "PORT", + &port)) || (port > 65535)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - component_name, + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, _ ("Require valid port number for transport plugin `%s' in configuration!\n"), PROTOCOL_PREFIX); @@ -3387,7 +3333,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) GNUNET_CONFIGURATION_get_value_string (env->cfg, component_name, "BINDTO4", - &plugin->bind_hostname)); + &plugin-> + bind_hostname)); plugin->bind4_address = GNUNET_malloc (sizeof (struct sockaddr_in)); plugin->bind4_address->sin_family = AF_INET; plugin->bind4_address->sin_port = htons (port); @@ -3398,8 +3345,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) (AF_INET, plugin->bind_hostname, &plugin->bind4_address->sin_addr) <= 0) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - component_name, + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, _ ("Misconfigured address to bind to in configuration!\n")); GNUNET_free (plugin->bind4_address); @@ -3414,10 +3360,10 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) if ((plugin->use_ipv6 == GNUNET_YES) && (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "BINDTO6"))) { - if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, - component_name, - "BINDTO6", - &plugin->bind_hostname)) + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (env->cfg, component_name, + "BINDTO6", + &plugin->bind_hostname)) { plugin->bind6_address = GNUNET_malloc (sizeof (struct sockaddr_in6)); plugin->bind6_address->sin6_family = AF_INET6; @@ -3428,8 +3374,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) (AF_INET6, plugin->bind_hostname, &plugin->bind6_address->sin6_addr) <= 0) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - component_name, + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, _ ("Misconfigured address to bind to in configuration!\n")); GNUNET_free (plugin->bind6_address); @@ -3445,22 +3390,17 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) /* Reading HTTPS crypto related configuration */ /* Get crypto init string from config */ if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (env->cfg, - "transport-https", + GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-https", "CRYPTO_INIT", &plugin->crypto_init)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (env->cfg, - "transport-https", - "KEY_FILE", - &key_file)) || + GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https", + "KEY_FILE", &key_file)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (env->cfg, - "transport-https", + GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https", "CERT_FILE", &cert_file))) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "https", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", _ ("Required configuration options missing in section `%s'\n"), "transport-https"); @@ -3472,8 +3412,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) } /* read key & certificates from file */ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Loading TLS certificate `%s' `%s'\n", key_file, cert_file); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading TLS certificate `%s' `%s'\n", + key_file, cert_file); plugin->key = load_certificate (key_file); plugin->cert = load_certificate (cert_file); @@ -3491,14 +3431,14 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) "No usable TLS certificate found, creating certificate\n"); #endif errno = 0; - certcreation = GNUNET_OS_start_process (NULL, NULL, - "gnunet-transport-certificate-creation", - "gnunet-transport-certificate-creation", - key_file, cert_file, NULL); + certcreation = + GNUNET_OS_start_process (NULL, NULL, + "gnunet-transport-certificate-creation", + "gnunet-transport-certificate-creation", + key_file, cert_file, NULL); if (certcreation == NULL) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "https", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", _ ("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n")); GNUNET_free (key_file); @@ -3514,8 +3454,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) } if ((plugin->key == NULL) || (plugin->cert == NULL)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "https", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", _ ("No usable TLS certificate found and creating one failed!\n"), "transport-https"); @@ -3549,15 +3488,14 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) #if BUILD_HTTPS MHD_USE_SSL | #endif - MHD_USE_IPv6, - port, + MHD_USE_IPv6, port, &mhd_accept_cb, plugin, &mhd_access_cb, plugin, MHD_OPTION_SOCK_ADDR, tmp, MHD_OPTION_CONNECTION_LIMIT, - (unsigned int) - plugin->max_connect_per_transport, + (unsigned int) plugin-> + max_connect_per_transport, #if BUILD_HTTPS MHD_OPTION_HTTPS_PRIORITIES, plugin->crypto_init, @@ -3589,16 +3527,15 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) #if BUILD_HTTPS MHD_USE_SSL | #endif - MHD_NO_FLAG, - port, + MHD_NO_FLAG, port, &mhd_accept_cb, plugin, &mhd_access_cb, plugin, MHD_OPTION_SOCK_ADDR, (struct sockaddr_in *) plugin->bind4_address, MHD_OPTION_CONNECTION_LIMIT, - (unsigned int) - plugin->max_connect_per_transport, + (unsigned int) plugin-> + max_connect_per_transport, #if BUILD_HTTPS MHD_OPTION_HTTPS_PRIORITIES, plugin->crypto_init, @@ -3685,8 +3622,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) if (NULL == plugin->multi_handle) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - component_name, + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, _ ("Could not initialize curl multi handle, failed to start %s plugin!\n"), PROTOCOL_PREFIX); @@ -3695,19 +3631,17 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) return NULL; } - ret = GNUNET_SERVICE_get_server_addresses (component_name, - env->cfg, &addrs, &addrlens); + ret = + GNUNET_SERVICE_get_server_addresses (component_name, env->cfg, &addrs, + &addrlens); if (ret != GNUNET_SYSERR) { - plugin->nat = GNUNET_NAT_register (env->cfg, - GNUNET_YES, - port, - (unsigned int) ret, - (const struct sockaddr **) addrs, - addrlens, - &tcp_nat_port_map_callback, - &try_connection_reversal, plugin); + plugin->nat = + GNUNET_NAT_register (env->cfg, GNUNET_YES, port, (unsigned int) ret, + (const struct sockaddr **) addrs, addrlens, + &tcp_nat_port_map_callback, + &try_connection_reversal, plugin); while (ret > 0) { ret--; @@ -3719,11 +3653,9 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) } else { - plugin->nat = GNUNET_NAT_register (env->cfg, - GNUNET_YES, - 0, - 0, NULL, NULL, - NULL, &try_connection_reversal, plugin); + plugin->nat = + GNUNET_NAT_register (env->cfg, GNUNET_YES, 0, 0, NULL, NULL, NULL, + &try_connection_reversal, plugin); } plugin->peers = GNUNET_CONTAINER_multihashmap_create (10); diff --git a/src/transport/plugin_transport_smtp.c b/src/transport/plugin_transport_smtp.c index 074bc16fc..1b9f5fb72 100644 --- a/src/transport/plugin_transport_smtp.c +++ b/src/transport/plugin_transport_smtp.c @@ -145,8 +145,8 @@ static GNUNET_CronTime last_transmission; /** ******************** Base64 encoding ***********/ #define FILLCHAR '=' -static char *cvt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; +static char *cvt = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; /** * Encode into Base64. @@ -171,8 +171,10 @@ base64_encode (const char *data, unsigned int len, char **output) (*output)[ret++] = '\n'; \ } ret = 0; - opt = GNUNET_malloc (2 + (((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)) / - MAX_CHAR_PER_LINE); + opt = + GNUNET_malloc (2 + + (((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + + 2)) / MAX_CHAR_PER_LINE); /* message must start with \r\n for libesmtp */ *output = opt; opt[0] = '\r'; @@ -361,17 +363,14 @@ listenAndDistribute (void *unused) if (ntohs (mp->header.size) != size) { GNUNET_GE_LOG (ectx, - GNUNET_GE_WARNING | GNUNET_GE_BULK | - GNUNET_GE_USER, - _ - ("Received malformed message via %s. Ignored.\n"), + GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, + _("Received malformed message via %s. Ignored.\n"), "SMTP"); #if DEBUG_SMTP GNUNET_GE_LOG (ectx, - GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | - GNUNET_GE_USER, - "Size returned by base64=%d, in the msg=%d.\n", - size, ntohl (mp->size)); + GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, + "Size returned by base64=%d, in the msg=%d.\n", size, + ntohl (mp->size)); #endif GNUNET_free (out); goto END; @@ -384,8 +383,7 @@ listenAndDistribute (void *unused) coreMP->tsession = NULL; coreMP->sender = mp->sender; #if DEBUG_SMTP - GNUNET_GE_LOG (ectx, - GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, + GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, "SMTP message passed to the core.\n"); #endif @@ -393,8 +391,7 @@ listenAndDistribute (void *unused) } END: #if DEBUG_SMTP - GNUNET_GE_LOG (ectx, - GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, + GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER, "SMTP message processed.\n"); #endif if (fdes != NULL) @@ -423,8 +420,9 @@ api_verify_hello (const GNUNET_MessageHello * hello) maddr = (const EmailAddress *) &hello[1]; if ((ntohs (hello->header.size) != sizeof (GNUNET_MessageHello) + ntohs (hello->senderAddressSize)) || - (maddr->senderAddress[ntohs (hello->senderAddressSize) - 1 - - FILTER_STRING_SIZE] != '\0')) + (maddr-> + senderAddress[ntohs (hello->senderAddressSize) - 1 - + FILTER_STRING_SIZE] != '\0')) { GNUNET_GE_BREAK (ectx, 0); return GNUNET_SYSERR; /* obviously invalid */ @@ -449,13 +447,11 @@ api_create_hello () EmailAddress *haddr; int i; - GNUNET_GC_get_configuration_value_string (coreAPI->cfg, - "SMTP", "FILTER", + GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "SMTP", "FILTER", "X-mailer: GNUnet", &filter); if (NULL == strstr (filter, ": ")) { - GNUNET_GE_LOG (ectx, - GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, + GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, _("SMTP filter string to invalid, lacks ': '\n")); GNUNET_free (filter); return NULL; @@ -464,8 +460,7 @@ api_create_hello () if (strlen (filter) > FILTER_STRING_SIZE) { filter[FILTER_STRING_SIZE] = '\0'; - GNUNET_GE_LOG (ectx, - GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, + GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER, _("SMTP filter string to long, capped to `%s'\n"), filter); } i = (strlen (email) + 8) & (~7); /* make multiple of 8 */ @@ -521,8 +516,8 @@ get_message (void **buf, int *len, void *cls) * @return GNUNET_SYSERR on error, GNUNET_OK on success */ static int -api_send (GNUNET_TSession * tsession, - const void *msg, const unsigned int size, int important) +api_send (GNUNET_TSession * tsession, const void *msg, const unsigned int size, + int important) { const GNUNET_MessageHello *hello; const EmailAddress *haddr; @@ -561,10 +556,9 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_IMMEDIATE, - _("SMTP: `%s' failed: %s.\n"), - "smtp_create_session", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"), + "smtp_create_session", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); GNUNET_mutex_unlock (lock); return GNUNET_SYSERR; } @@ -572,10 +566,9 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_IMMEDIATE, - _("SMTP: `%s' failed: %s.\n"), - "smtp_set_server", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_IMMEDIATE, _("SMTP: `%s' failed: %s.\n"), + "smtp_set_server", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); smtp_destroy_session (session); GNUNET_mutex_unlock (lock); return GNUNET_SYSERR; @@ -586,10 +579,9 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_BULK, - _("SMTP: `%s' failed: %s.\n"), - "smtp_add_message", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), + "smtp_add_message", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); smtp_destroy_session (session); GNUNET_mutex_unlock (lock); return GNUNET_SYSERR; @@ -606,10 +598,9 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_BULK, - _("SMTP: `%s' failed: %s.\n"), - "smtp_set_header", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), + "smtp_set_header", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); smtp_destroy_session (session); GNUNET_mutex_unlock (lock); GNUNET_free (filter); @@ -630,19 +621,17 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_BULK, - _("SMTP: `%s' failed: %s.\n"), - "smtp_size_set_estimate", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), + "smtp_size_set_estimate", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); } if (0 == smtp_set_messagecb (message, &get_message, &gm_cls)) { GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_BULK, - _("SMTP: `%s' failed: %s.\n"), - "smtp_set_messagecb", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), + "smtp_set_messagecb", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); smtp_destroy_session (session); GNUNET_mutex_unlock (lock); GNUNET_free (gm_cls.ebody); @@ -653,10 +642,9 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_BULK, - _("SMTP: `%s' failed: %s.\n"), - "smtp_add_recipient", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), + "smtp_add_recipient", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); smtp_destroy_session (session); GNUNET_mutex_unlock (lock); return GNUNET_SYSERR; @@ -665,10 +653,9 @@ api_send (GNUNET_TSession * tsession, { GNUNET_GE_LOG (ectx, GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER | - GNUNET_GE_BULK, - _("SMTP: `%s' failed: %s.\n"), - "smtp_start_session", - smtp_strerror (smtp_errno (), ebuf, EBUF_LEN)); + GNUNET_GE_BULK, _("SMTP: `%s' failed: %s.\n"), + "smtp_start_session", smtp_strerror (smtp_errno (), ebuf, + EBUF_LEN)); smtp_destroy_session (session); GNUNET_mutex_unlock (lock); GNUNET_free (gm_cls.ebody); @@ -694,8 +681,8 @@ api_send (GNUNET_TSession * tsession, * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed */ static int -api_connect (const GNUNET_MessageHello * hello, - GNUNET_TSession ** tsessionPtr, int may_reuse) +api_connect (const GNUNET_MessageHello * hello, GNUNET_TSession ** tsessionPtr, + int may_reuse) { GNUNET_TSession *tsession; @@ -739,8 +726,8 @@ api_start_transport_server () if (dispatchThread == NULL) { GNUNET_GE_DIE_STRERROR (ectx, - GNUNET_GE_ADMIN | GNUNET_GE_BULK | - GNUNET_GE_FATAL, "pthread_create"); + GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL, + "pthread_create"); return GNUNET_SYSERR; } return GNUNET_OK; @@ -765,8 +752,8 @@ api_stop_transport_server () * Convert SMTP hello to an IP address (always fails). */ static int -api_hello_to_address (const GNUNET_MessageHello * hello, - void **sa, unsigned int *sa_len) +api_hello_to_address (const GNUNET_MessageHello * hello, void **sa, + unsigned int *sa_len) { return GNUNET_SYSERR; } @@ -807,42 +794,34 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core) ectx = core->ectx; if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "EMAIL")) { - GNUNET_GE_LOG (ectx, - GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER, + GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER, _ ("No email-address specified, can not start SMTP transport.\n")); return NULL; } - GNUNET_GC_get_configuration_value_number (coreAPI->cfg, - "SMTP", - "MTU", - 1200, + GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "SMTP", "MTU", 1200, SMTP_MESSAGE_SIZE, SMTP_MESSAGE_SIZE, &mtu); - GNUNET_GC_get_configuration_value_number (coreAPI->cfg, - "SMTP", - "RATELIMIT", + GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "SMTP", "RATELIMIT", 0, 0, 1024 * 1024, &rate_limit); stats = coreAPI->service_request ("stats"); if (stats != NULL) { - stat_bytesReceived - = stats->create (gettext_noop ("# bytes received via SMTP")); + stat_bytesReceived = + stats->create (gettext_noop ("# bytes received via SMTP")); stat_bytesSent = stats->create (gettext_noop ("# bytes sent via SMTP")); - stat_bytesDropped - = stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)")); + stat_bytesDropped = + stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)")); } - GNUNET_GC_get_configuration_value_filename (coreAPI->cfg, - "SMTP", - "PIPE", + GNUNET_GC_get_configuration_value_filename (coreAPI->cfg, "SMTP", "PIPE", GNUNET_DEFAULT_DAEMON_VAR_DIRECTORY "/smtp-pipe", &pipename); UNLINK (pipename); if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH)) { GNUNET_GE_LOG_STRERROR (ectx, - GNUNET_GE_ADMIN | GNUNET_GE_BULK | - GNUNET_GE_FATAL, "mkfifo"); + GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_FATAL, + "mkfifo"); GNUNET_free (pipename); coreAPI->service_release (stats); stats = NULL; @@ -854,12 +833,10 @@ inittransport_smtp (GNUNET_CoreAPIForTransport * core) GNUNET_GE_LOG_STRERROR (ectx, GNUNET_GE_ADMIN | GNUNET_GE_BULK | GNUNET_GE_WARNING, "chmod"); - GNUNET_GC_get_configuration_value_string (coreAPI->cfg, - "SMTP", "EMAIL", NULL, &email); + GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "SMTP", "EMAIL", NULL, + &email); lock = GNUNET_mutex_create (GNUNET_NO); - GNUNET_GC_get_configuration_value_string (coreAPI->cfg, - "SMTP", - "SERVER", + GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "SMTP", "SERVER", "localhost:25", &smtp_server_name); sa.sa_handler = SIG_IGN; sigemptyset (&sa.sa_mask); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index bd2f4aa6a..331203471 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -419,8 +419,7 @@ plugin_tcp_access_check (void *cls, * @param addrlen actual lenght of the address */ static void -tcp_nat_port_map_callback (void *cls, - int add_remove, +tcp_nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen) { struct Plugin *plugin = cls; @@ -429,10 +428,9 @@ tcp_nat_port_map_callback (void *cls, void *arg; size_t args; - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "NPMC called with %d for address `%s'\n", - add_remove, GNUNET_a2s (addr, addrlen)); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", + "NPMC called with %d for address `%s'\n", add_remove, + GNUNET_a2s (addr, addrlen)); /* convert 'addr' to our internal format */ switch (addr->sa_family) { @@ -445,8 +443,7 @@ tcp_nat_port_map_callback (void *cls, break; case AF_INET6: GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); - memcpy (&t6.ipv6_addr, - &((struct sockaddr_in6 *) addr)->sin6_addr, + memcpy (&t6.ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); t6.t6_port = ((struct sockaddr_in6 *) addr)->sin6_port; arg = &t6; @@ -503,8 +500,7 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen) } else { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", _("Unexpected address length: %u bytes\n"), (unsigned int) addrlen); GNUNET_break (0); @@ -515,9 +511,8 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); return NULL; } - GNUNET_snprintf (rbuf, - sizeof (rbuf), - (af == AF_INET6) ? "[%s]:%u" : "%s:%u", buf, port); + GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", + buf, port); return rbuf; } @@ -554,8 +549,7 @@ find_session_by_client (struct Plugin *plugin, * @return new session object */ static struct Session * -create_session (struct Plugin *plugin, - const struct GNUNET_PeerIdentity *target, +create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, struct GNUNET_SERVER_Client *client, int is_nat) { struct Session *ret; @@ -567,8 +561,7 @@ create_session (struct Plugin *plugin, else GNUNET_assert (client == NULL); #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Creating new session for peer `%4s'\n", GNUNET_i2s (target)); #endif @@ -600,8 +593,8 @@ create_session (struct Plugin *plugin, ret->pending_messages_tail, pm); if (is_nat != GNUNET_YES) GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# TCP sessions active"), - 1, GNUNET_NO); + gettext_noop ("# TCP sessions active"), 1, + GNUNET_NO); return ret; } @@ -645,8 +638,7 @@ do_transmit (void *cls, size_t size, void *buf) if (buf == NULL) { #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Timeout trying to transmit to peer `%4s', discarding message queue.\n", GNUNET_i2s (&session->target)); #endif @@ -661,8 +653,7 @@ do_transmit (void *cls, size_t size, void *buf) GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, session->pending_messages_tail, pos); #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Failed to transmit %u byte message to `%4s'.\n", pos->message_size, GNUNET_i2s (&session->target)); #endif @@ -729,15 +720,15 @@ do_transmit (void *cls, size_t size, void *buf) GNUNET_assert (hd == NULL); GNUNET_assert (tl == NULL); #if DEBUG_TCP > 1 - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", "Transmitting %u bytes\n", ret); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Transmitting %u bytes\n", + ret); #endif GNUNET_STATISTICS_update (plugin->env->stats, gettext_noop ("# bytes currently in TCP buffers"), -(int64_t) ret, GNUNET_NO); GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# bytes transmitted via TCP"), - ret, GNUNET_NO); + gettext_noop ("# bytes transmitted via TCP"), ret, + GNUNET_NO); return ret; } @@ -759,12 +750,11 @@ process_pending_messages (struct Session *session) if (NULL == (pm = session->pending_messages_head)) return; - session->transmit_handle - = GNUNET_SERVER_notify_transmit_ready (session->client, - pm->message_size, - GNUNET_TIME_absolute_get_remaining - (pm->timeout), - &do_transmit, session); + session->transmit_handle = + GNUNET_SERVER_notify_transmit_ready (session->client, pm->message_size, + GNUNET_TIME_absolute_get_remaining + (pm->timeout), &do_transmit, + session); } @@ -783,14 +773,14 @@ disconnect_session (struct Session *session) struct PendingMessage *pm; #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Disconnecting from `%4s' at %s.\n", GNUNET_i2s (&session->target), - (session->connect_addr != NULL) ? - tcp_address_to_string (session->plugin, - session->connect_addr, - session->connect_alen) : "*"); + (session->connect_addr != + NULL) ? tcp_address_to_string (session->plugin, + session->connect_addr, + session-> + connect_alen) : "*"); #endif /* remove from session list */ prev = NULL; @@ -816,11 +806,10 @@ disconnect_session (struct Session *session) while (NULL != (pm = session->pending_messages_head)) { #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - pm->transmit_cont != NULL - ? "Could not deliver message to `%4s'.\n" - : "Could not deliver message to `%4s', notifying.\n", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", + pm->transmit_cont != + NULL ? "Could not deliver message to `%4s'.\n" : + "Could not deliver message to `%4s', notifying.\n", GNUNET_i2s (&session->target)); #endif GNUNET_STATISTICS_update (session->plugin->env->stats, @@ -833,8 +822,8 @@ disconnect_session (struct Session *session) GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, session->pending_messages_tail, pm); if (NULL != pm->transmit_cont) - pm->transmit_cont (pm->transmit_cont_cls, - &session->target, GNUNET_SYSERR); + pm->transmit_cont (pm->transmit_cont_cls, &session->target, + GNUNET_SYSERR); GNUNET_free (pm); } GNUNET_break (session->client != NULL); @@ -850,8 +839,8 @@ disconnect_session (struct Session *session) session->client = NULL; } GNUNET_STATISTICS_update (session->plugin->env->stats, - gettext_noop ("# TCP sessions active"), - -1, GNUNET_NO); + gettext_noop ("# TCP sessions active"), -1, + GNUNET_NO); GNUNET_free_non_null (session->connect_addr); GNUNET_assert (NULL == session->transmit_handle); GNUNET_free (session); @@ -928,16 +917,10 @@ select_better_session (struct Session *s1, struct Session *s2) * and does NOT mean that the message was not transmitted (DV and NAT) */ static ssize_t -tcp_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *msg, - size_t msgbuf_size, - uint32_t priority, - struct GNUNET_TIME_Relative timeout, - struct Session *session, - const void *addr, - size_t addrlen, - int force_address, +tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, + const char *msg, size_t msgbuf_size, uint32_t priority, + struct GNUNET_TIME_Relative timeout, struct Session *session, + const void *addr, size_t addrlen, int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) { struct Plugin *plugin = cls; @@ -969,8 +952,9 @@ tcp_plugin_send (void *cls, { next = session->next; GNUNET_assert (session->client != NULL); - if (0 != memcmp (target, - &session->target, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (target, &session->target, + sizeof (struct GNUNET_PeerIdentity))) continue; if (((GNUNET_SYSERR == force_address) && (session->expecting_welcome == GNUNET_NO)) || @@ -989,8 +973,8 @@ tcp_plugin_send (void *cls, } if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO)) continue; - if ((0 != memcmp (session->connect_addr, - addr, addrlen)) && (session->is_nat == GNUNET_NO)) + if ((0 != memcmp (session->connect_addr, addr, addrlen)) && + (session->is_nat == GNUNET_NO)) continue; cand_session = select_better_session (cand_session, session); } @@ -999,8 +983,7 @@ tcp_plugin_send (void *cls, if ((session == NULL) && (addr == NULL)) { #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Asked to transmit to `%4s' without address and I have no existing connection (failing).\n", GNUNET_i2s (target)); #endif @@ -1046,8 +1029,8 @@ tcp_plugin_send (void *cls, } else { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "tcp", _("Address of unexpected length: %u\n"), addrlen); + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", + _("Address of unexpected length: %u\n"), addrlen); GNUNET_break (0); return -1; } @@ -1057,15 +1040,13 @@ tcp_plugin_send (void *cls, if (0 == plugin->max_connections) return -1; /* saturated */ - if ((is_natd == GNUNET_YES) && - (NULL != plugin->nat) && + if ((is_natd == GNUNET_YES) && (NULL != plugin->nat) && (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (plugin->nat_wait_conns, &target->hashPubKey))) { #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", _("Found valid IPv4 NAT address (creating session)!\n")); #endif session = create_session (plugin, target, NULL, GNUNET_YES); @@ -1088,14 +1069,12 @@ tcp_plugin_send (void *cls, session->pending_messages_tail, session->pending_messages_tail, pm); - GNUNET_assert (GNUNET_CONTAINER_multihashmap_put (plugin->nat_wait_conns, - &target->hashPubKey, - session, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) - == GNUNET_OK); + GNUNET_assert (GNUNET_CONTAINER_multihashmap_put + (plugin->nat_wait_conns, &target->hashPubKey, session, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == + GNUNET_OK); #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Created NAT WAIT connection to `%4s' at `%s'\n", GNUNET_i2s (target), GNUNET_a2s (sb, sbs)); #endif @@ -1114,8 +1093,7 @@ tcp_plugin_send (void *cls, if (sa == NULL) { #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Failed to create connection to `%4s' at `%s'\n", GNUNET_i2s (target), GNUNET_a2s (sb, sbs)); #endif @@ -1128,15 +1106,14 @@ tcp_plugin_send (void *cls, GNUNET_assert (0 != plugin->max_connections); plugin->max_connections--; #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Asked to transmit to `%4s', creating fresh session using address `%s'.\n", GNUNET_i2s (target), GNUNET_a2s (sb, sbs)); #endif - session = create_session (plugin, - target, - GNUNET_SERVER_connect_socket (plugin->server, - sa), GNUNET_NO); + session = + create_session (plugin, target, + GNUNET_SERVER_connect_socket (plugin->server, sa), + GNUNET_NO); session->connect_addr = GNUNET_malloc (addrlen); memcpy (session->connect_addr, addr, addrlen); session->connect_alen = addrlen; @@ -1177,8 +1154,7 @@ tcp_plugin_send (void *cls, session->pending_messages_tail, session->pending_messages_tail, pm); #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Asked to transmit %u bytes to `%s', added message to list.\n", msgbuf_size, GNUNET_i2s (target)); #endif @@ -1212,16 +1188,15 @@ tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) struct PendingMessage *pm; #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Asked to cancel session with `%4s'\n", GNUNET_i2s (target)); #endif next = plugin->sessions; while (NULL != (session = next)) { next = session->next; - if (0 != memcmp (target, - &session->target, sizeof (struct GNUNET_PeerIdentity))) + if (0 != + memcmp (target, &session->target, sizeof (struct GNUNET_PeerIdentity))) continue; pm = session->pending_messages_head; while (pm != NULL) @@ -1300,10 +1275,8 @@ append_port (void *cls, const char *hostname) * @param asc_cls closure for asc */ static void -tcp_plugin_address_pretty_printer (void *cls, - const char *type, - const void *addr, - size_t addrlen, +tcp_plugin_address_pretty_printer (void *cls, const char *type, + const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, @@ -1408,8 +1381,8 @@ tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen) if (GNUNET_OK != check_port (plugin, ntohs (v4->t4_port))) return GNUNET_SYSERR; if (GNUNET_OK != - GNUNET_NAT_test_address (plugin->nat, - &v4->ipv4_addr, sizeof (struct in_addr))) + GNUNET_NAT_test_address (plugin->nat, &v4->ipv4_addr, + sizeof (struct in_addr))) return GNUNET_SYSERR; } else @@ -1423,8 +1396,8 @@ tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen) if (GNUNET_OK != check_port (plugin, ntohs (v6->t6_port))) return GNUNET_SYSERR; if (GNUNET_OK != - GNUNET_NAT_test_address (plugin->nat, - &v6->ipv6_addr, sizeof (struct in6_addr))) + GNUNET_NAT_test_address (plugin->nat, &v6->ipv6_addr, + sizeof (struct in6_addr))) return GNUNET_SYSERR; } return GNUNET_OK; @@ -1441,8 +1414,7 @@ tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen) * @param message the actual message */ static void -handle_tcp_nat_probe (void *cls, - struct GNUNET_SERVER_Client *client, +handle_tcp_nat_probe (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; @@ -1472,34 +1444,36 @@ handle_tcp_nat_probe (void *cls, } tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *) message; - if (0 == memcmp (&tcp_nat_probe->clientIdentity, - plugin->env->my_identity, - sizeof (struct GNUNET_PeerIdentity))) + if (0 == + memcmp (&tcp_nat_probe->clientIdentity, plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity))) { /* refuse connections from ourselves */ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - session = GNUNET_CONTAINER_multihashmap_get (plugin->nat_wait_conns, - &tcp_nat_probe-> - clientIdentity.hashPubKey); + session = + GNUNET_CONTAINER_multihashmap_get (plugin->nat_wait_conns, + &tcp_nat_probe->clientIdentity. + hashPubKey); if (session == NULL) { #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", "Did NOT find session for NAT probe!\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", + "Did NOT find session for NAT probe!\n"); #endif GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", "Found session for NAT probe!\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", + "Found session for NAT probe!\n"); #endif - GNUNET_assert (GNUNET_CONTAINER_multihashmap_remove (plugin->nat_wait_conns, - &tcp_nat_probe->clientIdentity.hashPubKey, - session) == GNUNET_YES); + GNUNET_assert (GNUNET_CONTAINER_multihashmap_remove + (plugin->nat_wait_conns, + &tcp_nat_probe->clientIdentity.hashPubKey, + session) == GNUNET_YES); if (GNUNET_OK != GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) { GNUNET_break (0); @@ -1514,8 +1488,7 @@ handle_tcp_nat_probe (void *cls, session->inbound = GNUNET_NO; #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Found address `%s' for incoming connection\n", GNUNET_a2s (vaddr, alen)); #endif @@ -1540,8 +1513,8 @@ handle_tcp_nat_probe (void *cls, default: GNUNET_break_op (0); #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", "Bad address for incoming connection!\n"); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", + "Bad address for incoming connection!\n"); #endif GNUNET_free (vaddr); GNUNET_SERVER_client_drop (client); @@ -1554,8 +1527,8 @@ handle_tcp_nat_probe (void *cls, session->next = plugin->sessions; plugin->sessions = session; GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# TCP sessions active"), - 1, GNUNET_NO); + gettext_noop ("# TCP sessions active"), 1, + GNUNET_NO); process_pending_messages (session); GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -1570,8 +1543,7 @@ handle_tcp_nat_probe (void *cls, * @param message the actual message */ static void -handle_tcp_welcome (void *cls, - struct GNUNET_SERVER_Client *client, +handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; @@ -1584,30 +1556,28 @@ handle_tcp_welcome (void *cls, const struct sockaddr_in *s4; const struct sockaddr_in6 *s6; - if (0 == memcmp (&wm->clientIdentity, - plugin->env->my_identity, - sizeof (struct GNUNET_PeerIdentity))) + if (0 == + memcmp (&wm->clientIdentity, plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity))) { /* refuse connections from ourselves */ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", - "Received %s message from `%4s'.\n", - "WELCOME", GNUNET_i2s (&wm->clientIdentity)); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", + "Received %s message from `%4s'.\n", "WELCOME", + GNUNET_i2s (&wm->clientIdentity)); #endif GNUNET_STATISTICS_update (plugin->env->stats, - gettext_noop ("# TCP WELCOME messages received"), - 1, GNUNET_NO); + gettext_noop ("# TCP WELCOME messages received"), 1, + GNUNET_NO); session = find_session_by_client (plugin, client); if (session == NULL) { #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Received %s message from a `%4s', creating new session\n", "WELCOME", GNUNET_i2s (&wm->clientIdentity)); #endif @@ -1617,8 +1587,7 @@ handle_tcp_welcome (void *cls, if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) { #if DEBUG_TCP_NAT - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Found address `%s' for incoming connection\n", GNUNET_a2s (vaddr, alen)); #endif @@ -1646,8 +1615,7 @@ handle_tcp_welcome (void *cls, else { #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Did not obtain TCP socket address for incoming connection\n"); #endif } @@ -1658,8 +1626,7 @@ handle_tcp_welcome (void *cls, #if DEBUG_TCP_NAT if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Found address `%s' (already have session)\n", GNUNET_a2s (vaddr, alen)); GNUNET_free (vaddr); @@ -1695,9 +1662,10 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_TIME_Relative delay; session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; - delay = session->plugin->env->receive (session->plugin->env->cls, - &session->target, - NULL, NULL, 0, session, NULL, 0); + delay = + session->plugin->env->receive (session->plugin->env->cls, + &session->target, NULL, NULL, 0, session, + NULL, 0); if (delay.rel_value == 0) GNUNET_SERVER_receive_done (session->client, GNUNET_OK); else @@ -1715,8 +1683,7 @@ delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param message the actual message */ static void -handle_tcp_data (void *cls, - struct GNUNET_SERVER_Client *client, +handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; @@ -1740,8 +1707,7 @@ handle_tcp_data (void *cls, } session->last_activity = GNUNET_TIME_absolute_get (); #if DEBUG_TCP > 1 - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Passing %u bytes of type %u from `%4s' to transport service.\n", (unsigned int) ntohs (message->size), (unsigned int) ntohs (message->type), @@ -1756,14 +1722,14 @@ handle_tcp_data (void *cls, distance[0].value = htonl (1); distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); distance[1].value = htonl (0); - delay = plugin->env->receive (plugin->env->cls, &session->target, message, - (const struct GNUNET_TRANSPORT_ATS_Information - *) &distance, 2, session, - (GNUNET_YES == - session-> - inbound) ? NULL : session->connect_addr, - (GNUNET_YES == - session->inbound) ? 0 : session->connect_alen); + delay = + plugin->env->receive (plugin->env->cls, &session->target, message, + (const struct GNUNET_TRANSPORT_ATS_Information *) + &distance, 2, session, + (GNUNET_YES == + session->inbound) ? NULL : session->connect_addr, + (GNUNET_YES == + session->inbound) ? 0 : session->connect_alen); if (delay.rel_value == 0) { GNUNET_SERVER_receive_done (client, GNUNET_OK); @@ -1771,8 +1737,7 @@ handle_tcp_data (void *cls, else { #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Throttling receiving from `%s' for %llu ms\n", GNUNET_i2s (&session->target), (unsigned long long) delay.rel_value); @@ -1804,14 +1769,14 @@ disconnect_notify (void *cls, struct GNUNET_SERVER_Client *client) if (session == NULL) return; /* unknown, nothing to do */ #if DEBUG_TCP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Destroying session of `%4s' with %s due to network-level disconnect.\n", GNUNET_i2s (&session->target), - (session->connect_addr != NULL) ? - tcp_address_to_string (session->plugin, - session->connect_addr, - session->connect_alen) : "*"); + (session->connect_addr != + NULL) ? tcp_address_to_string (session->plugin, + session->connect_addr, + session-> + connect_alen) : "*"); #endif GNUNET_STATISTICS_update (session->plugin->env->stats, gettext_noop @@ -1837,8 +1802,8 @@ notify_send_probe (void *cls, size_t size, void *buf) size_t ret; tcp_probe_ctx->transmit_handle = NULL; - GNUNET_CONTAINER_DLL_remove (plugin->probe_head, - plugin->probe_tail, tcp_probe_ctx); + GNUNET_CONTAINER_DLL_remove (plugin->probe_head, plugin->probe_tail, + tcp_probe_ctx); if (buf == NULL) { GNUNET_CONNECTION_destroy (tcp_probe_ctx->sock, GNUNET_NO); @@ -1865,8 +1830,8 @@ notify_send_probe (void *cls, size_t size, void *buf) * @param addrlen number of bytes in addr */ static void -try_connection_reversal (void *cls, - const struct sockaddr *addr, socklen_t addrlen) +try_connection_reversal (void *cls, const struct sockaddr *addr, + socklen_t addrlen) { struct Plugin *plugin = cls; struct GNUNET_CONNECTION_Handle *sock; @@ -1886,23 +1851,23 @@ try_connection_reversal (void *cls, /* FIXME: do we need to track these probe context objects so that * we can clean them up on plugin unload? */ tcp_probe_ctx = GNUNET_malloc (sizeof (struct TCPProbeContext)); - tcp_probe_ctx->message.header.size - = htons (sizeof (struct TCP_NAT_ProbeMessage)); - tcp_probe_ctx->message.header.type - = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE); - memcpy (&tcp_probe_ctx->message.clientIdentity, - plugin->env->my_identity, sizeof (struct GNUNET_PeerIdentity)); + tcp_probe_ctx->message.header.size = + htons (sizeof (struct TCP_NAT_ProbeMessage)); + tcp_probe_ctx->message.header.type = + htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE); + memcpy (&tcp_probe_ctx->message.clientIdentity, plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity)); tcp_probe_ctx->plugin = plugin; tcp_probe_ctx->sock = sock; - GNUNET_CONTAINER_DLL_insert (plugin->probe_head, - plugin->probe_tail, tcp_probe_ctx); - tcp_probe_ctx->transmit_handle - = GNUNET_CONNECTION_notify_transmit_ready (sock, - ntohs (tcp_probe_ctx-> - message.header.size), - GNUNET_TIME_UNIT_FOREVER_REL, - ¬ify_send_probe, - tcp_probe_ctx); + GNUNET_CONTAINER_DLL_insert (plugin->probe_head, plugin->probe_tail, + tcp_probe_ctx); + tcp_probe_ctx->transmit_handle = + GNUNET_CONNECTION_notify_transmit_ready (sock, + ntohs (tcp_probe_ctx->message. + header.size), + GNUNET_TIME_UNIT_FOREVER_REL, + ¬ify_send_probe, + tcp_probe_ctx); } @@ -1938,27 +1903,21 @@ libgnunet_plugin_transport_tcp_init (void *cls) socklen_t *addrlens; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-tcp", + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp", "MAX_CONNECTIONS", &max_connections)) max_connections = 128; aport = 0; if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-tcp", - "PORT", - &bport)) || - (bport > 65535) || + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp", "PORT", + &bport)) || (bport > 65535) || ((GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-tcp", - "ADVERTISED-PORT", - &aport)) && (aport > 65535))) + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp", + "ADVERTISED-PORT", &aport)) && + (aport > 65535))) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", _ ("Require valid port number for service `%s' in configuration!\n"), "transport-tcp"); @@ -1973,8 +1932,8 @@ libgnunet_plugin_transport_tcp_init (void *cls) service = GNUNET_SERVICE_start ("transport-tcp", env->cfg); if (service == NULL) { - GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, - "tcp", _("Failed to start service.\n")); + GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "tcp", + _("Failed to start service.\n")); return NULL; } } @@ -1991,18 +1950,15 @@ libgnunet_plugin_transport_tcp_init (void *cls) plugin->lsock = NULL; if ((service != NULL) && (GNUNET_SYSERR != - (ret = GNUNET_SERVICE_get_server_addresses ("transport-tcp", - env->cfg, - &addrs, &addrlens)))) + (ret = + GNUNET_SERVICE_get_server_addresses ("transport-tcp", env->cfg, &addrs, + &addrlens)))) { - plugin->nat = GNUNET_NAT_register (env->cfg, - GNUNET_YES, - aport, - (unsigned int) ret, - (const struct sockaddr **) addrs, - addrlens, - &tcp_nat_port_map_callback, - &try_connection_reversal, plugin); + plugin->nat = + GNUNET_NAT_register (env->cfg, GNUNET_YES, aport, (unsigned int) ret, + (const struct sockaddr **) addrs, addrlens, + &tcp_nat_port_map_callback, + &try_connection_reversal, plugin); while (ret > 0) { ret--; @@ -2014,11 +1970,9 @@ libgnunet_plugin_transport_tcp_init (void *cls) } else { - plugin->nat = GNUNET_NAT_register (env->cfg, - GNUNET_YES, - 0, - 0, NULL, NULL, - NULL, &try_connection_reversal, plugin); + plugin->nat = + GNUNET_NAT_register (env->cfg, GNUNET_YES, 0, 0, NULL, NULL, NULL, + &try_connection_reversal, plugin); } api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); api->cls = plugin; @@ -2035,12 +1989,10 @@ libgnunet_plugin_transport_tcp_init (void *cls) else { if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (env->cfg, - "transport-tcp", + GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-tcp", "TIMEOUT", &idle_timeout)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", _("Failed to find option %s in section %s!\n"), "TIMEOUT", "transport-tcp"); if (plugin->nat != NULL) @@ -2063,16 +2015,14 @@ libgnunet_plugin_transport_tcp_init (void *cls) GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin); plugin->nat_wait_conns = GNUNET_CONTAINER_multihashmap_create (16); if (bport != 0) - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "tcp", _("TCP transport listening on port %llu\n"), bport); + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "tcp", + _("TCP transport listening on port %llu\n"), bport); else - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "tcp", _ ("TCP transport not listening on any port (client only)\n")); if (aport != bport) - GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, - "tcp", + GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "tcp", _ ("TCP transport advertises itself as being on port %llu\n"), aport); @@ -2102,8 +2052,8 @@ libgnunet_plugin_transport_tcp_done (void *cls) GNUNET_NAT_unregister (plugin->nat); while (NULL != (tcp_probe = plugin->probe_head)) { - GNUNET_CONTAINER_DLL_remove (plugin->probe_head, - plugin->probe_tail, tcp_probe); + GNUNET_CONTAINER_DLL_remove (plugin->probe_head, plugin->probe_tail, + tcp_probe); GNUNET_CONNECTION_destroy (tcp_probe->sock, GNUNET_NO); GNUNET_free (tcp_probe); } diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index d83807a36..3ad8014c5 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c @@ -151,18 +151,14 @@ struct Plugin * and does NOT mean that the message was not transmitted (DV) */ static ssize_t -template_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, +template_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, + const char *msgbuf, size_t msgbuf_size, unsigned int priority, struct GNUNET_TIME_Relative timeout, - struct Session *session, - const void *addr, - size_t addrlen, + struct Session *session, const void *addr, size_t addrlen, int force_address, - GNUNET_TRANSPORT_TransmitContinuation - cont, void *cont_cls) + GNUNET_TRANSPORT_TransmitContinuation cont, + void *cont_cls) { int bytes_sent = 0; @@ -203,10 +199,8 @@ template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) * @param asc_cls closure for asc */ static void -template_plugin_address_pretty_printer (void *cls, - const char *type, - const void *addr, - size_t addrlen, +template_plugin_address_pretty_printer (void *cls, const char *type, + const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index df8447a12..f9310fb8f 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -350,8 +350,8 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) * @return the number of bytes written */ static ssize_t -udp_send (struct Plugin *plugin, - const struct sockaddr *sa, const struct GNUNET_MessageHeader *msg) +udp_send (struct Plugin *plugin, const struct sockaddr *sa, + const struct GNUNET_MessageHeader *msg) { ssize_t sent; size_t slen; @@ -362,18 +362,14 @@ udp_send (struct Plugin *plugin, if (NULL == plugin->sockv4) return 0; sent = - GNUNET_NETWORK_socket_sendto (plugin->sockv4, - msg, - ntohs (msg->size), + GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, ntohs (msg->size), sa, slen = sizeof (struct sockaddr_in)); break; case AF_INET6: if (NULL == plugin->sockv6) return 0; sent = - GNUNET_NETWORK_socket_sendto (plugin->sockv6, - msg, - ntohs (msg->size), + GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, ntohs (msg->size), sa, slen = sizeof (struct sockaddr_in6)); break; default: @@ -385,8 +381,7 @@ udp_send (struct Plugin *plugin, #if DEBUG_UDP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UDP transmited %u-byte message to %s (%d: %s)\n", - (unsigned int) ntohs (msg->size), - GNUNET_a2s (sa, slen), + (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); #endif return sent; @@ -437,16 +432,10 @@ send_fragment (void *cls, const struct GNUNET_MessageHeader *msg) * still be transmitted later!) */ static ssize_t -udp_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - struct Session *session, - const void *addr, - size_t addrlen, - int force_address, +udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, + const char *msgbuf, size_t msgbuf_size, unsigned int priority, + struct GNUNET_TIME_Relative timeout, struct Session *session, + const void *addr, size_t addrlen, int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) { struct Plugin *plugin = cls; @@ -534,13 +523,12 @@ udp_plugin_send (void *cls, &target->hashPubKey, peer_session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); - peer_session->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, - UDP_MTU, - &plugin->tracker, - plugin->last_expected_delay, - &udp->header, - &send_fragment, - peer_session); + peer_session->frag = + GNUNET_FRAGMENT_context_create (plugin->env->stats, UDP_MTU, + &plugin->tracker, + plugin->last_expected_delay, + &udp->header, &send_fragment, + peer_session); } return mlen; } @@ -577,8 +565,7 @@ struct SourceInformation * @param hdr the actual message */ static void -process_inbound_tokenized_messages (void *cls, - void *client, +process_inbound_tokenized_messages (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) { struct Plugin *plugin = cls; @@ -591,8 +578,8 @@ process_inbound_tokenized_messages (void *cls, distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); distance[1].value = htonl (0); - plugin->env->receive (plugin->env->cls, - &si->sender, hdr, distance, 2, NULL, si->arg, si->args); + plugin->env->receive (plugin->env->cls, &si->sender, hdr, distance, 2, NULL, + si->arg, si->args); } @@ -605,8 +592,7 @@ process_inbound_tokenized_messages (void *cls, * @param sender_addr_len number of bytes in sender_addr */ static void -process_udp_message (struct Plugin *plugin, - const struct UDPMessage *msg, +process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, const struct sockaddr *sender_addr, socklen_t sender_addr_len) { @@ -650,21 +636,18 @@ process_udp_message (struct Plugin *plugin, return; } #if DEBUG_UDP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "udp", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "udp", "Received message with %u bytes from peer `%s' at `%s'\n", (unsigned int) ntohs (msg->header.size), - GNUNET_i2s (&msg->sender), - GNUNET_a2s (sender_addr, sender_addr_len)); + GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr, + sender_addr_len)); #endif /* iterate over all embedded messages */ si.sender = msg->sender; si.arg = arg; si.args = args; - GNUNET_SERVER_mst_receive (plugin->mst, - &si, - (const char *) &msg[1], + GNUNET_SERVER_mst_receive (plugin->mst, &si, (const char *) &msg[1], ntohs (msg->header.size) - sizeof (struct UDPMessage), GNUNET_YES, GNUNET_NO); } @@ -691,8 +674,7 @@ fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_break (0); return; } - process_udp_message (rc->plugin, - (const struct UDPMessage *) msg, + process_udp_message (rc->plugin, (const struct UDPMessage *) msg, rc->src_addr, rc->addr_len); } @@ -713,13 +695,11 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) struct UDPMessage *udp; #if DEBUG_UDP - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "udp", - "Sending ACK to `%s'\n", + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "udp", "Sending ACK to `%s'\n", GNUNET_a2s (rc->src_addr, - (rc->src_addr->sa_family == AF_INET) - ? sizeof (struct sockaddr_in) - : sizeof (struct sockaddr_in6))); + (rc->src_addr->sa_family == + AF_INET) ? sizeof (struct sockaddr_in) : + sizeof (struct sockaddr_in6))); #endif udp = (struct UDPMessage *) buf; udp->header.size = htons ((uint16_t) msize); @@ -764,8 +744,7 @@ struct FindReceiveContext * GNUNET_NO if not. */ static int -find_receive_context (void *cls, - struct GNUNET_CONTAINER_HeapNode *node, +find_receive_context (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost) { struct FindReceiveContext *frc = cls; @@ -804,8 +783,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) fromlen = sizeof (addr); memset (&addr, 0, sizeof (addr)); - ret = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), - (struct sockaddr *) &addr, &fromlen); + ret = + GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), + (struct sockaddr *) &addr, &fromlen); if (ret < sizeof (struct GNUNET_MessageHeader)) { GNUNET_break_op (0); @@ -813,8 +793,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) } #if DEBUG_UDP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "UDP received %u-byte message from `%s'\n", - (unsigned int) ret, + "UDP received %u-byte message from `%s'\n", (unsigned int) ret, GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); #endif msg = (const struct GNUNET_MessageHeader *) buf; @@ -831,8 +810,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) GNUNET_break_op (0); return; } - process_udp_message (plugin, - (const struct UDPMessage *) msg, + process_udp_message (plugin, (const struct UDPMessage *) msg, (const struct sockaddr *) addr, fromlen); return; case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: @@ -857,8 +835,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) #if DEBUG_UDP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", - (unsigned int) ntohs (msg->size), - GNUNET_i2s (&udp->sender), + (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp->sender), GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); #endif @@ -875,8 +852,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) return; GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (plugin->sessions, - &udp-> - sender.hashPubKey, + &udp->sender. + hashPubKey, peer_session)); plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (peer_session->frag); @@ -887,8 +864,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) frc.rc = NULL; frc.addr = (const struct sockaddr *) addr; frc.addr_len = fromlen; - GNUNET_CONTAINER_heap_iterate (plugin->defrags, - &find_receive_context, &frc); + GNUNET_CONTAINER_heap_iterate (plugin->defrags, &find_receive_context, + &frc); now = GNUNET_TIME_absolute_get (); rc = frc.rc; if (rc == NULL) @@ -899,16 +876,14 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) rc->src_addr = (const struct sockaddr *) &rc[1]; rc->addr_len = fromlen; rc->plugin = plugin; - rc->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, - UDP_MTU, - UDP_MAX_MESSAGES_IN_DEFRAG, - rc, - &fragment_msg_proc, - &ack_proc); - rc->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrags, - rc, - (GNUNET_CONTAINER_HeapCostType) - now.abs_value); + rc->defrag = + GNUNET_DEFRAGMENT_context_create (plugin->env->stats, UDP_MTU, + UDP_MAX_MESSAGES_IN_DEFRAG, rc, + &fragment_msg_proc, &ack_proc); + rc->hnode = + GNUNET_CONTAINER_heap_insert (plugin->defrags, rc, + (GNUNET_CONTAINER_HeapCostType) now. + abs_value); } #if DEBUG_UDP GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -920,10 +895,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) { /* keep this 'rc' from expiring */ - GNUNET_CONTAINER_heap_update_cost (plugin->defrags, - rc->hnode, - (GNUNET_CONTAINER_HeapCostType) - now.abs_value); + GNUNET_CONTAINER_heap_update_cost (plugin->defrags, rc->hnode, + (GNUNET_CONTAINER_HeapCostType) now. + abs_value); } if (GNUNET_CONTAINER_heap_get_size (plugin->defrags) > UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) @@ -1026,8 +1000,8 @@ udp_plugin_check_address (void *cls, const void *addr, size_t addrlen) if (GNUNET_OK != check_port (plugin, ntohs (v4->u4_port))) return GNUNET_SYSERR; if (GNUNET_OK != - GNUNET_NAT_test_address (plugin->nat, - &v4->ipv4_addr, sizeof (struct in_addr))) + GNUNET_NAT_test_address (plugin->nat, &v4->ipv4_addr, + sizeof (struct in_addr))) return GNUNET_SYSERR; } else @@ -1041,8 +1015,8 @@ udp_plugin_check_address (void *cls, const void *addr, size_t addrlen) if (GNUNET_OK != check_port (plugin, ntohs (v6->u6_port))) return GNUNET_SYSERR; if (GNUNET_OK != - GNUNET_NAT_test_address (plugin->nat, - &v6->ipv6_addr, sizeof (struct in6_addr))) + GNUNET_NAT_test_address (plugin->nat, &v6->ipv6_addr, + sizeof (struct in6_addr))) return GNUNET_SYSERR; } return GNUNET_OK; @@ -1161,10 +1135,8 @@ append_port (void *cls, const char *hostname) * @param asc_cls closure for asc */ static void -udp_plugin_address_pretty_printer (void *cls, - const char *type, - const void *addr, - size_t addrlen, +udp_plugin_address_pretty_printer (void *cls, const char *type, + const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, @@ -1232,8 +1204,7 @@ udp_plugin_address_pretty_printer (void *cls, * @param addrlen actual lenght of the address */ static void -udp_nat_port_map_callback (void *cls, - int add_remove, +udp_nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, socklen_t addrlen) { struct Plugin *plugin = cls; @@ -1254,8 +1225,7 @@ udp_nat_port_map_callback (void *cls, break; case AF_INET6: GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); - memcpy (&u6.ipv6_addr, - &((struct sockaddr_in6 *) addr)->sin6_addr, + memcpy (&u6.ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (struct in6_addr)); u6.u6_port = ((struct sockaddr_in6 *) addr)->sin6_port; arg = &u6; @@ -1296,24 +1266,22 @@ libgnunet_plugin_transport_udp_init (void *cls) unsigned long long udp_max_bps; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-udp", "PORT", &port)) + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "PORT", + &port)) port = 2086; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-udp", + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "MAX_BPS", &udp_max_bps)) udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-udp", + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "ADVERTISED_PORT", &aport)) aport = port; if (port > 65535) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Given `%s' option is out of range: %llu > %u\n"), - "PORT", port, 65535); + _("Given `%s' option is out of range: %llu > %u\n"), "PORT", + port, 65535); return NULL; } memset (&serverAddrv6, 0, sizeof (serverAddrv6)); @@ -1336,10 +1304,9 @@ libgnunet_plugin_transport_udp_init (void *cls) api->address_to_string = &udp_address_to_string; api->check_address = &udp_plugin_check_address; - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, - "transport-udp", - "BINDTO", - &plugin->bind4_address)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-udp", + "BINDTO", &plugin->bind4_address)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Binding udp plugin to specific address: `%s'\n", @@ -1353,19 +1320,18 @@ libgnunet_plugin_transport_udp_init (void *cls) } } - if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, - "transport-udp", - "BINDTO6", - &plugin->bind6_address)) + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-udp", + "BINDTO6", &plugin->bind6_address)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Binding udp plugin to specific address: `%s'\n", plugin->bind6_address); - if (1 != inet_pton (AF_INET6, - plugin->bind6_address, &serverAddrv6.sin6_addr)) + if (1 != + inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid IPv6 address: `%s'\n"), plugin->bind6_address); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), + plugin->bind6_address); GNUNET_free_non_null (plugin->bind4_address); GNUNET_free (plugin->bind6_address); GNUNET_free (plugin); @@ -1381,8 +1347,8 @@ libgnunet_plugin_transport_udp_init (void *cls) * 2); sockets_created = 0; if ((GNUNET_YES != - GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, - "nat", "DISABLEV6"))) + GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, "nat", + "DISABLEV6"))) { plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 0); if (NULL == plugin->sockv6) @@ -1400,12 +1366,12 @@ libgnunet_plugin_transport_udp_init (void *cls) addrlen = sizeof (serverAddrv6); serverAddr = (struct sockaddr *) &serverAddrv6; #if DEBUG_UDP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Binding to IPv6 port %d\n", ntohs (serverAddrv6.sin6_port)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", + ntohs (serverAddrv6.sin6_port)); #endif tries = 0; - while (GNUNET_NETWORK_socket_bind (plugin->sockv6, - serverAddr, addrlen) != GNUNET_OK) + while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != + GNUNET_OK) { serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ #if DEBUG_UDP @@ -1430,8 +1396,8 @@ libgnunet_plugin_transport_udp_init (void *cls) } } - plugin->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, - plugin); + plugin->mst = + GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, plugin); plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); if (NULL == plugin->sockv4) { @@ -1448,8 +1414,8 @@ libgnunet_plugin_transport_udp_init (void *cls) addrlen = sizeof (serverAddrv4); serverAddr = (struct sockaddr *) &serverAddrv4; #if DEBUG_UDP - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Binding to IPv4 port %d\n", ntohs (serverAddrv4.sin_port)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", + ntohs (serverAddrv4.sin_port)); #endif tries = 0; while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != @@ -1491,12 +1457,10 @@ libgnunet_plugin_transport_udp_init (void *cls) NULL, &udp_plugin_select, plugin); if (sockets_created == 0) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); - plugin->nat = GNUNET_NAT_register (env->cfg, - GNUNET_NO, - port, - sockets_created, - (const struct sockaddr **) addrs, addrlens, - &udp_nat_port_map_callback, NULL, plugin); + plugin->nat = + GNUNET_NAT_register (env->cfg, GNUNET_NO, port, sockets_created, + (const struct sockaddr **) addrs, addrlens, + &udp_nat_port_map_callback, NULL, plugin); return api; } @@ -1534,8 +1498,8 @@ libgnunet_plugin_transport_udp_done (void *cls) struct ReceiveContext *rc; /* FIXME: clean up heap and hashmap */ - GNUNET_CONTAINER_multihashmap_iterate (plugin->sessions, - &destroy_session, NULL); + GNUNET_CONTAINER_multihashmap_iterate (plugin->sessions, &destroy_session, + NULL); GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); plugin->sessions = NULL; while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 22dda8e8b..7193e2e8b 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -419,18 +419,16 @@ find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer) } /* Forward Declaration */ -static ssize_t -unix_real_send (void *cls, - struct RetrySendContext *incoming_retry_context, - struct GNUNET_NETWORK_Handle *send_handle, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - const void *addr, - size_t addrlen, - GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls); +static ssize_t unix_real_send (void *cls, + struct RetrySendContext *incoming_retry_context, + struct GNUNET_NETWORK_Handle *send_handle, + const struct GNUNET_PeerIdentity *target, + const char *msgbuf, size_t msgbuf_size, + unsigned int priority, + struct GNUNET_TIME_Relative timeout, + const void *addr, size_t addrlen, + GNUNET_TRANSPORT_TransmitContinuation cont, + void *cont_cls); /** * Retry sending a message. @@ -451,16 +449,12 @@ retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } - unix_real_send (retry_ctx->plugin, - retry_ctx, - retry_ctx->send_handle, - &retry_ctx->target, - retry_ctx->msg, - retry_ctx->msg_size, + unix_real_send (retry_ctx->plugin, retry_ctx, retry_ctx->send_handle, + &retry_ctx->target, retry_ctx->msg, retry_ctx->msg_size, retry_ctx->priority, GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout), - retry_ctx->addr, - retry_ctx->addrlen, retry_ctx->cont, retry_ctx->cont_cls); + retry_ctx->addr, retry_ctx->addrlen, retry_ctx->cont, + retry_ctx->cont_cls); return; } @@ -487,17 +481,13 @@ retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return the number of bytes written, -1 on errors */ static ssize_t -unix_real_send (void *cls, - struct RetrySendContext *incoming_retry_context, +unix_real_send (void *cls, struct RetrySendContext *incoming_retry_context, struct GNUNET_NETWORK_Handle *send_handle, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - const void *addr, - size_t addrlen, - GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) + const struct GNUNET_PeerIdentity *target, const char *msgbuf, + size_t msgbuf_size, unsigned int priority, + struct GNUNET_TIME_Relative timeout, const void *addr, + size_t addrlen, GNUNET_TRANSPORT_TransmitContinuation cont, + void *cont_cls) { struct Plugin *plugin = cls; struct UNIXMessage *message; @@ -635,9 +625,8 @@ unix_real_send (void *cls, #if DEBUG_UNIX GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNIX transmit %u-byte message to %s (%d: %s)\n", - (unsigned int) ssize, - GNUNET_a2s (sb, sbs), - (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); + (unsigned int) ssize, GNUNET_a2s (sb, sbs), (int) sent, + (sent < 0) ? STRERROR (errno) : "ok"); #endif if (cont != NULL) { @@ -689,16 +678,10 @@ unix_real_send (void *cls, * still be transmitted later!) */ static ssize_t -unix_plugin_send (void *cls, - const struct GNUNET_PeerIdentity *target, - const char *msgbuf, - size_t msgbuf_size, - unsigned int priority, - struct GNUNET_TIME_Relative timeout, - struct Session *session, - const void *addr, - size_t addrlen, - int force_address, +unix_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, + const char *msgbuf, size_t msgbuf_size, unsigned int priority, + struct GNUNET_TIME_Relative timeout, struct Session *session, + const void *addr, size_t addrlen, int force_address, GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) { struct Plugin *plugin = cls; @@ -712,12 +695,10 @@ unix_plugin_send (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n", (char *) addr); #endif - sent = unix_real_send (cls, - NULL, - plugin->unix_sock.desc, - target, - msgbuf, msgbuf_size, - priority, timeout, addr, addrlen, cont, cont_cls); + sent = + unix_real_send (cls, NULL, plugin->unix_sock.desc, target, msgbuf, + msgbuf_size, priority, timeout, addr, addrlen, cont, + cont_cls); #if DEBUG_UNIX GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent, (char *) addr); @@ -738,8 +719,7 @@ unix_plugin_send (void *cls, * @param fromlen the length of the address */ static void -unix_demultiplexer (struct Plugin *plugin, - struct GNUNET_PeerIdentity *sender, +unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *currhdr, const struct sockaddr_un *un, size_t fromlen) { @@ -909,8 +889,8 @@ unix_transport_server_start (void *cls) return GNUNET_SYSERR; } #if DEBUG_UNIX - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "unix", "Bound to `%s'\n", &un.sun_path[0]); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "unix", "Bound to `%s'\n", + &un.sun_path[0]); #endif plugin->rs = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_zero (plugin->rs); @@ -990,10 +970,8 @@ append_port (void *cls, const char *hostname) * @param asc_cls closure for asc */ static void -unix_plugin_address_pretty_printer (void *cls, - const char *type, - const void *addr, - size_t addrlen, +unix_plugin_address_pretty_printer (void *cls, const char *type, + const void *addr, size_t addrlen, int numeric, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressStringCallback asc, @@ -1075,8 +1053,7 @@ address_notification (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct Plugin *plugin = cls; - plugin->env->notify_address (plugin->env->cls, - GNUNET_YES, + plugin->env->notify_address (plugin->env->cls, GNUNET_YES, plugin->unix_socket_path, strlen (plugin->unix_socket_path) + 1); } @@ -1095,14 +1072,14 @@ libgnunet_plugin_transport_unix_init (void *cls) int sockets_created; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-unix", "PORT", &port)) + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-unix", "PORT", + &port)) port = UNIX_NAT_DEFAULT_PORT; plugin = GNUNET_malloc (sizeof (struct Plugin)); plugin->port = port; plugin->env = env; - GNUNET_asprintf (&plugin->unix_socket_path, - "/tmp/unix-plugin-sock.%d", plugin->port); + GNUNET_asprintf (&plugin->unix_socket_path, "/tmp/unix-plugin-sock.%d", + plugin->port); api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); api->cls = plugin; diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 6ed367293..ad8d9a7a1 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -662,11 +662,10 @@ struct FragmentMessage struct Radiotap_Send *radioHeader; }; -static void -do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); -static void -free_session (struct Plugin *plugin, struct Sessionqueue *queue, - int do_free_macendpoint); +static void do_transmit (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); +static void free_session (struct Plugin *plugin, struct Sessionqueue *queue, + int do_free_macendpoint); static struct MacEndpoint *create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr); @@ -773,8 +772,9 @@ search_session (struct Plugin *plugin, const struct MacEndpoint *endpoint, while (queue != NULL) { GNUNET_assert (queue->content != NULL); - if (memcmp (peer, &queue->content->target, - sizeof (struct GNUNET_PeerIdentity)) == 0) + if (memcmp + (peer, &queue->content->target, + sizeof (struct GNUNET_PeerIdentity)) == 0) return queue->content; /* session found */ queue = queue->next; } @@ -974,27 +974,29 @@ set_next_beacon_time (struct Plugin *const plugin) //under 10 known peers: once a second if (plugin->mac_count < 10) { - plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - HALLO_BEACON_SCALING_FACTOR)); + plugin->beacon_time = + GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, + HALLO_BEACON_SCALING_FACTOR)); } //under 30 known peers: every 10 seconds else if (plugin->mac_count < 30) { - plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, - 10 * - HALLO_BEACON_SCALING_FACTOR)); + plugin->beacon_time = + GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_SECONDS, + 10 * HALLO_BEACON_SCALING_FACTOR)); } //over 30 known peers: once a minute else { - plugin->beacon_time = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MINUTES, - HALLO_BEACON_SCALING_FACTOR)); + plugin->beacon_time = + GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MINUTES, + HALLO_BEACON_SCALING_FACTOR)); } } @@ -1094,10 +1096,10 @@ get_next_queue_session (struct Plugin *plugin) if (GNUNET_TIME_absolute_get_remaining (pm->timeout).rel_value > 0) { //check if session has no message in the fragment queue - if ((session->mac->fragment_messages_out_count - < FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT) - && (session->fragment_messages_out_count - < FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION)) + if ((session->mac->fragment_messages_out_count < + FRAGMENT_QUEUE_MESSAGES_OUT_PER_MACENDPOINT) && + (session->fragment_messages_out_count < + FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION)) { plugin->pendingsessions--; GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions_head, @@ -1335,8 +1337,9 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr) fm, fm->session, endpoint); #endif - size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) - + sizeof (struct ieee80211_frame) + ntohs (hdr->size); + size = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + + sizeof (struct ieee80211_frame) + ntohs (hdr->size); fm->frag = GNUNET_malloc (size); fm->size = size; @@ -1382,9 +1385,10 @@ send_hello_beacon (struct Plugin *plugin) hello = plugin->env->get_our_hello (); hallo_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); GNUNET_assert (sizeof (struct WlanHeader) + hallo_size <= WLAN_MTU); - size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) - + sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) - + hallo_size; + size = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + + sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) + + hallo_size; msgheader = GNUNET_malloc (size); msgheader->size = htons (size); @@ -1443,16 +1447,18 @@ add_ack_for_send (void *cls, uint32_t msg_id, struct GNUNET_MessageHeader *msgheader2; uint16_t size; - size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) - + sizeof (struct ieee80211_frame) + ntohs (hdr->size) - + sizeof (struct AckSendQueue); + size = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + + sizeof (struct ieee80211_frame) + ntohs (hdr->size) + + sizeof (struct AckSendQueue); ack = GNUNET_malloc (size); ack->message_id = msg_id; ack->endpoint = endpoint; - size = sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) - + sizeof (struct ieee80211_frame) + ntohs (hdr->size); + size = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + + sizeof (struct ieee80211_frame) + ntohs (hdr->size); msgheader = (struct GNUNET_MessageHeader *) &ack[1]; ack->hdr = (struct GNUNET_MessageHeader *) &ack[1]; @@ -1528,13 +1534,12 @@ check_fragment_queue (struct Plugin *plugin) fm->session = session; fm->timeout.abs_value = pm->timeout.abs_value; fm->frag = NULL; - fm->fragcontext = GNUNET_FRAGMENT_context_create (plugin->env->stats, - WLAN_MTU, - &plugin->tracker, - GNUNET_TIME_UNIT_SECONDS, - &(pm->msg->header), - &add_message_for_send, - fm); + fm->fragcontext = + GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU, + &plugin->tracker, + GNUNET_TIME_UNIT_SECONDS, + &(pm->msg->header), + &add_message_for_send, fm); fm->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (fm->timeout), fragmentmessage_timeout, @@ -1596,8 +1601,9 @@ send_ack (struct Plugin *plugin, struct AckSendQueue *ack) getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin, ntohs (ack->hdr->size)); - bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr, - ntohs (ack->hdr->size)); + bytes = + GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr, + ntohs (ack->hdr->size)); if (bytes == GNUNET_SYSERR) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, @@ -1632,8 +1638,9 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (finish); return; } - bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, - finish->msgheader, finish->size); + bytes = + GNUNET_DISK_file_write (plugin->server_stdin_handle, finish->msgheader, + finish->size); GNUNET_assert (bytes != GNUNET_SYSERR); if (bytes != finish->size) @@ -1713,8 +1720,9 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, fm->size); - bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag, - fm->size); + bytes = + GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag, + fm->size); if (bytes == GNUNET_SYSERR) { GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, @@ -1852,9 +1860,8 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, newmsg = session->pending_message_head; GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n", - GNUNET_TIME_absolute_get_remaining (newmsg-> - timeout).rel_value, - session->mac->fragment_messages_out_count); + GNUNET_TIME_absolute_get_remaining (newmsg->timeout). + rel_value, session->mac->fragment_messages_out_count); } newmsg = GNUNET_malloc (sizeof (struct PendingMessage)); @@ -1992,8 +1999,8 @@ free_session (struct Plugin *plugin, struct Sessionqueue *queue, pm = queue->content->pending_message_head; } - GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, - endpoint->sessions_tail, queue); + GNUNET_CONTAINER_DLL_remove (endpoint->sessions_head, endpoint->sessions_tail, + queue); if (endpoint->sessions_head == NULL && do_free_macendpoint == GNUNET_YES) { @@ -2033,8 +2040,9 @@ wlan_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) // content is never NULL GNUNET_assert (queue->content != NULL); queue_next = queue->next; - if (memcmp (target, &(queue->content->target), - sizeof (struct GNUNET_PeerIdentity)) == 0) + if (memcmp + (target, &(queue->content->target), + sizeof (struct GNUNET_PeerIdentity)) == 0) { free_session (plugin, queue, GNUNET_YES); } @@ -2113,8 +2121,8 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) ntohs (hdr->size)); #endif - if (ntohs (hdr->size) < sizeof (struct WlanHeader) - + sizeof (struct GNUNET_MessageHeader)) + if (ntohs (hdr->size) < + sizeof (struct WlanHeader) + sizeof (struct GNUNET_MessageHeader)) { //packet not big enought return; @@ -2149,13 +2157,14 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) sizeof (struct WlanHeader)); #endif //try if it is a hello message - if (ntohs (wlanheader->header.size) >= ntohs (temp_hdr->size) - + sizeof (struct WlanHeader)) + if (ntohs (wlanheader->header.size) >= + ntohs (temp_hdr->size) + sizeof (struct WlanHeader)) { if (ntohs (temp_hdr->type) == GNUNET_MESSAGE_TYPE_HELLO) { - if (GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) - temp_hdr, &tmpsource) == GNUNET_OK) + if (GNUNET_HELLO_get_id + ((const struct GNUNET_HELLO_Message *) temp_hdr, + &tmpsource) == GNUNET_OK) { session = create_session (plugin, endpoint, &tmpsource); } @@ -2186,8 +2195,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) //"receive" the message - if (memcmp (&wlanheader->source, &session->target, - sizeof (struct GNUNET_PeerIdentity)) != 0) + if (memcmp + (&wlanheader->source, &session->target, + sizeof (struct GNUNET_PeerIdentity)) != 0) { //wrong peer id #if DEBUG_wlan @@ -2198,8 +2208,9 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) return; } - if (memcmp (&wlanheader->target, plugin->env->my_identity, - sizeof (struct GNUNET_PeerIdentity)) != 0) + if (memcmp + (&wlanheader->target, plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity)) != 0) { //wrong peer id #if DEBUG_wlan @@ -2252,8 +2263,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Calling plugin->env->receive for session %p; %s; size: %u\n", session, wlan_plugin_address_to_string (NULL, - session->mac-> - addr.mac, 6), + session->mac->addr. + mac, 6), htons (hdr->size)); #endif @@ -2291,22 +2302,20 @@ wlan_data_helper (void *cls, struct Session_light *session_light, #if DEBUG_wlan GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n", - ntohs (hdr->size), - wlan_plugin_address_to_string (NULL, - session_light->addr.mac, - 6)); + ntohs (hdr->size), wlan_plugin_address_to_string (NULL, + session_light-> + addr.mac, + 6)); #endif if (session_light->macendpoint == NULL) { - session_light->macendpoint = get_macendpoint (plugin, - &session_light->addr, - GNUNET_NO); + session_light->macendpoint = + get_macendpoint (plugin, &session_light->addr, GNUNET_NO); } - GNUNET_assert (GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) - &hdr[1], - &(session_light->session->target)) != - GNUNET_SYSERR); + GNUNET_assert (GNUNET_HELLO_get_id + ((const struct GNUNET_HELLO_Message *) &hdr[1], + &(session_light->session->target)) != GNUNET_SYSERR); } @@ -2318,9 +2327,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, GNUNET_assert (session_light != NULL); if (session_light->macendpoint == NULL) { - session_light->macendpoint = get_macendpoint (plugin, - &session_light->addr, - GNUNET_YES); + session_light->macendpoint = + get_macendpoint (plugin, &session_light->addr, GNUNET_YES); } #if DEBUG_wlan @@ -2355,9 +2363,8 @@ wlan_data_helper (void *cls, struct Session_light *session_light, GNUNET_assert (session_light != NULL); if (session_light->macendpoint == NULL) { - session_light->macendpoint = get_macendpoint (plugin, - &session_light->addr, - GNUNET_NO); + session_light->macendpoint = + get_macendpoint (plugin, &session_light->addr, GNUNET_NO); } if (session_light->macendpoint == NULL) @@ -2365,10 +2372,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light, #if DEBUG_wlan GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n", - ntohs (hdr->size), - wlan_plugin_address_to_string (NULL, - session_light->addr.mac, - 6)); + ntohs (hdr->size), wlan_plugin_address_to_string (NULL, + session_light-> + addr. + mac, + 6)); #endif return; } @@ -2469,16 +2477,16 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } if (GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_add - (endpoint->last_activity, MACENDPOINT_TIMEOUT)).rel_value == 0) + (GNUNET_TIME_absolute_add (endpoint->last_activity, MACENDPOINT_TIMEOUT)). + rel_value == 0) { free_macendpoint (endpoint->plugin, endpoint); } else { - endpoint->timeout_task = GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, - &macendpoint_timeout, - endpoint); + endpoint->timeout_task = + GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout, + endpoint); } } @@ -2497,16 +2505,15 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr) newend->plugin = plugin; newend->addr = *addr; newend->fragment_messages_out_count = 0; - newend->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, - WLAN_MTU, - MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, - newend, - &wlan_data_message_handler, - &add_ack_for_send); + newend->defrag = + GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, + MESSAGES_IN_DEFRAG_QUEUE_PER_MAC, + newend, &wlan_data_message_handler, + &add_ack_for_send); newend->last_activity = GNUNET_TIME_absolute_get (); - newend->timeout_task = GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, - &macendpoint_timeout, - newend); + newend->timeout_task = + GNUNET_SCHEDULER_add_delayed (MACENDPOINT_TIMEOUT, &macendpoint_timeout, + newend); plugin->mac_count++; GNUNET_CONTAINER_DLL_insert_tail (plugin->mac_head, plugin->mac_tail, newend); @@ -2548,15 +2555,16 @@ wlan_process_helper (void *cls, void *client, #endif //call wlan_process_helper with the message inside, later with wlan: analyze signal - if (ntohs (hdr->size) < sizeof (struct ieee80211_frame) - + sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) + if (ntohs (hdr->size) < + sizeof (struct ieee80211_frame) + sizeof (struct GNUNET_MessageHeader) + + sizeof (struct Radiotap_rx)) { #if DEBUG_wlan GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Size of packet is too small; size: %u min size: %u\n", ntohs (hdr->size), - sizeof (struct ieee80211_frame) - + sizeof (struct GNUNET_MessageHeader)); + sizeof (struct ieee80211_frame) + + sizeof (struct GNUNET_MessageHeader)); #endif //GNUNET_break (0); /* FIXME: restart SUID process */ @@ -2568,12 +2576,14 @@ wlan_process_helper (void *cls, void *client, //process only if it is an broadcast or for this computer both with the gnunet bssid //check for bssid - if (memcmp (&(wlanIeeeHeader->i_addr3), &mac_bssid, - sizeof (struct MacAddress)) == 0) + if (memcmp + (&(wlanIeeeHeader->i_addr3), &mac_bssid, + sizeof (struct MacAddress)) == 0) { //check for broadcast or mac - if (memcmp (&(wlanIeeeHeader->i_addr1), &bc_all_mac, - sizeof (struct MacAddress) == 0) || + if (memcmp + (&(wlanIeeeHeader->i_addr1), &bc_all_mac, + sizeof (struct MacAddress) == 0) || memcmp (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), sizeof (struct MacAddress)) == 0) { @@ -2581,9 +2591,9 @@ wlan_process_helper (void *cls, void *client, // process the inner data - datasize = ntohs (hdr->size) - sizeof (struct ieee80211_frame) - - sizeof (struct GNUNET_MessageHeader) - - sizeof (struct Radiotap_rx); + datasize = + ntohs (hdr->size) - sizeof (struct ieee80211_frame) - + sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx); session_light = GNUNET_malloc (sizeof (struct Session_light)); memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), @@ -2670,8 +2680,9 @@ wlan_plugin_helper_read (void *cls, char mybuf[WLAN_MTU + sizeof (struct GNUNET_MessageHeader)]; ssize_t bytes; - bytes = GNUNET_DISK_file_read (plugin->server_stdout_handle, mybuf, - sizeof (mybuf)); + bytes = + GNUNET_DISK_file_read (plugin->server_stdout_handle, mybuf, + sizeof (mybuf)); if (bytes <= 0) { #if DEBUG_wlan @@ -2724,10 +2735,10 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) filenamehw, plugin->interface, testmode); #endif - plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, - plugin->server_stdout, - filenamehw, filenamehw, - plugin->interface, NULL); + plugin->server_proc = + GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, + filenamehw, filenamehw, plugin->interface, + NULL); } else if (testmode == 1) { @@ -2738,10 +2749,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) filenameloopback, plugin->interface, testmode); #endif - plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, - plugin->server_stdout, - filenameloopback, - filenameloopback, "1", NULL); + plugin->server_proc = + GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, + filenameloopback, filenameloopback, "1", NULL); } else if (testmode == 2) { @@ -2750,10 +2760,9 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n", filenameloopback, plugin->interface, testmode); #endif - plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, - plugin->server_stdout, - filenameloopback, - filenameloopback, "2", NULL); + plugin->server_proc = + GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, + filenameloopback, filenameloopback, "2", NULL); } if (plugin->server_proc == NULL) { @@ -2771,10 +2780,12 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) /* Close the read end of the write pipe */ GNUNET_DISK_pipe_close_end (plugin->server_stdin, GNUNET_DISK_PIPE_END_READ); - plugin->server_stdout_handle = GNUNET_DISK_pipe_handle (plugin->server_stdout, - GNUNET_DISK_PIPE_END_READ); - plugin->server_stdin_handle = GNUNET_DISK_pipe_handle (plugin->server_stdin, - GNUNET_DISK_PIPE_END_WRITE); + plugin->server_stdout_handle = + GNUNET_DISK_pipe_handle (plugin->server_stdout, + GNUNET_DISK_PIPE_END_READ); + plugin->server_stdin_handle = + GNUNET_DISK_pipe_handle (plugin->server_stdin, + GNUNET_DISK_PIPE_END_WRITE); GNUNET_assert (plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); @@ -2880,8 +2891,8 @@ libgnunet_plugin_transport_wlan_init (void *cls) GNUNET_BANDWIDTH_value_init (100 * 1024 * 1024 / 8), 100); - plugin->suid_tokenizer = GNUNET_SERVER_mst_create (&wlan_process_helper, - plugin); + plugin->suid_tokenizer = + GNUNET_SERVER_mst_create (&wlan_process_helper, plugin); plugin->data_tokenizer = GNUNET_SERVER_mst_create (&process_data, plugin); @@ -2899,19 +2910,17 @@ libgnunet_plugin_transport_wlan_init (void *cls) if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "TESTMODE")) { - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (env->cfg, - "transport-wlan", - "TESTMODE", - &testmode)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-wlan", + "TESTMODE", &testmode)) testmode = 0; //default value } if (GNUNET_CONFIGURATION_have_value (env->cfg, "transport-wlan", "INTERFACE")) { - if (GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-wlan", - "INTERFACE", - &(plugin->interface)) != - GNUNET_YES) + if (GNUNET_CONFIGURATION_get_value_string + (env->cfg, "transport-wlan", "INTERFACE", + &(plugin->interface)) != GNUNET_YES) { libgnunet_plugin_transport_wlan_done (api); return NULL; diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index e66e04ead..6bb187b19 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -87,20 +87,16 @@ static int ok; /** */ static void -receive (void *cls, - const struct GNUNET_PeerIdentity - *peer, const struct GNUNET_MessageHeader *message, - uint32_t distance, +receive (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message, uint32_t distance, const char *sender_address, size_t sender_address_len) { /* do nothing */ } void -notify_address (void *cls, - const char *name, - const void *addr, - size_t addrlen, struct GNUNET_TIME_Relative expires) +notify_address (void *cls, const char *name, const void *addr, size_t addrlen, + struct GNUNET_TIME_Relative expires) { } @@ -161,8 +157,7 @@ test_validation () GNUNET_assert (GNUNET_OK == api->check_address (api->cls, &soaddr, sizeof (soaddr))); ok = 0; - GNUNET_SCHEDULER_add_continuation (&unload_task, - (void *) cfg, + GNUNET_SCHEDULER_add_continuation (&unload_task, (void *) cfg, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } @@ -186,9 +181,8 @@ setup_plugin_environment () * @param c configuration to use */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { unsigned long long tneigh; char *keyfile; @@ -197,14 +191,11 @@ run (void *cls, cfg = c; /* parse configuration */ if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "TRANSPORT", - "NEIGHBOUR_LIMIT", + GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", &tneigh)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", - "HOSTKEY", &keyfile))) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -223,8 +214,8 @@ run (void *cls, return; } GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); - GNUNET_CRYPTO_hash (&my_public_key, - sizeof (my_public_key), &my_identity.hashPubKey); + GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), + &my_identity.hashPubKey); @@ -281,11 +272,10 @@ main (int argc, char *const *argv) #endif NULL); ok = 1; /* set to fail */ - ret = (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv_prog, - "test-plugin-transport", - "testcase", options, &run, NULL)) ? ok : 1; + ret = + (GNUNET_OK == + GNUNET_PROGRAM_run (5, argv_prog, "test-plugin-transport", "testcase", + options, &run, NULL)) ? ok : 1; GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); return ret; } diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 921f9ec32..f59edfb26 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -399,8 +399,8 @@ shutdown_clean () /* Evaluate results */ fail = 0; - if ((fail_notify_address == GNUNET_YES) || - (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES)) + if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) + || (fail_addr_to_str == GNUNET_YES)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 0: Test plugin functions failed\n"); @@ -530,15 +530,14 @@ static void run_connection_tests (int phase, void *cls); static struct GNUNET_TIME_Relative receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, - const struct GNUNET_TRANSPORT_ATS_Information *ats, - uint32_t ats_count, - struct Session *session, - const char *sender_address, uint16_t sender_address_len) + const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count, + struct Session *session, const char *sender_address, + uint16_t sender_address_len) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", - GNUNET_i2s (peer), - ntohs (message->type), ntohs (message->size), session); + GNUNET_i2s (peer), ntohs (message->type), ntohs (message->size), + session); if ((ntohs (message->type) >= 10) && (ntohs (message->type) < 20)) { @@ -689,9 +688,8 @@ send_execute (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("curl failed for `%s' at %s:%d: `%s'\n"), - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); + "curl_multi_perform", __FILE__, __LINE__, + curl_easy_strerror (msg->data.result)); /* sending msg failed */ curl_easy_cleanup (curl_handle); curl_handle = NULL; @@ -792,8 +790,7 @@ send_prepare (struct HTTP_Transfer *result) mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_fdset", __FILE__, __LINE__, curl_multi_strerror (mret)); return -1; @@ -801,8 +798,7 @@ send_prepare (struct HTTP_Transfer *result) mret = curl_multi_timeout (multi_handle, &to); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_timeout", __FILE__, __LINE__, curl_multi_strerror (mret)); return -1; @@ -918,13 +914,12 @@ notify_address (void *cls, int add_remove, const void *addr, size_t addrlen) } static void -plugin_env_session_end (void *cls, - const struct GNUNET_PeerIdentity *peer, +plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, struct Session *session) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Pluging tells me: session %X to peer `%s' ended\n", - session, GNUNET_i2s (peer)); + "Pluging tells me: session %X to peer `%s' ended\n", session, + GNUNET_i2s (peer)); } @@ -967,8 +962,8 @@ pretty_printer_cb (void *cls, const char *address) { if (NULL == address) return; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Plugin returned pretty address: `%s'\n", address); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Plugin returned pretty address: `%s'\n", + address); fail_pretty_printer_count++; } @@ -999,8 +994,8 @@ run_connection_tests (int phase, void *cls) /* Connecting to peer without identification */ const char *ident = ""; - GNUNET_asprintf (&host_str, - "%s://%s/%s", PROTOCOL_PREFIX, test_addr, ident); + GNUNET_asprintf (&host_str, "%s://%s/%s", PROTOCOL_PREFIX, test_addr, + ident); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer without any peer identification.\n")); test_no_ident.test_executed = GNUNET_YES; @@ -1013,8 +1008,8 @@ run_connection_tests (int phase, void *cls) const char *ident = "AAAAAAAAAA"; /* Connecting to peer with too short identification */ - GNUNET_asprintf (&host_str, - "%s://%s/%s", PROTOCOL_PREFIX, test_addr, ident); + GNUNET_asprintf (&host_str, "%s://%s/%s", PROTOCOL_PREFIX, test_addr, + ident); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Connecting to peer with too short peer identification.\n")); @@ -1044,9 +1039,8 @@ run_connection_tests (int phase, void *cls) struct GNUNET_CRYPTO_HashAsciiEncoded ident; GNUNET_CRYPTO_hash_to_enc (&my_identity.hashPubKey, &ident); - GNUNET_asprintf (&host_str, - "%s://%s/%s%s", - PROTOCOL_PREFIX, test_addr, (char *) &ident, ";0"); + GNUNET_asprintf (&host_str, "%s://%s/%s%s", PROTOCOL_PREFIX, test_addr, + (char *) &ident, ";0"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with valid peer identification.\n")); test_valid_ident.test_executed = GNUNET_YES; @@ -1083,8 +1077,8 @@ run_connection_tests (int phase, void *cls) INET_ADDRSTRLEN); port = ntohs (((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message to addres no. %u: `%s':%u\n", - count, address, port); + "Sending message to addres no. %u: `%s':%u\n", count, + address, port); } if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) { @@ -1092,19 +1086,15 @@ run_connection_tests (int phase, void *cls) INET6_ADDRSTRLEN); port = ntohs (((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message to addres no. %u: `%s':%u\n", - count, address, port); + "Sending message to addres no. %u: `%s':%u\n", count, + address, port); } msg.type = htons (type); memcpy (tmp, &msg, sizeof (struct GNUNET_MessageHeader)); - api->send (api->cls, - &my_identity, - tmp, sizeof (struct GNUNET_MessageHeader), - 0, TIMEOUT, - NULL, - tmp_addr->addr, tmp_addr->addrlen, - GNUNET_YES, - &task_send_cont, &fail_msgs_transmited_to_local_addrs); + api->send (api->cls, &my_identity, tmp, + sizeof (struct GNUNET_MessageHeader), 0, TIMEOUT, NULL, + tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, + &fail_msgs_transmited_to_local_addrs); tmp_addr = tmp_addr->next; count++; type++; @@ -1123,26 +1113,19 @@ run_connection_tests (int phase, void *cls) size = sizeof (struct GNUNET_MessageHeader); msg->size = htons (size); msg->type = htons (20); - api->send (api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL); + api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, + NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL); msg->type = htons (21); - api->send (api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); + api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, + NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); /* answer on session */ size = sizeof (struct GNUNET_MessageHeader); msg->size = htons (size); msg->type = htons (22); - api->send (api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, - &task_send_cont, NULL); + api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, + session, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); GNUNET_free (msg); /* answer on session with big message not fitting in mhd send buffer */ @@ -1150,10 +1133,8 @@ run_connection_tests (int phase, void *cls) msg = GNUNET_malloc (size); msg->size = htons (size); msg->type = htons (23); - api->send (api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL); + api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, + session, NULL, 0, GNUNET_NO, &task_send_cont, NULL); GNUNET_free (msg); return; } @@ -1178,12 +1159,10 @@ run_connection_tests (int phase, void *cls) msg2->size = htons (2 * sizeof (struct GNUNET_MessageHeader)); msg2->type = htons (31); - api->send (api->cls, - &my_identity, - (const char *) msg, 4 * sizeof (struct GNUNET_MessageHeader), - 0, TIMEOUT, NULL, - addr_head->addr, addr_head->addrlen, - GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission); + api->send (api->cls, &my_identity, (const char *) msg, + 4 * sizeof (struct GNUNET_MessageHeader), 0, TIMEOUT, NULL, + addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, + &fail_multiple_msgs_in_transmission); GNUNET_free (msg); /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ @@ -1191,12 +1170,9 @@ run_connection_tests (int phase, void *cls) msg = GNUNET_malloc (size); msg->size = htons (size); msg->type = htons (32); - api->send (api->cls, - &my_identity, - (const char *) msg, size, - 0, TIMEOUT, NULL, - addr_head->addr, addr_head->addrlen, - GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size); + api->send (api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, + NULL, addr_head->addr, addr_head->addrlen, GNUNET_NO, + &task_send_cont, &fail_msg_transmited_max_size); GNUNET_free (msg); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more tests to run\n"); } @@ -1210,9 +1186,8 @@ run_connection_tests (int phase, void *cls) * @param c configuration to use */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { char *libname; @@ -1244,14 +1219,11 @@ run (void *cls, &servicehome); if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "TRANSPORT", - "NEIGHBOUR_LIMIT", + GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", &tneigh)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", - "HOSTKEY", &keyfile))) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -1262,14 +1234,11 @@ run (void *cls, } if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - "transport-http", - "PORT", - &port)) || - (port > 65535) || (port == 0)) + GNUNET_CONFIGURATION_get_value_number (cfg, "transport-http", "PORT", + &port)) || (port > 65535) || + (port == 0)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "http", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "http", _ ("Require valid port number for transport plugin `%s' in configuration!\n"), "transport-http"); @@ -1297,8 +1266,8 @@ run (void *cls, /* load plugins... */ setup_plugin_environment (); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http"); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Loading HTTP transport plugin `%s'\n"), libname); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading HTTP transport plugin `%s'\n"), + libname); api = GNUNET_PLUGIN_load (libname, &env); GNUNET_free (libname); if (api == NULL) @@ -1322,9 +1291,9 @@ run (void *cls, cur = addr_head; while (cur != NULL) { - api->address_pretty_printer (api->cls, "http", - cur->addr, cur->addrlen, GNUNET_NO, - TEST_TIMEOUT, &pretty_printer_cb, NULL); + api->address_pretty_printer (api->cls, "http", cur->addr, cur->addrlen, + GNUNET_NO, TEST_TIMEOUT, &pretty_printer_cb, + NULL); addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen); suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen); @@ -1444,12 +1413,11 @@ main (int argc, char *const *argv) GNUNET_DISK_directory_remove (servicehome); GNUNET_CONFIGURATION_destroy (cfg); - ret = (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv_prog, - "test_gnunet_transport_plugin_http", - "testcase", options, &run, - NULL)) ? GNUNET_NO : GNUNET_YES; + ret = + (GNUNET_OK == + GNUNET_PROGRAM_run (5, argv_prog, "test_gnunet_transport_plugin_http", + "testcase", options, &run, + NULL)) ? GNUNET_NO : GNUNET_YES; if (servicehome != NULL) { diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c index e6e71c7f5..5b78f89b4 100644 --- a/src/transport/test_plugin_transport_https.c +++ b/src/transport/test_plugin_transport_https.c @@ -559,10 +559,9 @@ static void run_connection_tests (int phase, void *cls); static struct GNUNET_TIME_Relative receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, - const struct GNUNET_TRANSPORT_ATS_Information *ats, - uint32_t ats_count, - struct Session *session, - const char *sender_address, uint16_t sender_address_len) + const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count, + struct Session *session, const char *sender_address, + uint16_t sender_address_len) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", @@ -723,9 +722,8 @@ send_execute (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("curl failed for `%s' at %s:%d: `%s'\n"), - "curl_multi_perform", - __FILE__, - __LINE__, curl_easy_strerror (msg->data.result)); + "curl_multi_perform", __FILE__, __LINE__, + curl_easy_strerror (msg->data.result)); /* sending msg failed */ curl_easy_cleanup (curl_handle); curl_handle = NULL; @@ -826,8 +824,7 @@ send_prepare (struct HTTP_Transfer *result) mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_fdset", __FILE__, __LINE__, curl_multi_strerror (mret)); return -1; @@ -835,8 +832,7 @@ send_prepare (struct HTTP_Transfer *result) mret = curl_multi_timeout (multi_handle, &to); if (mret != CURLM_OK) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("%s failed at %s:%d: `%s'\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), "curl_multi_timeout", __FILE__, __LINE__, curl_multi_strerror (mret)); return -1; @@ -955,8 +951,7 @@ notify_address (void *cls, int add_remove, const void *addr, size_t addrlen) } static void -plugin_env_session_end (void *cls, - const struct GNUNET_PeerIdentity *peer, +plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, struct Session *session) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1230,9 +1225,8 @@ run_connection_tests (int phase, void *cls) * @param c configuration to use */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { char *libname; @@ -1264,14 +1258,11 @@ run (void *cls, if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "TRANSPORT", - "NEIGHBOUR_LIMIT", + GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", &tneigh)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", - "HOSTKEY", &keyfile))) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -1282,14 +1273,11 @@ run (void *cls, } if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - "transport-https", - "PORT", - &port)) || - (port > 65535) || (port == 0)) + GNUNET_CONFIGURATION_get_value_number (cfg, "transport-https", "PORT", + &port)) || (port > 65535) || + (port == 0)) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, - "https", + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", _ ("Require valid port number for transport plugin `%s' in configuration!\n"), "transport-http"); @@ -1298,9 +1286,8 @@ run (void *cls, /* Get private key file from config */ if (GNUNET_CONFIGURATION_have_value (cfg, "transport-https", "KEY_FILE")) { - GNUNET_CONFIGURATION_get_value_string (cfg, - "transport-https", - "KEY_FILE", &key_file); + GNUNET_CONFIGURATION_get_value_string (cfg, "transport-https", "KEY_FILE", + &key_file); } if (key_file == NULL) GNUNET_asprintf (&key_file, "https.key"); @@ -1319,9 +1306,8 @@ run (void *cls, /* Get private key file from config */ if (GNUNET_CONFIGURATION_have_value (cfg, "transport-https", "CERT_FILE")) { - GNUNET_CONFIGURATION_get_value_string (cfg, - "transport-https", - "CERT_FILE", &cert_file); + GNUNET_CONFIGURATION_get_value_string (cfg, "transport-https", "CERT_FILE", + &cert_file); } if (cert_file == NULL) GNUNET_asprintf (&cert_file, "https.cert"); @@ -1511,12 +1497,11 @@ main (int argc, char *const *argv) GNUNET_DISK_directory_remove (servicehome); GNUNET_CONFIGURATION_destroy (cfg); - ret = (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv_prog, - "test_gnunet_transport_plugin.https", - "testcase", options, &run, - NULL)) ? GNUNET_NO : GNUNET_YES; + ret = + (GNUNET_OK == + GNUNET_PROGRAM_run (5, argv_prog, "test_gnunet_transport_plugin.https", + "testcase", options, &run, + NULL)) ? GNUNET_NO : GNUNET_YES; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("\ndelete\n\n")); if (servicehome != NULL) { diff --git a/src/transport/test_plugin_transport_udp.c b/src/transport/test_plugin_transport_udp.c index b23d4eb67..8fbd2ab9c 100644 --- a/src/transport/test_plugin_transport_udp.c +++ b/src/transport/test_plugin_transport_udp.c @@ -89,20 +89,16 @@ static int ok; * Initialize Environment for this plugin */ static void -receive (void *cls, - const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message, - uint32_t distance, +receive (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message, uint32_t distance, const char *sender_address, size_t sender_address_len) { /* do nothing */ } void -notify_address (void *cls, - const char *name, - const void *addr, - size_t addrlen, struct GNUNET_TIME_Relative expires) +notify_address (void *cls, const char *name, const void *addr, size_t addrlen, + struct GNUNET_TIME_Relative expires) { } @@ -168,9 +164,8 @@ setup_plugin_environment () * @param c configuration to use */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *c) { unsigned long long tneigh; char *keyfile; @@ -179,14 +174,11 @@ run (void *cls, cfg = c; /* parse configuration */ if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (c, - "TRANSPORT", - "NEIGHBOUR_LIMIT", + GNUNET_CONFIGURATION_get_value_number (c, "TRANSPORT", "NEIGHBOUR_LIMIT", &tneigh)) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (c, - "GNUNETD", - "HOSTKEY", &keyfile))) + GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY", + &keyfile))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -205,8 +197,8 @@ run (void *cls, return; } GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); - GNUNET_CRYPTO_hash (&my_public_key, - sizeof (my_public_key), &my_identity.hashPubKey); + GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), + &my_identity.hashPubKey); /* load plugins... */ setup_plugin_environment (); @@ -261,11 +253,10 @@ main (int argc, char *const *argv) #endif NULL); ok = 1; /* set to fail */ - ret = (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv_prog, - "test-plugin-transport", - "testcase", options, &run, NULL)) ? ok : 1; + ret = + (GNUNET_OK == + GNUNET_PROGRAM_run (5, argv_prog, "test-plugin-transport", "testcase", + options, &run, NULL)) ? ok : 1; GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-plugin-transport"); return ret; } diff --git a/src/transport/test_plugin_transport_wlan_dummy.c b/src/transport/test_plugin_transport_wlan_dummy.c index eba4f9dbd..03dedbe4d 100644 --- a/src/transport/test_plugin_transport_wlan_dummy.c +++ b/src/transport/test_plugin_transport_wlan_dummy.c @@ -72,8 +72,9 @@ stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) char *to_radiotap; char *to_start; - sendsize = ntohs (hdr->size) - sizeof (struct Radiotap_Send) - + sizeof (struct Radiotap_rx); + sendsize = + ntohs (hdr->size) - sizeof (struct Radiotap_Send) + + sizeof (struct Radiotap_rx); if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) { @@ -335,9 +336,9 @@ testmode (int argc, char *argv[]) if (FD_ISSET (STDOUT_FILENO, &wfds)) { - ret = write (STDOUT_FILENO, - write_std.buf + write_std.pos, - write_std.size - write_std.pos); + ret = + write (STDOUT_FILENO, write_std.buf + write_std.pos, + write_std.size - write_std.pos); if (0 > ret) { closeprog = 1; @@ -358,9 +359,9 @@ testmode (int argc, char *argv[]) if (FD_ISSET (fdpout, &wfds)) { - ret = write (fdpout, - write_pout.buf + write_pout.pos, - write_pout.size - write_pout.pos); + ret = + write (fdpout, write_pout.buf + write_pout.pos, + write_pout.size - write_pout.pos); if (0 > ret) { @@ -453,9 +454,8 @@ main (int argc, char *argv[]) fprintf (stderr, "This program must be started with the operating mode as argument.\n"); fprintf (stderr, - "Usage: options\n" - "options:\n" - "1 = first loopback file\n" "2 = second loopback file\n" "\n"); + "Usage: options\n" "options:\n" "1 = first loopback file\n" + "2 = second loopback file\n" "\n"); return 1; } if (strstr (argv[1], "1") || strstr (argv[1], "2")) diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index e4638e4fc..bc2aca31b 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c @@ -232,8 +232,7 @@ get_size () } static void -notify_receive_new (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive_new (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -250,8 +249,7 @@ notify_receive_new (void *cls, #if DEBUG_MEASUREMENT if (ntohl (hdr->num) % 5000 == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got message %u of size %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", ntohl (hdr->num), ntohs (message->size)); } #endif @@ -309,11 +307,9 @@ notify_ready (void *cls, size_t size, void *buf) break; /* sometimes pack buffer full, sometimes not */ } while (size - ret >= s); - transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, - &p1.id, - s, 0, SEND_TIMEOUT, - ¬ify_ready, - NULL); + transmit_handle = + GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, SEND_TIMEOUT, + ¬ify_ready, NULL); total_bytes_sent += s; return ret; } @@ -348,9 +344,9 @@ measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; measurement_running = GNUNET_NO; - struct GNUNET_TIME_Relative duration - = GNUNET_TIME_absolute_get_difference (start_time, - GNUNET_TIME_absolute_get ()); + struct GNUNET_TIME_Relative duration = + GNUNET_TIME_absolute_get_difference (start_time, + GNUNET_TIME_absolute_get ()); if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) @@ -435,10 +431,8 @@ measurement_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "\nQuota compliance ok: \n" - "Quota allowed: %10llu kB/s\n" - "Throughput : %10llu kB/s\n", - (quota_allowed / (1024)), + "\nQuota compliance ok: \n" "Quota allowed: %10llu kB/s\n" + "Throughput : %10llu kB/s\n", (quota_allowed / (1024)), (total_bytes_sent / (duration.rel_value / 1000) / 1024)); if (failed_measurement_counter < 2) failed_measurement_counter++; @@ -509,12 +503,10 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2) current_quota_p2 / 1024); #endif - GNUNET_TRANSPORT_set_quota (p1.th, - &p2.id, + GNUNET_TRANSPORT_set_quota (p1.th, &p2.id, GNUNET_BANDWIDTH_value_init (current_quota_p1), GNUNET_BANDWIDTH_value_init (current_quota_p1)); - GNUNET_TRANSPORT_set_quota (p2.th, - &p1.id, + GNUNET_TRANSPORT_set_quota (p2.th, &p1.id, GNUNET_BANDWIDTH_value_init (current_quota_p2), GNUNET_BANDWIDTH_value_init (current_quota_p2)); GNUNET_SCHEDULER_cancel (die_task); @@ -535,12 +527,10 @@ measure (unsigned long long quota_p1, unsigned long long quota_p2) if (transmit_handle != NULL) GNUNET_TRANSPORT_notify_transmit_ready_cancel (transmit_handle); - transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, - &p1.id, - get_size (), 0, - SEND_TIMEOUT, - ¬ify_ready, - NULL); + transmit_handle = + GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (), 0, + SEND_TIMEOUT, ¬ify_ready, + NULL); } @@ -584,8 +574,7 @@ exchange_hello (void *cls, const struct GNUNET_MessageHeader *message) static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -593,15 +582,15 @@ notify_connect (void *cls, if (cls == &p1) { #if DEBUG_CONNECTIONS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); #endif } else { #if DEBUG_CONNECTIONS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); #endif } if (connected == 2) @@ -636,8 +625,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) } connected--; #if DEBUG_CONNECTIONS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", + GNUNET_i2s (peer), cls); #endif } @@ -655,19 +644,18 @@ setup_peer (struct PeerContext *p, const char *cfgname) } #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, - "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif - p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, - p, - ¬ify_receive_new, - ¬ify_connect, ¬ify_disconnect); + p->th = + GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive_new, + ¬ify_connect, ¬ify_disconnect); GNUNET_assert (p->th != NULL); } @@ -680,15 +668,15 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); - tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &try_connect, NULL); + tct = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, + NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; @@ -924,8 +912,8 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, - argv1, logger, "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv1) / sizeof (char *)) - 1, argv1, logger, + "nohelp", options, &run, &ok); ret = ok; stop_arm (&p1); stop_arm (&p2); diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c index f9ac6a8e5..02d80d410 100644 --- a/src/transport/test_transport_api.c +++ b/src/transport/test_transport_api.c @@ -115,8 +115,7 @@ end_badly () static void -notify_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -164,30 +163,27 @@ notify_ready (void *cls, size_t size, void *buf) static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); } static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", + GNUNET_i2s (peer), cls); } static void sendtask () { - th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, - &p2->id, - 256, 0, TIMEOUT, ¬ify_ready, - &p1); + th = GNUNET_TRANSPORT_notify_transmit_ready (p1->th, &p2->id, 256, 0, TIMEOUT, + ¬ify_ready, &p1); } static void @@ -195,8 +191,8 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) { char *p1_c = strdup (GNUNET_i2s (&p1->id)); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", - p1_c, GNUNET_i2s (&p2->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, + GNUNET_i2s (&p2->id)); GNUNET_free (p1_c); // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! @@ -204,20 +200,17 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, - ¬ify_receive, - ¬ify_connect, - ¬ify_disconnect, NULL); - p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, - ¬ify_receive, - ¬ify_connect, - ¬ify_disconnect, NULL); + p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect, + NULL); + p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect, + NULL); GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); } @@ -241,8 +234,8 @@ check () setTransportOptions ("test_transport_api_data.conf"); #endif ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-transport-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-transport-api", "nohelp", options, &run, &ok); return ok; } @@ -332,8 +325,8 @@ check_gnunet_nat_binary (char *binary) } if (0 != STAT (p, &statbuf)) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("stat (%s) failed: %s\n"), p, STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, + STRERROR (errno)); GNUNET_free (p); return GNUNET_SYSERR; } diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c index 08f57b670..daae553b7 100644 --- a/src/transport/test_transport_api_disconnect.c +++ b/src/transport/test_transport_api_disconnect.c @@ -185,8 +185,7 @@ end_badly () static void -notify_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -201,8 +200,8 @@ notify_receive (void *cls, msgs_recv++; } -static void -peers_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void peers_disconnect (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); static size_t notify_ready (void *cls, size_t size, void *buf) @@ -231,13 +230,12 @@ notify_ready (void *cls, size_t size, void *buf) static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); peers_connected++; if (cls == &p1) { @@ -250,12 +248,10 @@ notify_connect (void *cls, GNUNET_SCHEDULER_cancel (tct); tct = GNUNET_SCHEDULER_NO_TASK; - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, - &end_badly, NULL); - th = GNUNET_TRANSPORT_notify_transmit_ready (p1.th, - &p2.id, - 256, 0, TIMEOUT, ¬ify_ready, - &p1); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, &end_badly, NULL); + th = GNUNET_TRANSPORT_notify_transmit_ready (p1.th, &p2.id, 256, 0, TIMEOUT, + ¬ify_ready, &p1); } } @@ -263,8 +259,8 @@ notify_connect (void *cls, static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", + GNUNET_i2s (peer), cls); peers_connected--; } @@ -282,12 +278,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) GNUNET_DISK_directory_remove (p->servicehome); #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif } @@ -300,8 +297,9 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* FIXME: 'pX.id' may still be all-zeros here... */ GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); - tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &try_connect, NULL); + tct = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, + NULL); } @@ -340,16 +338,14 @@ peers_connect () ITERATIONS); GNUNET_assert (p1.th == NULL); - p1.th = GNUNET_TRANSPORT_connect (p1.cfg, - NULL, &p1, - ¬ify_receive, - ¬ify_connect, ¬ify_disconnect); + p1.th = + GNUNET_TRANSPORT_connect (p1.cfg, NULL, &p1, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect); GNUNET_assert (p2.th == NULL); - p2.th = GNUNET_TRANSPORT_connect (p2.cfg, - NULL, &p2, - ¬ify_receive, - ¬ify_connect, ¬ify_disconnect); + p2.th = + GNUNET_TRANSPORT_connect (p2.cfg, NULL, &p2, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect); GNUNET_assert (p1.th != NULL); GNUNET_assert (p2.th != NULL); @@ -360,9 +356,8 @@ peers_connect () } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; @@ -393,8 +388,8 @@ check () setTransportOptions ("test_transport_api_data.conf"); #endif ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-transport-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-transport-api", "nohelp", options, &run, &ok); stop_arm (&p1); stop_arm (&p2); diff --git a/src/transport/test_transport_api_multiaddress.c b/src/transport/test_transport_api_multiaddress.c index 63ef28862..8748e5f6c 100644 --- a/src/transport/test_transport_api_multiaddress.c +++ b/src/transport/test_transport_api_multiaddress.c @@ -165,13 +165,12 @@ end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); if (cls == &p1) { GNUNET_assert (ok >= 2); @@ -182,8 +181,8 @@ notify_connect (void *cls, if (GNUNET_SCHEDULER_NO_TASK != tct) GNUNET_SCHEDULER_cancel (tct); tct = GNUNET_SCHEDULER_NO_TASK; - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, - &end_normally, NULL); + die_task = + GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, &end_normally, NULL); } } @@ -196,8 +195,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", + GNUNET_i2s (peer), cls); } @@ -210,24 +209,24 @@ setup_peer (struct PeerContext *p, const char *cfgname) if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) { GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (p->cfg, - "PATHS", + GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome)); GNUNET_DISK_directory_remove (p->servicehome); } #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif - p->th = GNUNET_TRANSPORT_connect (p->cfg, - NULL, p, - NULL, ¬ify_connect, ¬ify_disconnect); + p->th = + GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, + ¬ify_disconnect); GNUNET_assert (p->th != NULL); } @@ -239,15 +238,15 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* FIXME: 'pX.id' may still be all-zeros here... */ GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); - tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &try_connect, NULL); + tct = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, + NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_assert (ok == 1); OKPP; @@ -284,8 +283,8 @@ check () setTransportOptions ("test_transport_api_data.conf"); #endif ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-transport-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-transport-api", "nohelp", options, &run, &ok); stop_arm (&p1); stop_arm (&p2); diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 60191394d..008bb9019 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c @@ -114,8 +114,8 @@ end () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; - fprintf (stderr, - "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); + fprintf (stderr, "\nThroughput was %llu kb/s\n", + total_bytes * 1000 / 1024 / delta); //GNUNET_asprintf(&value_name, "reliable_%s", test_name); //GAUGER ("TRANSPORT", value_name, (int)(total_bytes * 1000 / 1024 /delta), "kb/s"); //GNUNET_free(value_name); @@ -161,8 +161,7 @@ get_size (unsigned int iter) static void -notify_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -204,8 +203,8 @@ notify_receive (void *cls, if (0 != memcmp (cbuf, &hdr[1], s - sizeof (struct TestMessage))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Expected message %u with bits %u, but body did not match\n", - n, (unsigned char) n); + "Expected message %u with bits %u, but body did not match\n", n, + (unsigned char) n); if (die_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (die_task); test_failed = GNUNET_YES; @@ -215,8 +214,7 @@ notify_receive (void *cls, #if VERBOSE if (ntohl (hdr->num) % 5000 == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got message %u of size %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", ntohl (hdr->num), ntohs (message->size)); } #endif @@ -271,8 +269,8 @@ notify_ready (void *cls, size_t size, void *buf) #if VERBOSE if (n % 5000 == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message %u of size %u\n", n, s); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n, + s); } #endif n++; @@ -284,10 +282,9 @@ notify_ready (void *cls, size_t size, void *buf) if (n < TOTAL_MSGS) { if (th == NULL) - th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, - &p1->id, - s, 0, TIMEOUT, - ¬ify_ready, NULL); + th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, s, 0, + TIMEOUT, ¬ify_ready, + NULL); msg_scheduled = n; } if (n % 5000 == 0) @@ -305,19 +302,17 @@ notify_ready (void *cls, size_t size, void *buf) static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); if (cls == p1) { - GNUNET_TRANSPORT_set_quota (p1->th, - &p2->id, + GNUNET_TRANSPORT_set_quota (p1->th, &p2->id, GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), GNUNET_BANDWIDTH_value_init (1024 * 1024 * @@ -325,8 +320,7 @@ notify_connect (void *cls, } else if (cls == p2) { - GNUNET_TRANSPORT_set_quota (p2->th, - &p1->id, + GNUNET_TRANSPORT_set_quota (p2->th, &p1->id, GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), GNUNET_BANDWIDTH_value_init (1024 * 1024 * @@ -338,18 +332,16 @@ notify_connect (void *cls, static void notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", + GNUNET_i2s (peer), cls); } static void sendtask () { start_time = GNUNET_TIME_absolute_get (); - th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, - &p1->id, - get_size (0), 0, TIMEOUT, - ¬ify_ready, NULL); + th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, get_size (0), 0, + TIMEOUT, ¬ify_ready, NULL); } static void @@ -357,8 +349,8 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) { char *p1_c = strdup (GNUNET_i2s (&p1->id)); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", - p1_c, GNUNET_i2s (&p2->id)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, + GNUNET_i2s (&p2->id)); GNUNET_free (p1_c); // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! @@ -366,20 +358,17 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, - ¬ify_receive, - ¬ify_connect, - ¬ify_disconnect, NULL); - p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, - ¬ify_receive, - ¬ify_connect, - ¬ify_disconnect, NULL); + p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect, + NULL); + p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect, + NULL); GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); } @@ -403,8 +392,8 @@ check () setTransportOptions ("test_transport_api_data.conf"); #endif ok = 1; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-transport-api", "nohelp", options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-transport-api", "nohelp", options, &run, &ok); return ok; } @@ -494,8 +483,8 @@ check_gnunet_nat_binary (char *binary) } if (0 != STAT (p, &statbuf)) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("stat (%s) failed: %s\n"), p, STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, + STRERROR (errno)); GNUNET_free (p); return GNUNET_SYSERR; } diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c index 88df23eb4..5eed408c0 100644 --- a/src/transport/test_transport_api_unreliability.c +++ b/src/transport/test_transport_api_unreliability.c @@ -193,8 +193,8 @@ end () GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), "kb/s"); GNUNET_free (value_name); - fprintf (stderr, - "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); + fprintf (stderr, "\nThroughput was %llu kb/s\n", + total_bytes * 1000 / 1024 / delta); ok = result; } @@ -231,8 +231,8 @@ end_unreliably () "Transports disconnected, returning success!\n"); #endif delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; - fprintf (stderr, - "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); + fprintf (stderr, "\nThroughput was %llu kb/s\n", + total_bytes * 1000 / 1024 / delta); GNUNET_asprintf (&value_name, "unreliable_%s", test_name); GAUGER ("TRANSPORT", value_name, (int) (total_bytes * 1000 / 1024 / delta), "kb/s"); @@ -355,8 +355,7 @@ get_size (unsigned int iter) static void -notify_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -401,8 +400,7 @@ notify_receive (void *cls, #if VERBOSE if (ntohl (hdr->num) % 5 == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got message %u of size %u\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", ntohl (hdr->num), ntohs (message->size)); } #endif @@ -456,8 +454,8 @@ notify_ready (void *cls, size_t size, void *buf) #if VERBOSE if (n % 5000 == 0) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Sending message %u of size %u\n", n, s); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n, + s); } #endif n++; @@ -468,10 +466,9 @@ notify_ready (void *cls, size_t size, void *buf) while (size - ret >= s); if (n < TOTAL_MSGS) { - th_p2 = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, - &p1.id, - s, 0, TIMEOUT, - ¬ify_ready, NULL); + th_p2 = + GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, s, 0, TIMEOUT, + ¬ify_ready, NULL); msg_scheduled = n; } else @@ -500,8 +497,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) { connected--; #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' disconnected (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", + GNUNET_i2s (peer), cls); #endif if (th_p2 != NULL) { @@ -513,17 +510,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", + GNUNET_i2s (peer), cls); if (cls == &p1) { - GNUNET_TRANSPORT_set_quota (p1.th, - &p2.id, + GNUNET_TRANSPORT_set_quota (p1.th, &p2.id, GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), GNUNET_BANDWIDTH_value_init (1024 * 1024 * @@ -533,8 +528,7 @@ notify_connect (void *cls, } else { - GNUNET_TRANSPORT_set_quota (p2.th, - &p1.id, + GNUNET_TRANSPORT_set_quota (p2.th, &p1.id, GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), GNUNET_BANDWIDTH_value_init (1024 * 1024 * @@ -564,10 +558,8 @@ notify_connect (void *cls, } die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - GNUNET_TRANSPORT_notify_transmit_ready (p2.th, - &p1.id, - get_size (0), 0, TIMEOUT, - ¬ify_ready, NULL); + GNUNET_TRANSPORT_notify_transmit_ready (p2.th, &p1.id, get_size (0), 0, + TIMEOUT, ¬ify_ready, NULL); } } @@ -583,8 +575,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) { GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (p->cfg, - "PATHS", + GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS", "SERVICEHOME", &p->servicehome)); GNUNET_DISK_directory_remove (p->servicehome); @@ -592,19 +583,18 @@ setup_peer (struct PeerContext *p, const char *cfgname) #if START_ARM - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, - "gnunet-service-arm", - "gnunet-service-arm", + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", #if VERBOSE_ARM - "-L", "DEBUG", + "-L", "DEBUG", #endif - "-c", cfgname, NULL); + "-c", cfgname, NULL); #endif - p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, - p, - ¬ify_receive, - ¬ify_connect, ¬ify_disconnect); + p->th = + GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect); GNUNET_assert (p->th != NULL); } @@ -694,8 +684,8 @@ check_gnunet_nat_binary (char *binary) } if (0 != STAT (p, &statbuf)) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("stat (%s) failed: %s\n"), p, STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, + STRERROR (errno)); GNUNET_free (p); return GNUNET_SYSERR; } @@ -727,16 +717,16 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking peers to connect...\n"); GNUNET_TRANSPORT_try_connect (p2.th, &p1.id); GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); - tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &try_connect, NULL); + tct = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, + NULL); } static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); if (is_tcp) @@ -814,9 +804,9 @@ check () return 0; } - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test-transport-api-unreliability", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test-transport-api-unreliability", "nohelp", options, + &run, &ok); stop_arm (&p1); stop_arm (&p2); diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index d9e4b23d5..0d16cd1b8 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c @@ -55,8 +55,8 @@ struct TransportConfiguration static void -create_ats_information (struct ATS_peer **p, int *c_p, - struct ATS_mechanism **m, int *c_m) +create_ats_information (struct ATS_peer **p, int *c_p, struct ATS_mechanism **m, + int *c_m) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS needs addresses\n"); @@ -73,8 +73,8 @@ run_ats () int ret = 0; ats_calculate_bandwidth_distribution (ats); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Running ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Running ATS: %s \n", + (ret == 0) ? "SUCCESSFUL" : "FAILED"); return ret; } @@ -84,12 +84,13 @@ init_ats () { int ret = 0; - ats = ats_init (1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION, - create_ats_information, ats_result_cb); + ats = + ats_init (1.0, 1.0, 1.0, 50000, 5, 10, ATS_MAX_EXEC_DURATION, + create_ats_information, ats_result_cb); //GNUNET_assert (ats != NULL); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Initializing ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Initializing ATS: %s \n", + (ret == 0) ? "SUCCESSFUL" : "FAILED"); return ret; } @@ -101,8 +102,8 @@ shutdown_ats () ats_delete_problem (ats); ats_shutdown (ats); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Shutdown ATS: %s \n", (ret == 0) ? "SUCCESSFUL" : "FAILED"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown ATS: %s \n", + (ret == 0) ? "SUCCESSFUL" : "FAILED"); return ret; } @@ -123,16 +124,16 @@ dummy () static void -iterate_peer_values (void *cls, - const char *section, const char *option, const char *value) +iterate_peer_values (void *cls, const char *section, const char *option, + const char *value) { if (strcmp (option, "f") == 0) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value); } static void -iterate_mech_values (void *cls, - const char *section, const char *option, const char *value) +iterate_mech_values (void *cls, const char *section, const char *option, + const char *value) { if (strcmp (option, "f") == 0) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t %s %s\n", option, value); diff --git a/src/transport/test_transport_ats_multiple_peers.c b/src/transport/test_transport_ats_multiple_peers.c index d060a4d4b..fbc148e10 100644 --- a/src/transport/test_transport_ats_multiple_peers.c +++ b/src/transport/test_transport_ats_multiple_peers.c @@ -215,15 +215,15 @@ evaluate_measurements () stddev[0] = 0.0; for (c = 0; c < c_new; c++) { - stddev[0] += (results_new[c].duration - average[0]) * - (results_new[c].duration - average[0]); + stddev[0] += + (results_new[c].duration - average[0]) * (results_new[c].duration - + average[0]); } stddev[0] /= c_new; stddev[0] = sqrt (stddev[0]); if (!machine_parsable) - fprintf (stderr, - "new, %i measurements, average: %f stddev: %f\n", - c_new, average[0], stddev[0]); + fprintf (stderr, "new, %i measurements, average: %f stddev: %f\n", c_new, + average[0], stddev[0]); average[1] = 0.0; for (c = 0; c < c_modified; c++) @@ -235,14 +235,14 @@ evaluate_measurements () stddev[1] = 0.0; for (c = 0; c < c_modified; c++) { - stddev[1] += (results_modified[c].duration - average[1]) * - (results_modified[c].duration - average[1]); + stddev[1] += + (results_modified[c].duration - + average[1]) * (results_modified[c].duration - average[1]); } stddev[1] /= c_modified; stddev[1] = sqrt (stddev[1]); if (!machine_parsable) - fprintf (stderr, - "modified, %i measurements, average: %f stddev: %f\n", + fprintf (stderr, "modified, %i measurements, average: %f stddev: %f\n", c_modified, average[1], stddev[1]); average[2] = 0.0; @@ -254,35 +254,31 @@ evaluate_measurements () stddev[2] = 0.0; for (c = 0; c < c_unmodified; c++) { - stddev[2] += (results_unmodified[c].duration - average[2]) * - (results_unmodified[c].duration - average[2]); + stddev[2] += + (results_unmodified[c].duration - + average[2]) * (results_unmodified[c].duration - average[2]); } stddev[2] /= c_unmodified; stddev[2] = sqrt (stddev[2]); if (!machine_parsable) - fprintf (stderr, - "unmodified, %i measurements, average: %f stddev: %f\n", + fprintf (stderr, "unmodified, %i measurements, average: %f stddev: %f\n", c_unmodified, average[2], stddev[2]); if (machine_parsable) fprintf (stderr, - "peers,%i,mechs,%llu," - "new,%i,%f,%f," - "mod,%i,%f,%f," - "unmod,%i,%f,%f\n", - peers - 1, (unsigned long long) results_unmodified[0].mechs, - c_new, average[0], stddev[0], - c_modified, average[1], stddev[1], + "peers,%i,mechs,%llu," "new,%i,%f,%f," "mod,%i,%f,%f," + "unmod,%i,%f,%f\n", peers - 1, + (unsigned long long) results_unmodified[0].mechs, c_new, + average[0], stddev[0], c_modified, average[1], stddev[1], c_unmodified, average[2], stddev[2]); shutdown_peers (); } static int -stats_cb (void *cls, - const char *subsystem, - const char *name, uint64_t value, int is_persistent) +stats_cb (void *cls, const char *subsystem, const char *name, uint64_t value, + int is_persistent) { static int printed = GNUNET_NO; @@ -330,8 +326,8 @@ stats_cb (void *cls, s_state = NULL; } - if ((measurement_started == GNUNET_NO) && - (0 == strcmp (name, "ATS peers")) && (value == peers - 1)) + if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && + (value == peers - 1)) { measurement_started = GNUNET_YES; count = 1; @@ -396,12 +392,11 @@ stats_cb (void *cls, } count++; #if VERBOSE - fprintf (stderr, - "(new: %i / modified: %i / unmodified: %i) of %i \n", + fprintf (stderr, "(new: %i / modified: %i / unmodified: %i) of %i \n", c_new, c_modified, c_unmodified, MEASUREMENTS); #endif - if ((c_modified >= MEASUREMENTS) && - (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS)) + if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && + (c_unmodified >= MEASUREMENTS)) { #if !VERBOSE if (!machine_parsable) @@ -430,32 +425,32 @@ stats_cb (void *cls, { current.solution = value; if (printed == GNUNET_NO) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", - count, name, value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, + value); } if (0 == strcmp (name, "ATS peers")) { current.peers = value; if (printed == GNUNET_NO) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", - count, name, value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, + value); } if (0 == strcmp (name, "ATS mechanisms")) { current.mechs = value; if (printed == GNUNET_NO) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", - count, name, value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, + value); } if (0 == strcmp (name, "ATS duration")) { current.duration = value; if (printed == GNUNET_NO) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", - count, name, value); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, + value); } if (0 == strcmp (name, "ATS state")) { @@ -485,8 +480,8 @@ stats_cb (void *cls, break; } if (printed == GNUNET_NO) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "[%i] ATS state: %s\n", count, cont); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count, + cont); } } return GNUNET_OK; @@ -500,16 +495,21 @@ stats_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) return; - s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", - TIMEOUT, NULL, &stats_cb, NULL); - s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", - TIMEOUT, NULL, &stats_cb, NULL); - s_duration = GNUNET_STATISTICS_get (stats, "transport", "ATS duration", - TIMEOUT, NULL, &stats_cb, NULL); - s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", - TIMEOUT, NULL, &stats_cb, NULL); - s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", - TIMEOUT, NULL, &stats_cb, NULL); + s_time = + GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, + &stats_cb, NULL); + s_solution = + GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, + &stats_cb, NULL); + s_duration = + GNUNET_STATISTICS_get (stats, "transport", "ATS duration", TIMEOUT, NULL, + &stats_cb, NULL); + s_peers = + GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, + &stats_cb, NULL); + s_mechs = + GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, + NULL, &stats_cb, NULL); s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); @@ -592,8 +592,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } if (send_msg == GNUNET_YES) - t = GNUNET_TRANSPORT_notify_transmit_ready (th, - &master_deamon->id, + t = GNUNET_TRANSPORT_notify_transmit_ready (th, &master_deamon->id, sizeof (struct TestMessage), 0, SEND_TIMEOUT, &send_dummy_data_task, NULL); @@ -605,8 +604,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -633,10 +631,8 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) } static void -daemon_connect_cb (void *cls, - const struct GNUNET_PeerIdentity *first, - const struct GNUNET_PeerIdentity *second, - uint32_t distance, +daemon_connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, const struct GNUNET_CONFIGURATION_Handle *second_cfg, struct GNUNET_TESTING_Daemon *first_daemon, @@ -647,20 +643,16 @@ daemon_connect_cb (void *cls, char *secondc = strdup (GNUNET_i2s (second)); connected++; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connected peers `%s'<->`%s' (%i/%i)\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers - 1); GNUNET_free (firstc); GNUNET_free (secondc); - if (((first_daemon == ping_deamon) || - (second_daemon == ping_deamon)) && + if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) && (master_deamon != NULL) && (ping_deamon != NULL)) { - th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, - &ping_deamon->id, - NULL, NULL, - ¬ify_connect, ¬ify_disconnect); + th = GNUNET_TRANSPORT_connect (ping_deamon->cfg, &ping_deamon->id, NULL, + NULL, ¬ify_connect, ¬ify_disconnect); force_q_updates = GNUNET_YES; send_msg = GNUNET_YES; } @@ -669,8 +661,7 @@ daemon_connect_cb (void *cls, static void -daemon_start_cb (void *cls, - const struct GNUNET_PeerIdentity *id, +daemon_start_cb (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Daemon *d, const char *emsg) { @@ -693,8 +684,8 @@ daemon_start_cb (void *cls, if (master_deamon == NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Master peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n", + GNUNET_i2s (id), d->cfgfile); master_deamon = d; stats = GNUNET_STATISTICS_create ("transport", master_deamon->cfg); GNUNET_assert (stats != NULL); @@ -702,13 +693,10 @@ daemon_start_cb (void *cls, } else { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connecting peer `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s (id), GNUNET_i2s (&master_deamon->id)); - GNUNET_TESTING_daemons_connect (d, - master_deamon, - TIMEOUT, - 0, GNUNET_YES, &daemon_connect_cb, NULL); + GNUNET_TESTING_daemons_connect (d, master_deamon, TIMEOUT, 0, GNUNET_YES, + &daemon_connect_cb, NULL); } if (peers_left == 0) @@ -716,8 +704,8 @@ daemon_start_cb (void *cls, if (ping_deamon == NULL) { ping_deamon = d; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Ping peer `%s' '%s'\n", GNUNET_i2s (id), d->cfgfile); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n", + GNUNET_i2s (id), d->cfgfile); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully!\n"); @@ -735,9 +723,8 @@ daemon_start_cb (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { ok = 1; measurement_started = GNUNET_NO; @@ -748,9 +735,8 @@ run (void *cls, pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ peers_left, /* Number of outstanding connections */ peers_left, /* Number of parallel ssh connections, or peers being started at once */ - TIMEOUT, - NULL, NULL, - &daemon_start_cb, NULL, NULL, NULL, NULL); + TIMEOUT, NULL, NULL, &daemon_start_cb, + NULL, NULL, NULL, NULL); GNUNET_assert (pg != NULL); } @@ -769,9 +755,9 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, - argv, "test_transport_ats_multiple_peers", "nohelp", - options, &run, &ok); + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, + "test_transport_ats_multiple_peers", "nohelp", options, + &run, &ok); return ok; } diff --git a/src/transport/test_transport_testing.c b/src/transport/test_transport_testing.c index cd5d7ed2c..85c05df4b 100644 --- a/src/transport/test_transport_testing.c +++ b/src/transport/test_transport_testing.c @@ -86,15 +86,14 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) { char *p1_c = strdup (GNUNET_i2s (&p1->id)); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers connected: %s <-> %s\n", - p1_c, GNUNET_i2s (&p2->id)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers connected: %s <-> %s\n", p1_c, + GNUNET_i2s (&p2->id)); GNUNET_free (p1_c); end (); } static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -111,8 +110,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) } static void -notify_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -122,22 +120,19 @@ notify_receive (void *cls, static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &end_badly, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n"); p1 = GNUNET_TRANSPORT_TESTING_start_peer ("test_transport_api_tcp_peer1.conf", - ¬ify_receive, - ¬ify_connect, + ¬ify_receive, ¬ify_connect, ¬ify_disconnect, p1); p2 = GNUNET_TRANSPORT_TESTING_start_peer ("test_transport_api_tcp_peer2.conf", - ¬ify_receive, - ¬ify_connect, + ¬ify_receive, ¬ify_connect, ¬ify_disconnect, p2); if (p1 != NULL) @@ -185,9 +180,8 @@ main (int argc, char *argv[]) GNUNET_GETOPT_OPTION_END }; - GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, - argv_1, "test_transport_testing", "nohelp", - options, &run, &ret); + GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1, argv_1, + "test_transport_testing", "nohelp", options, &run, &ret); return ret; } diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index e6fcabb48..62544584c 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c @@ -41,14 +41,13 @@ struct ConnectingContext int p2_c; }; -static void -exchange_hello_last (void *cb_cls, const struct GNUNET_MessageHeader *message); -static void -exchange_hello (void *cb_cls, const struct GNUNET_MessageHeader *message); +static void exchange_hello_last (void *cb_cls, + const struct GNUNET_MessageHeader *message); +static void exchange_hello (void *cb_cls, + const struct GNUNET_MessageHeader *message); static void -notify_connect_internal (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect_internal (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -93,8 +92,7 @@ notify_connect_internal (void *cls, } static void -notify_connect (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) { @@ -118,8 +116,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) } static void -notify_receive (void *cls, - const struct GNUNET_PeerIdentity *peer, +notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) @@ -188,8 +185,8 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id); GNUNET_TRANSPORT_try_connect (cc->th_p2, &p1->id); - cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &try_connect, cc); + cc->tct = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, cc); } @@ -218,14 +215,15 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char *cfgname, &p->servicehome); if (NULL != p->servicehome) GNUNET_DISK_directory_remove (p->servicehome); - p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", "-c", cfgname, + p->arm_proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", + "gnunet-service-arm", "-c", cfgname, #if VERBOSE_PEERS - "-L", "DEBUG", + "-L", "DEBUG", #else - "-L", "ERROR", + "-L", "ERROR", #endif - NULL); + NULL); p->nc = nc; p->nd = nd; p->rec = rec; @@ -234,10 +232,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (const char *cfgname, else p->cb_cls = p; - p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, - p, - ¬ify_receive, - ¬ify_connect, ¬ify_disconnect); + p->th = + GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, + ¬ify_connect, ¬ify_disconnect); GNUNET_assert (p->th != NULL); return p; } @@ -296,13 +293,13 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext *p1, cc->cb = cb; cc->cb_cls = cb_cls; - cc->th_p1 = GNUNET_TRANSPORT_connect (cc->p1->cfg, NULL, - cc, - NULL, ¬ify_connect_internal, NULL); + cc->th_p1 = + GNUNET_TRANSPORT_connect (cc->p1->cfg, NULL, cc, NULL, + ¬ify_connect_internal, NULL); - cc->th_p2 = GNUNET_TRANSPORT_connect (cc->p2->cfg, NULL, - cc, - NULL, ¬ify_connect_internal, NULL); + cc->th_p2 = + GNUNET_TRANSPORT_connect (cc->p2->cfg, NULL, cc, NULL, + ¬ify_connect_internal, NULL); GNUNET_assert (cc->th_p1 != NULL); GNUNET_assert (cc->th_p2 != NULL); diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 2cdaacad6..b732871ca 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -304,8 +304,8 @@ static void schedule_transmission (struct GNUNET_TRANSPORT_Handle *h); * * @param h transport service to reconnect */ -static void -disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h); +static void disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle + *h); /** @@ -335,8 +335,8 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, struct Neighbour *n; #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Creating entry for neighbour `%4s'.\n", GNUNET_i2s (pid)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating entry for neighbour `%4s'.\n", + GNUNET_i2s (pid)); #endif n = GNUNET_malloc (sizeof (struct Neighbour)); n->id = *pid; @@ -347,8 +347,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, MAX_BANDWIDTH_CARRY_S); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (h->neighbours, - &pid->hashPubKey, - n, + &pid->hashPubKey, n, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); return n; } @@ -375,8 +374,8 @@ neighbour_delete (void *cls, const GNUNET_HashCode * key, void *value) GNUNET_assert (NULL == n->th); GNUNET_assert (NULL == n->hn); GNUNET_assert (GNUNET_YES == - GNUNET_CONTAINER_multihashmap_remove (handle->neighbours, - key, n)); + GNUNET_CONTAINER_multihashmap_remove (handle->neighbours, key, + n)); GNUNET_free (n); return GNUNET_YES; } @@ -414,8 +413,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) disconnect_and_schedule_reconnect (h); return; } - GNUNET_CLIENT_receive (h->client, - &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &demultiplexer, h, + GNUNET_TIME_UNIT_FOREVER_REL); size = ntohs (msg->size); switch (ntohs (msg->type)) { @@ -428,8 +427,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving (my own) `%s' message, I am `%4s'.\n", - "HELLO", GNUNET_i2s (&me)); + "Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO", + GNUNET_i2s (&me)); #endif GNUNET_free_non_null (h->my_hello); h->my_hello = NULL; @@ -465,8 +464,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) break; } #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving `%s' message for `%4s'.\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n", "CONNECT", GNUNET_i2s (&cim->id)); #endif n = neighbour_find (h, &cim->id); @@ -488,8 +486,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) dim = (const struct DisconnectInfoMessage *) msg; GNUNET_break (ntohl (dim->reserved) == 0); #if DEBUG_TRANSPORT_DISCONNECT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Receiving `%s' message for `%4s'.\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving `%s' message for `%4s'.\n", "DISCONNECT", GNUNET_i2s (&dim->peer)); #endif n = neighbour_find (h, &dim->peer); @@ -551,8 +548,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received message of type %u from `%4s'.\n", - ntohs (imm->type), GNUNET_i2s (&im->peer)); + "Received message of type %u from `%4s'.\n", ntohs (imm->type), + GNUNET_i2s (&im->peer)); #endif n = neighbour_find (h, &im->peer); if (n == NULL) @@ -565,8 +562,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) break; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("Received unexpected message of type %u in %s:%u\n"), + _("Received unexpected message of type %u in %s:%u\n"), ntohs (msg->type), __FILE__, __LINE__); GNUNET_break (0); break; @@ -663,17 +659,17 @@ transport_notify_ready (void *cls, size_t size, void *buf) th = n->th; if (th->notify_size + sizeof (struct OutboundMessage) > size) break; /* does not fit */ - if (GNUNET_BANDWIDTH_tracker_get_delay - (&n->out_tracker, th->notify_size).rel_value > 0) + if (GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, th->notify_size). + rel_value > 0) break; /* too early */ GNUNET_assert (n == GNUNET_CONTAINER_heap_remove_root (h->ready_heap)); n->hn = NULL; n->th = NULL; n->is_ready = GNUNET_NO; GNUNET_assert (size >= sizeof (struct OutboundMessage)); - mret = th->notify (th->notify_cls, - size - sizeof (struct OutboundMessage), - &cbuf[ret + sizeof (struct OutboundMessage)]); + mret = + th->notify (th->notify_cls, size - sizeof (struct OutboundMessage), + &cbuf[ret + sizeof (struct OutboundMessage)]); GNUNET_assert (mret <= size - sizeof (struct OutboundMessage)); if (mret != 0) { @@ -756,11 +752,10 @@ schedule_transmission_task (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling notify_transmit_ready\n"); #endif h->cth = - GNUNET_CLIENT_notify_transmit_ready (h->client, - size, + GNUNET_CLIENT_notify_transmit_ready (h->client, size, GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_NO, - &transport_notify_ready, h); + GNUNET_NO, &transport_notify_ready, + h); GNUNET_assert (NULL != h->cth); } @@ -794,8 +789,8 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling next transmission to service in %llu ms\n", (unsigned long long) delay.rel_value); - h->quota_task = GNUNET_SCHEDULER_add_delayed (delay, - &schedule_transmission_task, h); + h->quota_task = + GNUNET_SCHEDULER_add_delayed (delay, &schedule_transmission_task, h); } @@ -809,8 +804,7 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) * @param notify_cls closure for notify */ static void -schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, - size_t size, +schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size, GNUNET_CONNECTION_TransmitReadyNotify notify, void *notify_cls) { @@ -861,8 +855,8 @@ send_start (void *cls, size_t size, void *buf) s.do_check = htonl (h->check_self); s.self = h->self; memcpy (buf, &s, sizeof (struct StartMessage)); - GNUNET_CLIENT_receive (h->client, - &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (h->client, &demultiplexer, h, + GNUNET_TIME_UNIT_FOREVER_REL); return sizeof (struct StartMessage); } @@ -936,8 +930,8 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) "Scheduling task to reconnect to transport service in %llu ms.\n", h->reconnect_delay.rel_value); #endif - h->reconnect_task - = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); + h->reconnect_task = + GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); if (h->reconnect_delay.rel_value == 0) { h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; @@ -945,8 +939,8 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) else { h->reconnect_delay = GNUNET_TIME_relative_multiply (h->reconnect_delay, 2); - h->reconnect_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, - h->reconnect_delay); + h->reconnect_delay = + GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, h->reconnect_delay); } } @@ -990,8 +984,8 @@ send_set_quota (void *cls, size_t size, void *buf) } #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Transmitting `%s' request with respect to `%4s'.\n", - "SET_QUOTA", GNUNET_i2s (&sqc->target)); + "Transmitting `%s' request with respect to `%4s'.\n", "SET_QUOTA", + GNUNET_i2s (&sqc->target)); #endif GNUNET_assert (size >= sizeof (struct QuotaSetMessage)); msg.header.size = htons (sizeof (struct QuotaSetMessage)); @@ -1038,8 +1032,7 @@ GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle, (unsigned int) n->out_tracker.available_bytes_per_s__, (unsigned int) ntohl (quota_out.value__), GNUNET_i2s (target)); else - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Quota remains at %u for peer `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quota remains at %u for peer `%s'\n", (unsigned int) n->out_tracker.available_bytes_per_s__, GNUNET_i2s (target)); #endif @@ -1047,8 +1040,7 @@ GNUNET_TRANSPORT_set_quota (struct GNUNET_TRANSPORT_Handle *handle, sqc = GNUNET_malloc (sizeof (struct SetQuotaContext)); sqc->target = *target; sqc->quota_in = quota_in; - schedule_control_transmit (handle, - sizeof (struct QuotaSetMessage), + schedule_control_transmit (handle, sizeof (struct QuotaSetMessage), &send_set_quota, sqc); } @@ -1257,8 +1249,7 @@ GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle, */ struct GNUNET_TRANSPORT_Handle * GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - const struct GNUNET_PeerIdentity *self, - void *cls, + const struct GNUNET_PeerIdentity *self, void *cls, GNUNET_TRANSPORT_ReceiveCallback rec, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd) diff --git a/src/transport/transport_api_address_iterate.c b/src/transport/transport_api_address_iterate.c index 4f442fda0..833b82d7e 100644 --- a/src/transport/transport_api_address_iterate.c +++ b/src/transport/transport_api_address_iterate.c @@ -110,8 +110,7 @@ peer_address_response_processor (void *cls, return; } /* expect more replies */ - GNUNET_CLIENT_receive (alucb->client, - &peer_address_response_processor, alucb, + GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb, GNUNET_TIME_absolute_get_remaining (alucb->timeout)); alucb->cb (alucb->cb_cls, address); } @@ -154,10 +153,8 @@ GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, peer_address_lookup_cb->timeout = abs_timeout; peer_address_lookup_cb->client = client; GNUNET_assert (GNUNET_OK == - GNUNET_CLIENT_transmit_and_get_response (client, - &msg.header, - timeout, - GNUNET_YES, + GNUNET_CLIENT_transmit_and_get_response (client, &msg.header, + timeout, GNUNET_YES, &peer_address_response_processor, peer_address_lookup_cb)); } diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 4aadf10f4..1cbafdab0 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c @@ -97,8 +97,7 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) return; } /* expect more replies */ - GNUNET_CLIENT_receive (alucb->client, - &address_response_processor, alucb, + GNUNET_CLIENT_receive (alucb->client, &address_response_processor, alucb, GNUNET_TIME_absolute_get_remaining (alucb->timeout)); alucb->cb (alucb->cb_cls, address); } @@ -119,10 +118,8 @@ address_response_processor (void *cls, const struct GNUNET_MessageHeader *msg) */ void GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *address, - size_t addressLen, - int numeric, - const char *nameTrans, + const char *address, size_t addressLen, + int numeric, const char *nameTrans, struct GNUNET_TIME_Relative timeout, GNUNET_TRANSPORT_AddressLookUpCallback aluc, void *aluc_cls) @@ -163,10 +160,8 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, aluCB->timeout = GNUNET_TIME_relative_to_absolute (timeout); aluCB->client = client; GNUNET_assert (GNUNET_OK == - GNUNET_CLIENT_transmit_and_get_response (client, - &msg->header, - timeout, - GNUNET_YES, + GNUNET_CLIENT_transmit_and_get_response (client, &msg->header, + timeout, GNUNET_YES, &address_response_processor, aluCB)); GNUNET_free (msg); diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c index f8f430995..f6852ff01 100644 --- a/src/transport/transport_api_blacklist.c +++ b/src/transport/transport_api_blacklist.c @@ -122,8 +122,8 @@ query_handler (void *cls, const struct GNUNET_MessageHeader *msg) static void receive (struct GNUNET_TRANSPORT_Blacklist *br) { - GNUNET_CLIENT_receive (br->client, - &query_handler, br, GNUNET_TIME_UNIT_FOREVER_REL); + GNUNET_CLIENT_receive (br->client, &query_handler, br, + GNUNET_TIME_UNIT_FOREVER_REL); } @@ -166,12 +166,12 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br) GNUNET_CLIENT_disconnect (br->client, GNUNET_NO); br->client = GNUNET_CLIENT_connect ("transport", br->cfg); GNUNET_assert (br->client != NULL); - br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, - sizeof (struct - GNUNET_MessageHeader), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, - &transmit_blacklist_init, br); + br->th = + GNUNET_CLIENT_notify_transmit_ready (br->client, + sizeof (struct GNUNET_MessageHeader), + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_YES, &transmit_blacklist_init, + br); } @@ -212,12 +212,12 @@ transmit_blacklist_reply (void *cls, size_t size, void *buf) static void reply (struct GNUNET_TRANSPORT_Blacklist *br) { - br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, - sizeof (struct - BlacklistMessage), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_NO, - &transmit_blacklist_reply, br); + br->th = + GNUNET_CLIENT_notify_transmit_ready (br->client, + sizeof (struct BlacklistMessage), + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_NO, &transmit_blacklist_reply, + br); if (br->th == NULL) { reconnect (br); @@ -253,12 +253,12 @@ GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist)); ret->client = client; ret->cfg = cfg; - ret->th = GNUNET_CLIENT_notify_transmit_ready (client, - sizeof (struct - GNUNET_MessageHeader), - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_YES, - &transmit_blacklist_init, ret); + ret->th = + GNUNET_CLIENT_notify_transmit_ready (client, + sizeof (struct GNUNET_MessageHeader), + GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_YES, &transmit_blacklist_init, + ret); return ret; } diff --git a/src/transport/transport_api_peer_address_lookup.c b/src/transport/transport_api_peer_address_lookup.c index 50536b47d..c84874b4b 100644 --- a/src/transport/transport_api_peer_address_lookup.c +++ b/src/transport/transport_api_peer_address_lookup.c @@ -110,8 +110,7 @@ peer_address_response_processor (void *cls, return; } /* expect more replies */ - GNUNET_CLIENT_receive (alucb->client, - &peer_address_response_processor, alucb, + GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb, GNUNET_TIME_absolute_get_remaining (alucb->timeout)); alucb->cb (alucb->cb_cls, address); } @@ -155,10 +154,8 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle peer_address_lookup_cb->timeout = GNUNET_TIME_relative_to_absolute (timeout); peer_address_lookup_cb->client = client; GNUNET_assert (GNUNET_OK == - GNUNET_CLIENT_transmit_and_get_response (client, - &msg.header, - timeout, - GNUNET_YES, + GNUNET_CLIENT_transmit_and_get_response (client, &msg.header, + timeout, GNUNET_YES, &peer_address_response_processor, peer_address_lookup_cb)); } diff --git a/src/transport/wlan/radiotap-parser.c b/src/transport/wlan/radiotap-parser.c index 51dfd7107..ab75524f2 100644 --- a/src/transport/wlan/radiotap-parser.c +++ b/src/transport/wlan/radiotap-parser.c @@ -62,14 +62,14 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator, iterator->max_length = le16_to_cpu (radiotap_header->it_len); iterator->arg_index = 0; iterator->bitmap_shifter = le32_to_cpu (radiotap_header->it_present); - iterator->arg = ((u8 *) radiotap_header) + - sizeof (struct ieee80211_radiotap_header); + iterator->arg = + ((u8 *) radiotap_header) + sizeof (struct ieee80211_radiotap_header); iterator->this_arg = 0; /* find payload start allowing for extended bitmap(s) */ - if (unlikely (iterator->bitmap_shifter & - IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) + if (unlikely + (iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) { while (le32_to_cpu (*((u32 *) iterator->arg)) & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK) @@ -190,13 +190,14 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator) * kind of boundary. */ - if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) & - ((rt_sizes[iterator->arg_index] >> 4) - 1)) + if ((((void *) iterator->arg) - + ((void *) iterator-> + rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) - 1)) iterator->arg_index += (rt_sizes[iterator->arg_index] >> 4) - ((((void *) iterator->arg) - - ((void *) iterator->rtheader)) & - ((rt_sizes[iterator->arg_index] >> 4) - 1)); + ((void *) iterator-> + rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) - 1)); /* * this is what we will return to user, but we need to diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index d138ffba1..95ff4bfff 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c @@ -41,8 +41,7 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second) struct GNUNET_BANDWIDTH_Value32NBO ret; #if DEBUG_BANDWIDTH - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Initializing bandwidth of %u Bps\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing bandwidth of %u Bps\n", (unsigned int) bytes_per_second); #endif ret.value__ = htonl (bytes_per_second); @@ -61,8 +60,9 @@ struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, struct GNUNET_BANDWIDTH_Value32NBO b2) { - return GNUNET_BANDWIDTH_value_init (GNUNET_MIN (ntohl (b1.value__), - ntohl (b2.value__))); + return + GNUNET_BANDWIDTH_value_init (GNUNET_MIN + (ntohl (b1.value__), ntohl (b2.value__))); } @@ -152,8 +152,7 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, av->max_carry_s__ = max_carry_s; #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p initialized with %u Bps and max carry %u\n", - av, + "Tracker %p initialized with %u Bps and max carry %u\n", av, (unsigned int) av->available_bytes_per_s__, (unsigned int) max_carry_s); #endif @@ -196,8 +195,7 @@ update_tracker (struct GNUNET_BANDWIDTH_Tracker *av) #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p updated, have %u Bps, last update was %llu ms ago\n", - av, - (unsigned int) av->available_bytes_per_s__, + av, (unsigned int) av->available_bytes_per_s__, (unsigned long long) delta_time); #endif @@ -222,8 +220,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, int64_t nc; #if DEBUG_BANDWIDTH - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p consumes %d bytes\n", av, (int) size); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p consumes %d bytes\n", av, + (int) size); #endif if (size > 0) { @@ -239,8 +237,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, { #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p consumption %llu bytes above limit\n", - av, (unsigned long long) av->consumption_since_last_update__); + "Tracker %p consumption %llu bytes above limit\n", av, + (unsigned long long) av->consumption_since_last_update__); #endif return GNUNET_YES; } @@ -282,8 +280,8 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, { #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p delay for %u bytes is zero\n", - av, (unsigned int) size); + "Tracker %p delay for %u bytes is zero\n", av, + (unsigned int) size); #endif return GNUNET_TIME_UNIT_ZERO; } @@ -291,8 +289,8 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, 1000LL * bytes_needed / (unsigned long long) av->available_bytes_per_s__; #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p delay for %u bytes is %llu ms\n", - av, (unsigned int) size, (unsigned long long) ret.rel_value); + "Tracker %p delay for %u bytes is %llu ms\n", av, + (unsigned int) size, (unsigned long long) ret.rel_value); #endif return ret; } @@ -314,14 +312,15 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker * av) update_tracker (av); bps = GNUNET_BANDWIDTH_value_init (av->available_bytes_per_s__); - avail = GNUNET_BANDWIDTH_value_get_available_until (bps, - GNUNET_TIME_absolute_get_duration - (av->last_update__)); + avail = + GNUNET_BANDWIDTH_value_get_available_until (bps, + GNUNET_TIME_absolute_get_duration + (av->last_update__)); used = av->consumption_since_last_update__; #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p available bandwidth is %lld bytes\n", - av, (long long) (int64_t) (avail - used)); + "Tracker %p available bandwidth is %lld bytes\n", av, + (long long) (int64_t) (avail - used)); #endif return (int64_t) (avail - used); } @@ -344,8 +343,8 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av, new_limit = ntohl (bytes_per_second_limit.value__); #if DEBUG_BANDWIDTH GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Tracker %p bandwidth changed to %u Bps\n", - av, (unsigned int) new_limit); + "Tracker %p bandwidth changed to %u Bps\n", av, + (unsigned int) new_limit); #endif update_tracker (av); old_limit = av->available_bytes_per_s__; diff --git a/src/util/bio.c b/src/util/bio.c index b29d75eb9..404b7aa3b 100644 --- a/src/util/bio.c +++ b/src/util/bio.c @@ -101,8 +101,8 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h, char **emsg) * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, - const char *what, void *result, size_t len) +GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, const char *what, + void *result, size_t len) { char *dst = result; size_t min; @@ -131,14 +131,14 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, ret = GNUNET_DISK_file_read (h->fd, h->buffer, h->size); if (ret == -1) { - GNUNET_asprintf (&h->emsg, - _("Error reading `%s': %s"), what, STRERROR (errno)); + GNUNET_asprintf (&h->emsg, _("Error reading `%s': %s"), what, + STRERROR (errno)); return GNUNET_SYSERR; } if (ret == 0) { - GNUNET_asprintf (&h->emsg, - _("Error reading `%s': %s"), what, _("End of file")); + GNUNET_asprintf (&h->emsg, _("Error reading `%s': %s"), what, + _("End of file")); return GNUNET_SYSERR; } h->pos = 0; @@ -160,8 +160,8 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h, * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, - const char *file, int line, void *result, size_t len) +GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, const char *file, int line, + void *result, size_t len) { char what[1024]; @@ -181,8 +181,8 @@ GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h, * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, - const char *what, char **result, size_t maxLen) +GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, const char *what, + char **result, size_t maxLen) { char *buf; uint32_t big; @@ -200,8 +200,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, } if (big > maxLen) { - GNUNET_asprintf (&h->emsg, - _("String `%s' longer than allowed (%u > %u)"), + GNUNET_asprintf (&h->emsg, _("String `%s' longer than allowed (%u > %u)"), what, big, maxLen); return GNUNET_SYSERR; } @@ -229,8 +228,7 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h, * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ int -GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, - const char *what, +GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result) { uint32_t size; @@ -280,8 +278,8 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, - const char *file, int line, int32_t * i) +GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, const char *file, + int line, int32_t * i) { int32_t big; @@ -302,8 +300,8 @@ GNUNET_BIO_read_int32__ (struct GNUNET_BIO_ReadHandle *h, * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, - const char *file, int line, int64_t * i) +GNUNET_BIO_read_int64__ (struct GNUNET_BIO_ReadHandle *h, const char *file, + int line, int64_t * i) { int64_t big; @@ -339,9 +337,8 @@ GNUNET_BIO_write_open (const char *fn) struct GNUNET_BIO_WriteHandle *h; fd = GNUNET_DISK_file_open (fn, - GNUNET_DISK_OPEN_WRITE | - GNUNET_DISK_OPEN_TRUNCATE | - GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE + | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); if (NULL == fd) @@ -394,8 +391,8 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h) * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, - const void *buffer, size_t n) +GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer, + size_t n) { const char *src = buffer; size_t min; @@ -470,10 +467,9 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, if (m == NULL) return GNUNET_BIO_write_int32 (h, 0); buf = NULL; - size = GNUNET_CONTAINER_meta_data_serialize (m, - &buf, - MAX_META_DATA, - GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); + size = + GNUNET_CONTAINER_meta_data_serialize (m, &buf, MAX_META_DATA, + GNUNET_CONTAINER_META_DATA_SERIALIZE_PART); if (size == -1) { GNUNET_free (buf); diff --git a/src/util/client.c b/src/util/client.c index 032a6c5e4..59cd26ad1 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -293,15 +293,11 @@ do_connect (const char *service_name, #endif if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - service_name, - "PORT", - &port)) || - (port > 65535) || + GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "PORT", &port)) + || (port > 65535) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - service_name, - "HOSTNAME", &hostname))) + GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "HOSTNAME", + &hostname))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ @@ -325,13 +321,12 @@ do_connect (const char *service_name, /* try UNIX */ unixpath = NULL; if ((GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, - service_name, - "UNIXPATH", &unixpath)) && + GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", + &unixpath)) && (0 < strlen (unixpath))) { - sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, - unixpath); + sock = + GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath); if (sock != NULL) { GNUNET_free (unixpath); @@ -457,8 +452,8 @@ check_complete (struct GNUNET_CLIENT_Connection *conn) { if ((conn->received_pos >= sizeof (struct GNUNET_MessageHeader)) && (conn->received_pos >= - ntohs (((const struct GNUNET_MessageHeader *) conn->received_buf)-> - size))) + ntohs (((const struct GNUNET_MessageHeader *) conn-> + received_buf)->size))) conn->msg_complete = GNUNET_YES; } @@ -476,9 +471,7 @@ check_complete (struct GNUNET_CLIENT_Connection *conn) * @param errCode value of errno (on errors receiving) */ static void -receive_helper (void *cls, - const void *buf, - size_t available, +receive_helper (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) { struct GNUNET_CLIENT_Connection *conn = cls; @@ -512,8 +505,8 @@ receive_helper (void *cls, /* slow path: append to array */ if (conn->received_size < conn->received_pos + available) - GNUNET_array_grow (conn->received_buf, - conn->received_size, conn->received_pos + available); + GNUNET_array_grow (conn->received_buf, conn->received_size, + conn->received_pos + available); memcpy (&conn->received_buf[conn->received_pos], buf, available); conn->received_pos += available; check_complete (conn); @@ -527,8 +520,7 @@ receive_helper (void *cls, return; } /* back to receive -- either for more data or to call callback! */ - GNUNET_CLIENT_receive (conn, - conn->receiver_handler, + GNUNET_CLIENT_receive (conn, conn->receiver_handler, conn->receiver_handler_cls, remaining); } @@ -553,15 +545,15 @@ receive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received message of type %u and size %u\n", - ntohs (cmsg->type), msize); + "Received message of type %u and size %u\n", ntohs (cmsg->type), + msize); #endif sock->receive_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (GNUNET_YES == sock->msg_complete); GNUNET_assert (sock->received_pos >= msize); memcpy (msg, cmsg, msize); - memmove (sock->received_buf, - &sock->received_buf[msize], sock->received_pos - msize); + memmove (sock->received_buf, &sock->received_buf[msize], + sock->received_pos - msize); sock->received_pos -= msize; sock->msg_complete = GNUNET_NO; sock->receiver_handler = NULL; @@ -581,8 +573,8 @@ receive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ void GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, - GNUNET_CLIENT_MessageHandler handler, - void *handler_cls, struct GNUNET_TIME_Relative timeout) + GNUNET_CLIENT_MessageHandler handler, void *handler_cls, + struct GNUNET_TIME_Relative timeout) { if (sock->sock == NULL) { @@ -607,8 +599,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, #if DEBUG_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "calling GNUNET_CONNECTION_receive\n"); #endif - GNUNET_CONNECTION_receive (sock->sock, - GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, + GNUNET_CONNECTION_receive (sock->sock, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, timeout, &receive_helper, sock); } } @@ -620,8 +611,8 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, static void service_test_error (GNUNET_SCHEDULER_Task task, void *task_cls) { - GNUNET_SCHEDULER_add_continuation (task, - task_cls, GNUNET_SCHEDULER_REASON_TIMEOUT); + GNUNET_SCHEDULER_add_continuation (task, task_cls, + GNUNET_SCHEDULER_REASON_TIMEOUT); } @@ -645,8 +636,7 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received confirmation that service is running.\n"); #endif - GNUNET_SCHEDULER_add_continuation (conn->test_cb, - conn->test_cb_cls, + GNUNET_SCHEDULER_add_continuation (conn->test_cb, conn->test_cb_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); } else @@ -688,11 +678,9 @@ write_test (void *cls, size_t size, void *buf) msg = (struct GNUNET_MessageHeader *) buf; msg->type = htons (GNUNET_MESSAGE_TYPE_TEST); msg->size = htons (sizeof (struct GNUNET_MessageHeader)); - GNUNET_CLIENT_receive (conn, - &confirm_handler, - conn, - GNUNET_TIME_absolute_get_remaining - (conn->test_deadline)); + GNUNET_CLIENT_receive (conn, &confirm_handler, conn, + GNUNET_TIME_absolute_get_remaining (conn-> + test_deadline)); return sizeof (struct GNUNET_MessageHeader); } @@ -722,8 +710,8 @@ GNUNET_CLIENT_service_test (const char *service, struct GNUNET_CLIENT_Connection *conn; #if DEBUG_CLIENT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Testing if service `%s' is running.\n", service); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing if service `%s' is running.\n", + service); #endif #ifdef AF_UNIX { @@ -761,15 +749,13 @@ GNUNET_CLIENT_service_test (const char *service, s_un.sun_len = (u_char) slen; #endif if (GNUNET_OK != - GNUNET_NETWORK_socket_bind (sock, - (const struct sockaddr *) &s_un, + GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_un, slen)) { /* failed to bind => service must be running */ GNUNET_free (unixpath); (void) GNUNET_NETWORK_socket_close (sock); - GNUNET_SCHEDULER_add_continuation (task, - task_cls, + GNUNET_SCHEDULER_add_continuation (task, task_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } @@ -784,14 +770,11 @@ GNUNET_CLIENT_service_test (const char *service, hostname = NULL; if ((GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - service, - "PORT", - &port)) || + GNUNET_CONFIGURATION_get_value_number (cfg, service, "PORT", &port)) || (port > 65535) || (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - service, "HOSTNAME", &hostname))) + GNUNET_CONFIGURATION_get_value_string (cfg, service, "HOSTNAME", + &hostname))) { /* UNIXPATH failed (if possible) AND IP failed => error */ service_test_error (task, task_cls); @@ -818,15 +801,13 @@ GNUNET_CLIENT_service_test (const char *service, if (sock != NULL) { if (GNUNET_OK != - GNUNET_NETWORK_socket_bind (sock, - (const struct sockaddr *) &s_in, + GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in, sizeof (s_in))) { /* failed to bind => service must be running */ GNUNET_free (hostname); (void) GNUNET_NETWORK_socket_close (sock); - GNUNET_SCHEDULER_add_continuation (task, - task_cls, + GNUNET_SCHEDULER_add_continuation (task, task_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } @@ -854,15 +835,13 @@ GNUNET_CLIENT_service_test (const char *service, if (sock != NULL) { if (GNUNET_OK != - GNUNET_NETWORK_socket_bind (sock, - (const struct sockaddr *) &s_in6, + GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) &s_in6, sizeof (s_in6))) { /* failed to bind => service must be running */ GNUNET_free (hostname); (void) GNUNET_NETWORK_socket_close (sock); - GNUNET_SCHEDULER_add_continuation (task, - task_cls, + GNUNET_SCHEDULER_add_continuation (task, task_cls, GNUNET_SCHEDULER_REASON_PREREQ_DONE); return; } @@ -889,8 +868,7 @@ GNUNET_CLIENT_service_test (const char *service, if (conn == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _ - ("Could not connect to service `%s', must not be running.\n"), + _("Could not connect to service `%s', must not be running.\n"), service); service_test_error (task, task_cls); return; @@ -899,11 +877,11 @@ GNUNET_CLIENT_service_test (const char *service, conn->test_cb_cls = task_cls; conn->test_deadline = GNUNET_TIME_relative_to_absolute (timeout); - if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn, - sizeof (struct - GNUNET_MessageHeader), - timeout, GNUNET_YES, - &write_test, conn)) + if (NULL == + GNUNET_CLIENT_notify_transmit_ready (conn, + sizeof (struct GNUNET_MessageHeader), + timeout, GNUNET_YES, &write_test, + conn)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failure to transmit request to service `%s'\n"), service); @@ -952,8 +930,8 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (th); return; } - th->sock->sock = do_connect (th->sock->service_name, - th->sock->cfg, th->sock->attempts++); + th->sock->sock = + do_connect (th->sock->service_name, th->sock->cfg, th->sock->attempts++); if (NULL == th->sock->sock) { /* could happen if we're out of sockets */ @@ -970,17 +948,16 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) MAX_ATTEMPTS - th->attempts_left, (unsigned long long) delay.rel_value); #endif - th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, - &client_delayed_retry, - th); + th->reconnect_task = + GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); return; } GNUNET_CONNECTION_ignore_shutdown (th->sock->sock, th->sock->ignore_shutdown); - th->th = GNUNET_CONNECTION_notify_transmit_ready (th->sock->sock, - th->size, - GNUNET_TIME_absolute_get_remaining - (th->timeout), - &client_notify, th); + th->th = + GNUNET_CONNECTION_notify_transmit_ready (th->sock->sock, th->size, + GNUNET_TIME_absolute_get_remaining + (th->timeout), &client_notify, + th); if (th->th == NULL) { GNUNET_break (0); @@ -1037,8 +1014,7 @@ client_notify (void *cls, size_t size, void *buf) GNUNET_CONNECTION_destroy (th->sock->sock, GNUNET_NO); th->sock->sock = NULL; delay = GNUNET_TIME_relative_min (delay, th->sock->back_off); - th->sock->back_off - = + th->sock->back_off = GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (th->sock->back_off, 2), GNUNET_TIME_UNIT_SECONDS); @@ -1049,9 +1025,8 @@ client_notify (void *cls, size_t size, void *buf) (unsigned long long) delay.rel_value); #endif th->sock->th = th; - th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, - &client_delayed_retry, - th); + th->reconnect_task = + GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); return 0; } GNUNET_assert (size >= th->size); @@ -1108,17 +1083,16 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock, sock->th = th; if (sock->sock == NULL) { - th->reconnect_task = GNUNET_SCHEDULER_add_delayed (sock->back_off, - &client_delayed_retry, - th); + th->reconnect_task = + GNUNET_SCHEDULER_add_delayed (sock->back_off, &client_delayed_retry, + th); } else { - th->th = GNUNET_CONNECTION_notify_transmit_ready (sock->sock, - size, - timeout, - &client_notify, th); + th->th = + GNUNET_CONNECTION_notify_transmit_ready (sock->sock, size, timeout, + &client_notify, th); if (NULL == th->th) { GNUNET_break (0); @@ -1137,8 +1111,8 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *sock, * @param th handle from the original request. */ void -GNUNET_CLIENT_notify_transmit_ready_cancel (struct - GNUNET_CLIENT_TransmitHandle *th) +GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle + *th) { if (th->reconnect_task != GNUNET_SCHEDULER_NO_TASK) { @@ -1189,9 +1163,7 @@ transmit_for_response (void *cls, size_t size, void *buf) } GNUNET_assert (size >= msize); memcpy (buf, tc->hdr, msize); - GNUNET_CLIENT_receive (tc->sock, - tc->rn, - tc->rn_cls, + GNUNET_CLIENT_receive (tc->sock, tc->rn, tc->rn_cls, GNUNET_TIME_absolute_get_remaining (tc->timeout)); GNUNET_free (tc); return msize; @@ -1220,10 +1192,8 @@ transmit_for_response (void *cls, size_t size, void *buf) * is already pending */ int -GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection - *sock, - const struct GNUNET_MessageHeader - *hdr, +GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection *sock, + const struct GNUNET_MessageHeader *hdr, struct GNUNET_TIME_Relative timeout, int auto_retry, GNUNET_CLIENT_MessageHandler rn, @@ -1243,11 +1213,9 @@ GNUNET_CLIENT_transmit_and_get_response (struct GNUNET_CLIENT_Connection tc->timeout = GNUNET_TIME_relative_to_absolute (timeout); tc->rn = rn; tc->rn_cls = rn_cls; - if (NULL == GNUNET_CLIENT_notify_transmit_ready (sock, - msize, - timeout, - auto_retry, - &transmit_for_response, tc)) + if (NULL == + GNUNET_CLIENT_notify_transmit_ready (sock, msize, timeout, auto_retry, + &transmit_for_response, tc)) { GNUNET_break (0); GNUNET_free (tc); diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 6f01e8230..71aa15add 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -255,9 +255,7 @@ GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, * @param linenumber where in the code was the call to GNUNET_array_grow */ void -GNUNET_xgrow_ (void **old, - size_t elementSize, - unsigned int *oldCount, +GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, unsigned int newCount, const char *filename, int linenumber) { void *tmp; diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 37f630854..ff3ac12ee 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -279,8 +279,8 @@ GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls) * @param msg the actual message */ static void -output_message (enum GNUNET_ErrorType kind, - const char *comp, const char *datestr, const char *msg) +output_message (enum GNUNET_ErrorType kind, const char *comp, + const char *datestr, const char *msg) { struct CustomLogger *pos; @@ -371,8 +371,8 @@ GNUNET_log_skip (unsigned int n, int check_reset) * @param va arguments to the format string "message" */ static void -mylog (enum GNUNET_ErrorType kind, - const char *comp, const char *message, va_list va) +mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message, + va_list va) { char date[DATE_STR_SIZE]; char date2[DATE_STR_SIZE]; @@ -419,9 +419,8 @@ mylog (enum GNUNET_ErrorType kind, } else strcpy (date, "localtime error"); - if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && - (last_bulk_time.abs_value != 0) && - (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) + if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && (last_bulk_time.abs_value != 0) + && (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) { last_bulk_repeat++; if ((GNUNET_TIME_absolute_get_duration (last_bulk_time).rel_value > @@ -469,8 +468,8 @@ GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...) * @param ... arguments for format string */ void -GNUNET_log_from (enum GNUNET_ErrorType kind, - const char *comp, const char *message, ...) +GNUNET_log_from (enum GNUNET_ErrorType kind, const char *comp, + const char *message, ...) { va_list va; char comp_w_pid[128]; @@ -614,10 +613,7 @@ GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen) off = 0; if (un->sun_path[0] == '\0') off++; - snprintf (buf, - sizeof (buf), - "%s%.*s", - (off == 1) ? "@" : "", + snprintf (buf, sizeof (buf), "%s%.*s", (off == 1) ? "@" : "", (int) (addrlen - sizeof (sa_family_t) - 1 - off), &un->sun_path[off]); return buf; diff --git a/src/util/configuration.c b/src/util/configuration.c index b3b9d5ea8..534949652 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -241,8 +241,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, { /* parse error */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("Syntax error in configuration file `%s' at line %u.\n"), + _("Syntax error in configuration file `%s' at line %u.\n"), filename, nr); ret = GNUNET_SYSERR; break; @@ -499,8 +498,8 @@ GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, * @param value value to copy */ static void -copy_entry (void *cls, - const char *section, const char *option, const char *value) +copy_entry (void *cls, const char *section, const char *option, + const char *value) { struct GNUNET_CONFIGURATION_Handle *dst = cls; @@ -553,8 +552,8 @@ findSection (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section) * @return matching entry, NULL if not found */ static struct ConfigEntry * -findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section, const char *key) +findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, + const char *key) { struct ConfigSection *sec; struct ConfigEntry *pos; @@ -580,8 +579,8 @@ findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param value value to copy (of the default conf.) */ static void -compareEntries (void *cls, - const char *section, const char *option, const char *value) +compareEntries (void *cls, const char *section, const char *option, + const char *value) { struct DiffHandle *dh = cls; struct ConfigEntry *entNew; @@ -627,10 +626,9 @@ GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle * @param value value to set */ void -GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle - *cfg, - const char *section, - const char *option, const char *value) +GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, + const char *section, const char *option, + const char *value) { struct ConfigSection *sec; struct ConfigEntry *e; @@ -667,9 +665,8 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle * @param number value to set */ void -GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle - *cfg, const char *section, - const char *option, +GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, + const char *section, const char *option, unsigned long long number) { char s[64]; @@ -689,9 +686,8 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_CONFIGURATION_get_value_number (const struct - GNUNET_CONFIGURATION_Handle *cfg, - const char *section, +GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle + *cfg, const char *section, const char *option, unsigned long long *number) { @@ -751,9 +747,8 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_CONFIGURATION_get_value_string (const struct - GNUNET_CONFIGURATION_Handle *cfg, - const char *section, +GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle + *cfg, const char *section, const char *option, char **value) { struct ConfigEntry *e; @@ -782,11 +777,10 @@ GNUNET_CONFIGURATION_get_value_string (const struct * @return GNUNET_OK on success, GNUNET_SYSERR on error */ int -GNUNET_CONFIGURATION_get_value_choice (const struct - GNUNET_CONFIGURATION_Handle *cfg, - const char *section, - const char *option, - const char **choices, const char **value) +GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle + *cfg, const char *section, + const char *option, const char **choices, + const char **value) { struct ConfigEntry *e; int i; @@ -805,8 +799,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Configuration value '%s' for '%s'" - " in section '%s' is not in set of legal choices\n"), - e->val, option, section); + " in section '%s' is not in set of legal choices\n"), e->val, + option, section); return GNUNET_SYSERR; } *value = choices[i]; @@ -822,8 +816,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct * @return GNUNET_YES if so, GNUNET_NO if not. */ int -GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle - *cfg, const char *section, const char *option) +GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *section, const char *option) { struct ConfigEntry *e; @@ -866,9 +860,8 @@ GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle orig[i] = '\0'; post = &orig[i + 1]; } - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, - "PATHS", - &orig[1], &prefix)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", &orig[1], &prefix)) { if (NULL == (env = getenv (&orig[1]))) { @@ -940,8 +933,8 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle const char *val; int ret; - ret = GNUNET_CONFIGURATION_get_value_choice (cfg, - section, option, yesno, &val); + ret = + GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val); if (ret == GNUNET_SYSERR) return ret; if (val == yesno[0]) @@ -962,8 +955,8 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle */ int GNUNET_CONFIGURATION_iterate_value_filenames (const struct - GNUNET_CONFIGURATION_Handle - *cfg, const char *section, + GNUNET_CONFIGURATION_Handle *cfg, + const char *section, const char *option, GNUNET_FileNameCallback cb, void *cb_cls) @@ -1093,8 +1086,7 @@ test_match (void *cls, const char *fn) */ int GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle - *cfg, - const char *section, + *cfg, const char *section, const char *option, const char *value) { @@ -1102,12 +1094,10 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle char *old; char *nw; - if (GNUNET_SYSERR - == GNUNET_CONFIGURATION_iterate_value_filenames (cfg, - section, - option, - &test_match, - (void *) value)) + if (GNUNET_SYSERR == + GNUNET_CONFIGURATION_iterate_value_filenames (cfg, section, option, + &test_match, + (void *) value)) return GNUNET_NO; /* already exists */ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old)) @@ -1140,8 +1130,7 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle */ int GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle - *cfg, - const char *section, + *cfg, const char *section, const char *option, const char *value) { @@ -1231,11 +1220,10 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, if (ipath == NULL) return GNUNET_SYSERR; baseconfig = NULL; - GNUNET_asprintf (&baseconfig, - "%s%s%s", ipath, DIR_SEPARATOR_STR, "defaults.conf"); + GNUNET_asprintf (&baseconfig, "%s%s%s", ipath, DIR_SEPARATOR_STR, + "defaults.conf"); GNUNET_free (ipath); - if ((GNUNET_OK != - GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || + if ((GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || (!((filename == NULL) || (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) { @@ -1243,18 +1231,15 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; } GNUNET_free (baseconfig); - if (((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, - "PATHS", - "DEFAULTCONFIG"))) && + if (((GNUNET_YES != + GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && (filename != NULL)) - GNUNET_CONFIGURATION_set_value_string (cfg, - "PATHS", "DEFAULTCONFIG", filename); - if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, - "TESTING", - "WEAKRANDOM")) && - (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, - "TESTING", - "WEAKRANDOM"))) + GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", + filename); + if ((GNUNET_YES == + GNUNET_CONFIGURATION_have_value (cfg, "TESTING", "WEAKRANDOM")) && + (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (cfg, "TESTING", "WEAKRANDOM"))) GNUNET_CRYPTO_random_disable_entropy_gathering (); return GNUNET_OK; } diff --git a/src/util/connection.c b/src/util/connection.c index 1ac1b2304..39cb1dde2 100644 --- a/src/util/connection.c +++ b/src/util/connection.c @@ -425,9 +425,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, /* largely traditional GNU/Linux */ olen = sizeof (uc); if ((0 == - getsockopt (GNUNET_NETWORK_get_fd (sock), - SOL_SOCKET, SO_PEERCRED, &uc, &olen)) && - (olen == sizeof (uc))) + getsockopt (GNUNET_NETWORK_get_fd (sock), SOL_SOCKET, SO_PEERCRED, &uc, + &olen)) && (olen == sizeof (uc))) { gc.uid = uc.uid; gc.gid = uc.gid; @@ -455,8 +454,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, (GNUNET_YES != (aret = access (access_cls, gcp, uaddr, addrlen)))) { if (aret == GNUNET_NO) - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Access denied to `%s'\n"), GNUNET_a2s (uaddr, addrlen)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Access denied to `%s'\n"), + GNUNET_a2s (uaddr, addrlen)); GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_shutdown (sock, SHUT_RDWR)); GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock)); @@ -470,8 +469,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access, ret->addrlen = addrlen; ret->sock = sock; #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Accepting connection from `%s': %p\n"), + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Accepting connection from `%s': %p\n"), GNUNET_a2s (uaddr, addrlen), ret); #endif return ret; @@ -508,8 +506,8 @@ GNUNET_CONNECTION_get_address (struct GNUNET_CONNECTION_Handle *sock, * @param cls our connection handle * @param tc task context describing why we are here */ -static void -receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void receive_again (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -544,9 +542,9 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Destroy waits for write_task to be done (%p)\n", sock); #endif GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); - sock->destroy_task - = GNUNET_SCHEDULER_add_after (sock->write_task, - &destroy_continuation, sock); + sock->destroy_task = + GNUNET_SCHEDULER_add_after (sock->write_task, &destroy_continuation, + sock); return; } if (0 != (sock->ccs & COCO_RECEIVE_AGAIN)) @@ -569,9 +567,9 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); - sock->destroy_task - = GNUNET_SCHEDULER_add_after (sock->read_task, - &destroy_continuation, sock); + sock->destroy_task = + GNUNET_SCHEDULER_add_after (sock->read_task, &destroy_continuation, + sock); return; } #if DEBUG_CONNECTION @@ -604,8 +602,8 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free_non_null (sock->hostname); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->destroy_task); #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Freeing memory of connection %p.\n", sock); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Freeing memory of connection %p.\n", + sock); #endif GNUNET_free (sock->write_buffer); GNUNET_free (sock); @@ -621,8 +619,8 @@ destroy_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param cls our connection handle * @param tc task context describing why we are here */ -static void -transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); +static void transmit_ready (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); /** @@ -634,11 +632,10 @@ static void connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h) { #if DEBUG_CONNECTION - GNUNET_log ((0 != strncmp (h->hostname, - "localhost:", - 10)) - ? GNUNET_ERROR_TYPE_INFO - : GNUNET_ERROR_TYPE_WARNING, + GNUNET_log ((0 != + strncmp (h->hostname, "localhost:", + 10)) ? GNUNET_ERROR_TYPE_INFO : + GNUNET_ERROR_TYPE_WARNING, _ ("Failed to establish TCP connection to `%s:%u', no further addresses to try.\n"), h->hostname, h->port); @@ -697,8 +694,7 @@ static void connect_success_continuation (struct GNUNET_CONNECTION_Handle *h) { #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Connection to `%s' succeeded! (%p)\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection to `%s' succeeded! (%p)\n", GNUNET_a2s (h->addr, h->addrlen), h); #endif /* trigger jobs that waited for the connection */ @@ -767,8 +763,8 @@ connect_probe_continuation (void *cls, error = 0; if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) || (GNUNET_OK != - GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, - &error, &len)) || (error != 0)) + GNUNET_NETWORK_socket_getsockopt (ap->sock, SOL_SOCKET, SO_ERROR, &error, + &len)) || (error != 0)) { GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock)); GNUNET_free (ap); @@ -804,8 +800,8 @@ connect_probe_continuation (void *cls, * @param addrlen length of addr */ static void -try_connect_using_address (void *cls, - const struct sockaddr *addr, socklen_t addrlen) +try_connect_using_address (void *cls, const struct sockaddr *addr, + socklen_t addrlen) { struct GNUNET_CONNECTION_Handle *h = cls; struct AddressProbe *ap; @@ -824,8 +820,8 @@ try_connect_using_address (void *cls, /* try to connect */ #if DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Trying to connect using address `%s:%u/%s:%u'\n", - h->hostname, h->port, GNUNET_a2s (addr, addrlen), h->port); + "Trying to connect using address `%s:%u/%s:%u'\n", h->hostname, + h->port, GNUNET_a2s (addr, addrlen), h->port); #endif ap = GNUNET_malloc (sizeof (struct AddressProbe) + addrlen); ap->addr = (const struct sockaddr *) &ap[1]; @@ -853,13 +849,11 @@ try_connect_using_address (void *cls, return; /* not supported by OS */ } #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Trying to connect to `%s' (%p)\n"), + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"), GNUNET_a2s (ap->addr, ap->addrlen), h); #endif - if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (ap->sock, - ap->addr, - ap->addrlen)) && + if ((GNUNET_OK != + GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) && (errno != EINPROGRESS)) { /* maybe refused / unsupported address, try next */ @@ -871,13 +865,15 @@ try_connect_using_address (void *cls, GNUNET_CONTAINER_DLL_insert (h->ap_head, h->ap_tail, ap); delay = GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT; if (h->nth.notify_ready != NULL) - delay = GNUNET_TIME_relative_min (delay, - GNUNET_TIME_absolute_get_remaining - (h->nth.transmit_timeout)); + delay = + GNUNET_TIME_relative_min (delay, + GNUNET_TIME_absolute_get_remaining (h->nth. + transmit_timeout)); if (h->receiver != NULL) - delay = GNUNET_TIME_relative_min (delay, - GNUNET_TIME_absolute_get_remaining - (h->receive_timeout)); + delay = + GNUNET_TIME_relative_min (delay, + GNUNET_TIME_absolute_get_remaining (h-> + receive_timeout)); ap->task = GNUNET_SCHEDULER_add_write_net (delay, ap->sock, &connect_probe_continuation, ap); @@ -895,9 +891,9 @@ try_connect_using_address (void *cls, * @return the socket handle */ struct GNUNET_CONNECTION_Handle * -GNUNET_CONNECTION_create_from_connect (const struct - GNUNET_CONFIGURATION_Handle *cfg, - const char *hostname, uint16_t port) +GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle + *cfg, const char *hostname, + uint16_t port) { struct GNUNET_CONNECTION_Handle *ret; @@ -908,10 +904,10 @@ GNUNET_CONNECTION_create_from_connect (const struct ret->write_buffer = GNUNET_malloc (ret->write_buffer_size); ret->port = port; ret->hostname = GNUNET_strdup (hostname); - ret->dns_active = GNUNET_RESOLVER_ip_get (ret->hostname, - AF_UNSPEC, - GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, - &try_connect_using_address, ret); + ret->dns_active = + GNUNET_RESOLVER_ip_get (ret->hostname, AF_UNSPEC, + GNUNET_CONNECTION_CONNECT_RETRY_TIMEOUT, + &try_connect_using_address, ret); return ret; } @@ -966,8 +962,8 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_free (ret); return NULL; } - if (GNUNET_OK != GNUNET_NETWORK_socket_connect (ret->sock, - ret->addr, ret->addrlen)) + if (GNUNET_OK != + GNUNET_NETWORK_socket_connect (ret->sock, ret->addr, ret->addrlen)) { /* Just return; we expect everything to work eventually so don't fail HARD */ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); @@ -1004,18 +1000,18 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family, s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0); if (s == NULL) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, "socket"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, + "socket"); return NULL; } - if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) - && (errno != EINPROGRESS)) + if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) && + (errno != EINPROGRESS)) { /* maybe refused / unsupported address, try next */ GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "connect"); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Attempt to connect to `%s' failed\n"), - GNUNET_a2s (serv_addr, addrlen)); + _("Attempt to connect to `%s' failed\n"), GNUNET_a2s (serv_addr, + addrlen)); GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); return NULL; } @@ -1024,8 +1020,7 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family, memcpy (ret->addr, serv_addr, addrlen); ret->addrlen = addrlen; #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Trying to connect to `%s' (%p)\n"), + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Trying to connect to `%s' (%p)\n"), GNUNET_a2s (serv_addr, addrlen), ret); #endif return ret; @@ -1157,8 +1152,9 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive from `%s' encounters error: time out by %llums... (%p)\n", GNUNET_a2s (sh->addr, sh->addrlen), - GNUNET_TIME_absolute_get_duration (sh->receive_timeout). - rel_value, sh); + GNUNET_TIME_absolute_get_duration (sh-> + receive_timeout).rel_value, + sh); #endif signal_timeout (sh); return; @@ -1181,8 +1177,8 @@ RETRY: if (errno == EINTR) goto RETRY; #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Error receiving: %s\n", STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error receiving: %s\n", + STRERROR (errno)); #endif signal_error (sh, errno); return; @@ -1190,8 +1186,8 @@ RETRY: #if DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "receive_ready read %u/%u bytes from `%s' (%p)!\n", - (unsigned int) ret, - sh->max, GNUNET_a2s (sh->addr, sh->addrlen), sh); + (unsigned int) ret, sh->max, GNUNET_a2s (sh->addr, sh->addrlen), + sh); #endif GNUNET_assert (NULL != (receiver = sh->receiver)); sh->receiver = NULL; @@ -1260,8 +1256,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param receiver_cls closure for receiver */ void -GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock, - size_t max, +GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *sock, size_t max, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_Receiver receiver, void *receiver_cls) @@ -1358,15 +1353,16 @@ process_notify (struct GNUNET_CONNECTION_Handle *sock) if (sock->write_buffer_size - sock->write_buffer_off < size) { /* need to compact */ - memmove (sock->write_buffer, - &sock->write_buffer[sock->write_buffer_pos], used); + memmove (sock->write_buffer, &sock->write_buffer[sock->write_buffer_pos], + used); sock->write_buffer_off -= sock->write_buffer_pos; sock->write_buffer_pos = 0; } avail = sock->write_buffer_size - sock->write_buffer_off; GNUNET_assert (avail >= size); - size = notify (sock->nth.notify_ready_cls, - avail, &sock->write_buffer[sock->write_buffer_off]); + size = + notify (sock->nth.notify_ready_cls, avail, + &sock->write_buffer[sock->write_buffer_off]); GNUNET_assert (size <= avail); sock->write_buffer_off += size; return GNUNET_YES; @@ -1397,8 +1393,8 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmit to `%s:%u/%s' fails, time out reached (%p).\n", - sock->hostname, - sock->port, GNUNET_a2s (sock->addr, sock->addrlen), sock); + sock->hostname, sock->port, GNUNET_a2s (sock->addr, + sock->addrlen), sock); #endif GNUNET_assert (0 != (sock->ccs & COCO_TRANSMIT_READY)); sock->ccs -= COCO_TRANSMIT_READY; /* remove request */ @@ -1541,8 +1537,8 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((sock->nth.notify_ready != NULL) && (sock->write_buffer_size < sock->nth.notify_size)) { - sock->write_buffer = GNUNET_realloc (sock->write_buffer, - sock->nth.notify_size); + sock->write_buffer = + GNUNET_realloc (sock->write_buffer, sock->nth.notify_size); sock->write_buffer_size = sock->nth.notify_size; } process_notify (sock); @@ -1556,9 +1552,10 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (have + sock->write_buffer_pos <= sock->write_buffer_size); GNUNET_assert (sock->write_buffer_pos <= sock->write_buffer_size); RETRY: - ret = GNUNET_NETWORK_socket_send (sock->sock, - &sock->write_buffer[sock->write_buffer_pos], - have); + ret = + GNUNET_NETWORK_socket_send (sock->sock, + &sock->write_buffer[sock->write_buffer_pos], + have); if (ret == -1) { if (errno == EINTR) @@ -1566,8 +1563,7 @@ RETRY: #if 0 int en = errno; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to send to `%s': %s\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to send to `%s': %s\n"), GNUNET_a2s (sock->addr, sock->addrlen), STRERROR (en)); #endif #if DEBUG_CONNECTION @@ -1579,8 +1575,8 @@ RETRY: #if DEBUG_CONNECTION GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transmit_ready transmitted %u/%u bytes to `%s' (%p)\n", - (unsigned int) ret, - have, GNUNET_a2s (sock->addr, sock->addrlen), sock); + (unsigned int) ret, have, GNUNET_a2s (sock->addr, sock->addrlen), + sock); #endif sock->write_buffer_pos += ret; if (sock->write_buffer_pos == sock->write_buffer_off) @@ -1601,9 +1597,8 @@ SCHEDULE_WRITE: GNUNET_assert ((sock->nth.notify_ready != NULL) || (have > 0)); if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) sock->write_task = - GNUNET_SCHEDULER_add_write_net ((sock->nth.notify_ready == NULL) - ? GNUNET_TIME_UNIT_FOREVER_REL - : + GNUNET_SCHEDULER_add_write_net ((sock->nth.notify_ready == + NULL) ? GNUNET_TIME_UNIT_FOREVER_REL : GNUNET_TIME_absolute_get_remaining (sock->nth.transmit_timeout), sock->sock, &transmit_ready, sock); @@ -1625,8 +1620,8 @@ SCHEDULE_WRITE: * NULL if we are already going to notify someone else (busy) */ struct GNUNET_CONNECTION_TransmitHandle * -GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle - *sock, size_t size, +GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *sock, + size_t size, struct GNUNET_TIME_Relative timeout, GNUNET_CONNECTION_TransmitReadyNotify notify, void *notify_cls) @@ -1647,8 +1642,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle sock->nth.notify_size = size; sock->nth.transmit_timeout = GNUNET_TIME_relative_to_absolute (timeout); GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == sock->nth.timeout_task); - if ((sock->sock == NULL) && - (sock->ap_head == NULL) && (sock->dns_active == NULL)) + if ((sock->sock == NULL) && (sock->ap_head == NULL) && + (sock->dns_active == NULL)) { if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (sock->write_task); @@ -1660,8 +1655,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle if (sock->sock != NULL) { #if DEBUG_CONNECTION - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Scheduling transmit_ready (%p).\n", sock); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling transmit_ready (%p).\n", + sock); #endif sock->write_task = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining @@ -1676,9 +1671,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle sock); #endif sock->ccs |= COCO_TRANSMIT_READY; - sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, - &transmit_timeout, - sock); + sock->nth.timeout_task = + GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, sock); } return &sock->nth; } diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index a0749a18a..ebd056128 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c @@ -102,8 +102,7 @@ struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter *bf) { - return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray, - bf->bitArraySize, + return GNUNET_CONTAINER_bloomfilter_init (bf->bitArray, bf->bitArraySize, bf->addressesPerElement); } @@ -209,9 +208,8 @@ incrementBit (char *bitArray, unsigned int bitIdx, high++; } value = ((high << 4) | low); - GNUNET_assert (fileSlot == GNUNET_DISK_file_seek (fh, - fileSlot, - GNUNET_DISK_SEEK_SET)); + GNUNET_assert (fileSlot == + GNUNET_DISK_file_seek (fh, fileSlot, GNUNET_DISK_SEEK_SET)); GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1)); } @@ -348,8 +346,7 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf, { while (slot < (sizeof (GNUNET_HashCode) / sizeof (uint32_t))) { - callback (arg, - bf, + callback (arg, bf, (((uint32_t *) & tmp[round & 1])[slot]) & ((bf->bitArraySize * 8) - 1)); slot++; @@ -375,8 +372,7 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter *bf, * @param bit the bit to increment */ static void -incrementBitCallback (void *cls, - const struct GNUNET_CONTAINER_BloomFilter *bf, +incrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit) { struct GNUNET_CONTAINER_BloomFilter *b = cls; @@ -392,8 +388,7 @@ incrementBitCallback (void *cls, * @param bit the bit to decrement */ static void -decrementBitCallback (void *cls, - const struct GNUNET_CONTAINER_BloomFilter *bf, +decrementBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit) { struct GNUNET_CONTAINER_BloomFilter *b = cls; @@ -409,8 +404,7 @@ decrementBitCallback (void *cls, * @param bit the bit to test */ static void -testBitCallback (void *cls, - const struct GNUNET_CONTAINER_BloomFilter *bf, +testBitCallback (void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit) { int *arg = cls; @@ -432,8 +426,8 @@ testBitCallback (void *cls, * @return the bloomfilter */ struct GNUNET_CONTAINER_BloomFilter * -GNUNET_CONTAINER_bloomfilter_load (const char *filename, - size_t size, unsigned int k) +GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size, + unsigned int k) { struct GNUNET_CONTAINER_BloomFilter *bf; char *rbuff; @@ -453,10 +447,12 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter)); /* Try to open a bloomfilter file */ - bf->fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + bf->fh = + GNUNET_DISK_file_open (filename, + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (NULL == bf->fh) { GNUNET_free (bf); @@ -487,8 +483,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE); if (res == -1) { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "read", bf->filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "read", + bf->filename); } if (res == 0) break; /* is ok! we just did not use that many bits yet */ @@ -522,8 +518,8 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, * @return the bloomfilter */ struct GNUNET_CONTAINER_BloomFilter * -GNUNET_CONTAINER_bloomfilter_init (const char *data, - size_t size, unsigned int k) +GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size, + unsigned int k) { struct GNUNET_CONTAINER_BloomFilter *bf; size_t ui; @@ -752,8 +748,8 @@ GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter *bf, void GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_HashCodeIterator iterator, - void *iterator_cls, - size_t size, unsigned int k) + void *iterator_cls, size_t size, + unsigned int k) { GNUNET_HashCode hc; unsigned int i; diff --git a/src/util/container_heap.c b/src/util/container_heap.c index c1d478e06..ef6bcc892 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c @@ -218,11 +218,11 @@ node_iterator (const struct GNUNET_CONTAINER_Heap *heap, { if (node == NULL) return GNUNET_YES; - if (GNUNET_YES != node_iterator (heap, - node->left_child, iterator, iterator_cls)) + if (GNUNET_YES != + node_iterator (heap, node->left_child, iterator, iterator_cls)) return GNUNET_NO; - if (GNUNET_YES != node_iterator (heap, - node->right_child, iterator, iterator_cls)) + if (GNUNET_YES != + node_iterator (heap, node->right_child, iterator, iterator_cls)) return GNUNET_NO; return iterator (iterator_cls, node, node->element, node->cost); } @@ -267,9 +267,10 @@ GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap) if (pos == NULL) pos = heap->root; element = pos->element; - heap->walk_pos - = (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2)) - ? pos->right_child : pos->left_child; + heap->walk_pos = + (0 == + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + 2)) ? pos->right_child : pos->left_child; return element; } @@ -290,8 +291,12 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap, struct GNUNET_CONTAINER_HeapNode *parent; GNUNET_assert (node->parent == NULL); - while ((heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) - ? (pos->cost >= node->cost) : (pos->cost <= node->cost)) + while ((heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) ? (pos->cost >= + node-> + cost) : (pos-> + cost <= + node-> + cost)) { /* node is descendent of pos */ pos->tree_size += (1 + node->tree_size); @@ -343,8 +348,8 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap, * @return node for the new element */ struct GNUNET_CONTAINER_HeapNode * -GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, - void *element, GNUNET_CONTAINER_HeapCostType cost) +GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, void *element, + GNUNET_CONTAINER_HeapCostType cost) { struct GNUNET_CONTAINER_HeapNode *node; @@ -399,8 +404,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap) } GNUNET_free (root); #if DEBUG - GNUNET_assert (((heap->size == 0) && - (heap->root == NULL)) || + GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || (heap->size == heap->root->tree_size + 1)); CHECK (heap->root); #endif @@ -502,8 +506,7 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node) GNUNET_free (node); #if DEBUG CHECK (heap->root); - GNUNET_assert (((heap->size == 0) && - (heap->root == NULL)) || + GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || (heap->size == heap->root->tree_size + 1)); #endif return ret; @@ -523,16 +526,14 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, GNUNET_CONTAINER_HeapCostType new_cost) { #if DEBUG - GNUNET_assert (((heap->size == 0) && - (heap->root == NULL)) || + GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || (heap->size == heap->root->tree_size + 1)); CHECK (heap->root); #endif remove_node (node); #if DEBUG CHECK (heap->root); - GNUNET_assert (((heap->size == 1) && - (heap->root == NULL)) || + GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) || (heap->size == heap->root->tree_size + 2)); #endif node->cost = new_cost; @@ -542,8 +543,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, insert_node (heap, heap->root, node); #if DEBUG CHECK (heap->root); - GNUNET_assert (((heap->size == 0) && - (heap->root == NULL)) || + GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) || (heap->size == heap->root->tree_size + 1)); #endif } diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c index 64a58e133..c67e96dac 100644 --- a/src/util/container_meta_data.c +++ b/src/util/container_meta_data.c @@ -224,8 +224,7 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct GNUNET_CONTAINER_MetaData j = md2->items; while (NULL != j) { - if ((i->type == j->type) && - (i->format == j->format) && + if ((i->type == j->type) && (i->format == j->format) && (i->data_size == j->data_size) && (0 == memcmp (i->data, j->data, i->data_size))) { @@ -265,8 +264,8 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, const char *plugin_name, enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, - const char *data, size_t data_len) + const char *data_mime_type, const char *data, + size_t data_len) { struct MetaItem *prev; struct MetaItem *pos; @@ -279,8 +278,7 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, { if (pos->data_size < data_len) break; - if ((pos->type == type) && - (pos->data_size == data_len) && + if ((pos->type == type) && (pos->data_size == data_len) && (0 == memcmp (pos->data, data, data_len))) { if ((pos->mime_type == NULL) && (data_mime_type != NULL)) @@ -349,16 +347,13 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, * @return 0 (to continue) */ static int -merge_helper (void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, const char *data, size_t data_len) +merge_helper (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, const char *data_mime_type, + const char *data, size_t data_len) { struct GNUNET_CONTAINER_MetaData *md = cls; - (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, - type, format, + (void) GNUNET_CONTAINER_meta_data_insert (md, plugin_name, type, format, data_mime_type, data, data_len); return 0; } @@ -436,15 +431,13 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct struct GNUNET_TIME_Absolute t; t = GNUNET_TIME_absolute_get (); - GNUNET_CONTAINER_meta_data_delete (md, - EXTRACTOR_METATYPE_PUBLICATION_DATE, + GNUNET_CONTAINER_meta_data_delete (md, EXTRACTOR_METATYPE_PUBLICATION_DATE, NULL, 0); dat = GNUNET_STRINGS_absolute_time_to_string (t); - GNUNET_CONTAINER_meta_data_insert (md, - "", + GNUNET_CONTAINER_meta_data_insert (md, "", EXTRACTOR_METATYPE_PUBLICATION_DATE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", dat, strlen (dat) + 1); + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + dat, strlen (dat) + 1); GNUNET_free (dat); } @@ -458,10 +451,9 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct * @return number of entries */ int -GNUNET_CONTAINER_meta_data_iterate (const struct - GNUNET_CONTAINER_MetaData *md, - EXTRACTOR_MetaDataProcessor - iter, void *iter_cls) +GNUNET_CONTAINER_meta_data_iterate (const struct GNUNET_CONTAINER_MetaData *md, + EXTRACTOR_MetaDataProcessor iter, + void *iter_cls) { struct MetaItem *pos; @@ -472,10 +464,9 @@ GNUNET_CONTAINER_meta_data_iterate (const struct pos = md->items; while (NULL != pos) { - if (0 != iter (iter_cls, - pos->plugin_name, - pos->type, - pos->format, pos->mime_type, pos->data, pos->data_size)) + if (0 != + iter (iter_cls, pos->plugin_name, pos->type, pos->format, + pos->mime_type, pos->data, pos->data_size)) return md->item_count; pos = pos->next; } @@ -562,9 +553,8 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct * @return number of bytes in thumbnail, 0 if not available */ size_t -GNUNET_CONTAINER_meta_data_get_thumbnail (const struct - GNUNET_CONTAINER_MetaData * md, - unsigned char **thumb) +GNUNET_CONTAINER_meta_data_get_thumbnail (const struct GNUNET_CONTAINER_MetaData + * md, unsigned char **thumb) { struct MetaItem *pos; struct MetaItem *match; @@ -576,8 +566,7 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct while (NULL != pos) { if ((NULL != pos->mime_type) && - (0 == strncasecmp ("image/", pos->mime_type, - strlen ("image/"))) && + (0 == strncasecmp ("image/", pos->mime_type, strlen ("image/"))) && (pos->format == EXTRACTOR_METAFORMAT_BINARY)) { if (match == NULL) @@ -615,12 +604,9 @@ GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData pos = md->items; while (NULL != pos) { - GNUNET_CONTAINER_meta_data_insert (ret, - pos->plugin_name, - pos->type, - pos->format, - pos->mime_type, - pos->data, pos->data_size); + GNUNET_CONTAINER_meta_data_insert (ret, pos->plugin_name, pos->type, + pos->format, pos->mime_type, pos->data, + pos->data_size); pos = pos->next; } return ret; @@ -642,8 +628,8 @@ GNUNET_CONTAINER_meta_data_duplicate (const struct GNUNET_CONTAINER_MetaData * GNUNET_NO if compression did not help */ static int -try_compression (const char *data, - size_t oldSize, char **result, size_t * newSize) +try_compression (const char *data, size_t oldSize, char **result, + size_t * newSize) { char *tmp; uLongf dlen; @@ -656,8 +642,8 @@ try_compression (const char *data, * should be able to overshoot by more to be safe */ #endif tmp = GNUNET_malloc (dlen); - if (Z_OK == compress2 ((Bytef *) tmp, - &dlen, (const Bytef *) data, oldSize, 9)) + if (Z_OK == + compress2 ((Bytef *) tmp, &dlen, (const Bytef *) data, oldSize, 9)) { if (dlen < oldSize) { @@ -990,10 +976,9 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct if (md->sbuf != NULL) return md->sbuf_size; ptr = NULL; - ret = GNUNET_CONTAINER_meta_data_serialize (md, - &ptr, - GNUNET_MAX_MALLOC_CHECKED, - GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); + ret = + GNUNET_CONTAINER_meta_data_serialize (md, &ptr, GNUNET_MAX_MALLOC_CHECKED, + GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); if (ret != -1) GNUNET_free (ptr); return ret; @@ -1018,8 +1003,8 @@ decompress (const char *input, size_t inputSize, size_t outputSize) olen = outputSize; output = GNUNET_malloc (olen); - if (Z_OK == uncompress ((Bytef *) output, - &olen, (const Bytef *) input, inputSize)) + if (Z_OK == + uncompress ((Bytef *) output, &olen, (const Bytef *) input, inputSize)) { return output; } @@ -1119,8 +1104,7 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size) mdata = &cdata[ic * sizeof (struct MetaDataEntry)]; for (i = 0; i < ic; i++) { - memcpy (&ent, - &cdata[i * sizeof (struct MetaDataEntry)], + memcpy (&ent, &cdata[i * sizeof (struct MetaDataEntry)], sizeof (struct MetaDataEntry)); format = (enum EXTRACTOR_MetaFormat) ntohl (ent.format); if ((format != EXTRACTOR_METAFORMAT_UTF8) && @@ -1180,11 +1164,10 @@ GNUNET_CONTAINER_meta_data_deserialize (const char *input, size_t size) mime_type = NULL; else mime_type = &mdata[left]; - GNUNET_CONTAINER_meta_data_insert (md, - plugin_name, - (enum EXTRACTOR_MetaType) - ntohl (ent.type), format, mime_type, - meta_data, dlen); + GNUNET_CONTAINER_meta_data_insert (md, plugin_name, + (enum EXTRACTOR_MetaType) ntohl (ent. + type), + format, mime_type, meta_data, dlen); } GNUNET_free_non_null (data); return md; diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index 9635af17d..974d6c7f7 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c @@ -230,9 +230,8 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct * is not in the map */ int -GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap - *map, const GNUNET_HashCode * key, - void *value) +GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap *map, + const GNUNET_HashCode * key, void *value) { struct MapEntry *e; struct MapEntry *p; @@ -348,8 +347,7 @@ GNUNET_CONTAINER_multihashmap_contains (const struct int GNUNET_CONTAINER_multihashmap_contains_value (const struct GNUNET_CONTAINER_MultiHashMap - *map, - const GNUNET_HashCode * key, + *map, const GNUNET_HashCode * key, const void *value) { struct MapEntry *e; @@ -416,8 +414,7 @@ grow (struct GNUNET_CONTAINER_MultiHashMap *map) */ int GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, - const GNUNET_HashCode * key, - void *value, + const GNUNET_HashCode * key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt) { struct MapEntry *e; @@ -467,10 +464,10 @@ GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap *map, */ int GNUNET_CONTAINER_multihashmap_get_multiple (const struct - GNUNET_CONTAINER_MultiHashMap - *map, const GNUNET_HashCode * key, - GNUNET_CONTAINER_HashMapIterator - it, void *it_cls) + GNUNET_CONTAINER_MultiHashMap *map, + const GNUNET_HashCode * key, + GNUNET_CONTAINER_HashMapIterator it, + void *it_cls) { int count; struct MapEntry *e; diff --git a/src/util/container_slist.c b/src/util/container_slist.c index c06d70e91..2d7c24c03 100644 --- a/src/util/container_slist.c +++ b/src/util/container_slist.c @@ -107,8 +107,8 @@ struct GNUNET_CONTAINER_SList_Iterator * @return a new element */ static struct GNUNET_CONTAINER_SList_Elem * -create_elem (enum GNUNET_CONTAINER_SListDisposition disp, - const void *buf, size_t len) +create_elem (enum GNUNET_CONTAINER_SListDisposition disp, const void *buf, + size_t len) { struct GNUNET_CONTAINER_SList_Elem *e; @@ -186,8 +186,9 @@ GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, { struct GNUNET_CONTAINER_SList_Iterator *i; - for (i = GNUNET_CONTAINER_slist_begin (src); GNUNET_CONTAINER_slist_end (i) != - GNUNET_YES; GNUNET_CONTAINER_slist_next (i)) + for (i = GNUNET_CONTAINER_slist_begin (src); + GNUNET_CONTAINER_slist_end (i) != GNUNET_YES; + GNUNET_CONTAINER_slist_next (i)) { GNUNET_CONTAINER_slist_add (dst, diff --git a/src/util/crypto_aes.c b/src/util/crypto_aes.c index 200c367c1..a984e17fc 100644 --- a/src/util/crypto_aes.c +++ b/src/util/crypto_aes.c @@ -73,12 +73,11 @@ GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionKey * @returns the size of the encrypted block, -1 for errors */ ssize_t -GNUNET_CRYPTO_aes_encrypt (const void *block, - size_t len, - const struct GNUNET_CRYPTO_AesSessionKey - * sessionkey, - const struct GNUNET_CRYPTO_AesInitializationVector - * iv, void *result) +GNUNET_CRYPTO_aes_encrypt (const void *block, size_t len, + const struct GNUNET_CRYPTO_AesSessionKey * + sessionkey, + const struct GNUNET_CRYPTO_AesInitializationVector * + iv, void *result) { gcry_cipher_hd_t handle; int rc; @@ -89,9 +88,9 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, GNUNET_break (0); return -1; } - GNUNET_assert (0 == gcry_cipher_open (&handle, - GCRY_CIPHER_AES256, - GCRY_CIPHER_MODE_CFB, 0)); + GNUNET_assert (0 == + gcry_cipher_open (&handle, GCRY_CIPHER_AES256, + GCRY_CIPHER_MODE_CFB, 0)); rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); rc = gcry_cipher_setiv (handle, iv, @@ -115,12 +114,11 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, * @return -1 on failure, size of decrypted block on success */ ssize_t -GNUNET_CRYPTO_aes_decrypt (const void *block, - size_t size, - const struct GNUNET_CRYPTO_AesSessionKey - * sessionkey, - const struct GNUNET_CRYPTO_AesInitializationVector - * iv, void *result) +GNUNET_CRYPTO_aes_decrypt (const void *block, size_t size, + const struct GNUNET_CRYPTO_AesSessionKey * + sessionkey, + const struct GNUNET_CRYPTO_AesInitializationVector * + iv, void *result) { gcry_cipher_hd_t handle; int rc; @@ -131,9 +129,9 @@ GNUNET_CRYPTO_aes_decrypt (const void *block, GNUNET_break (0); return -1; } - GNUNET_assert (0 == gcry_cipher_open (&handle, - GCRY_CIPHER_AES256, - GCRY_CIPHER_MODE_CFB, 0)); + GNUNET_assert (0 == + gcry_cipher_open (&handle, GCRY_CIPHER_AES256, + GCRY_CIPHER_MODE_CFB, 0)); rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH); GNUNET_assert ((0 == rc) || ((char) rc == GPG_ERR_WEAK_KEY)); rc = gcry_cipher_setiv (handle, iv, diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index c693ed081..6438784ba 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c @@ -175,8 +175,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, - const char *filename, - size_t blocksize, + const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls) { @@ -202,17 +201,17 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, GNUNET_free (fhc); return NULL; } - fhc->fh = GNUNET_DISK_file_open (filename, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE); + fhc->fh = + GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (!fhc->fh) { GNUNET_free (fhc->filename); GNUNET_free (fhc); return NULL; } - fhc->task - = GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); + fhc->task = + GNUNET_SCHEDULER_add_with_priority (priority, &file_hash_task, fhc); return fhc; } @@ -390,8 +389,8 @@ GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a, void -GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, - const GNUNET_HashCode * b, GNUNET_HashCode * result) +GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a, const GNUNET_HashCode * b, + GNUNET_HashCode * result) { int i; @@ -542,12 +541,11 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, void GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, const struct GNUNET_CRYPTO_AesSessionKey *rkey, - const void *salt, - size_t salt_len, va_list argp) + const void *salt, size_t salt_len, + va_list argp) { - GNUNET_CRYPTO_kdf_v (key->key, - sizeof (key->key), - salt, salt_len, rkey->key, sizeof (rkey->key), argp); + GNUNET_CRYPTO_kdf_v (key->key, sizeof (key->key), salt, salt_len, rkey->key, + sizeof (rkey->key), argp); } @@ -561,15 +559,14 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, */ void GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, - const void *plaintext, - size_t plaintext_len, GNUNET_HashCode * hmac) + const void *plaintext, size_t plaintext_len, + GNUNET_HashCode * hmac) { gcry_md_hd_t md; const unsigned char *mc; - GNUNET_assert (GPG_ERR_NO_ERROR == gcry_md_open (&md, - GCRY_MD_SHA512, - GCRY_MD_FLAG_HMAC)); + GNUNET_assert (GPG_ERR_NO_ERROR == + gcry_md_open (&md, GCRY_MD_SHA512, GCRY_MD_FLAG_HMAC)); gcry_md_setkey (md, key->key, sizeof (key->key)); gcry_md_write (md, plaintext, plaintext_len); mc = gcry_md_read (md, GCRY_MD_SHA512); diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c index d97f516fe..0654b51f6 100644 --- a/src/util/crypto_hkdf.c +++ b/src/util/crypto_hkdf.c @@ -71,8 +71,8 @@ * @return HMAC, freed by caller via gcry_md_close/_reset */ static const void * -doHMAC (gcry_md_hd_t mac, - const void *key, size_t key_len, const void *buf, size_t buf_len) +doHMAC (gcry_md_hd_t mac, const void *key, size_t key_len, const void *buf, + size_t buf_len) { gcry_md_setkey (mac, key, key_len); gcry_md_write (mac, buf, buf_len); @@ -91,9 +91,8 @@ doHMAC (gcry_md_hd_t mac, * @return GNUNET_YES on success */ static int -getPRK (gcry_md_hd_t mac, - const void *xts, size_t xts_len, - const void *skm, size_t skm_len, void *prk) +getPRK (gcry_md_hd_t mac, const void *xts, size_t xts_len, const void *skm, + size_t skm_len, void *prk) { const void *ret; @@ -136,10 +135,9 @@ dump (const char *src, const void *p, unsigned int l) * @return GNUNET_YES on success */ int -GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, - int xtr_algo, int prf_algo, - const void *xts, size_t xts_len, - const void *skm, size_t skm_len, va_list argp) +GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo, + const void *xts, size_t xts_len, const void *skm, + size_t skm_len, va_list argp) { const void *hc; unsigned long i, t, d; @@ -280,17 +278,17 @@ hkdf_ok: * @return GNUNET_YES on success */ int -GNUNET_CRYPTO_hkdf (void *result, size_t out_len, - int xtr_algo, int prf_algo, - const void *xts, size_t xts_len, - const void *skm, size_t skm_len, ...) +GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo, + const void *xts, size_t xts_len, const void *skm, + size_t skm_len, ...) { va_list argp; int ret; va_start (argp, skm_len); - ret = GNUNET_CRYPTO_hkdf_v (result, out_len, xtr_algo, prf_algo, xts, - xts_len, skm, skm_len, argp); + ret = + GNUNET_CRYPTO_hkdf_v (result, out_len, xtr_algo, prf_algo, xts, xts_len, + skm, skm_len, argp); va_end (argp); return ret; diff --git a/src/util/crypto_kdf.c b/src/util/crypto_kdf.c index dc2e667af..cd665ad23 100644 --- a/src/util/crypto_kdf.c +++ b/src/util/crypto_kdf.c @@ -41,9 +41,9 @@ * @return GNUNET_YES on success */ int -GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, - const void *xts, size_t xts_len, const void *skm, - size_t skm_len, va_list argp) +GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts, + size_t xts_len, const void *skm, size_t skm_len, + va_list argp) { /* * "Finally, we point out to a particularly advantageous instantiation using @@ -73,9 +73,8 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, * @return GNUNET_YES on success */ int -GNUNET_CRYPTO_kdf (void *result, size_t out_len, - const void *xts, size_t xts_len, const void *skm, - size_t skm_len, ...) +GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, + size_t xts_len, const void *skm, size_t skm_len, ...) { va_list argp; int ret; diff --git a/src/util/crypto_ksk.c b/src/util/crypto_ksk.c index 7c23fc1e0..bec87c803 100644 --- a/src/util/crypto_ksk.c +++ b/src/util/crypto_ksk.c @@ -397,8 +397,8 @@ gen_prime (gcry_mpi_t * ptest, unsigned int nbits, GNUNET_HashCode * hc) * @param hc the HC to use for PRNG (modified!) */ static void -generate_kblock_key (KBlock_secret_key *sk, - unsigned int nbits, GNUNET_HashCode * hc) +generate_kblock_key (KBlock_secret_key *sk, unsigned int nbits, + GNUNET_HashCode * hc) { gcry_mpi_t t1, t2; gcry_mpi_t phi; /* helper: (p-1)(q-1) */ @@ -569,10 +569,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) pos = 0; size = ntohs (encoding->sizen); - rc = gcry_mpi_scan (&n, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&n, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizen); if (rc) { @@ -580,10 +579,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) return NULL; } size = ntohs (encoding->sizee); - rc = gcry_mpi_scan (&e, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&e, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizee); if (rc) { @@ -592,10 +590,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) return NULL; } size = ntohs (encoding->sized); - rc = gcry_mpi_scan (&d, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&d, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sized); if (rc) { @@ -608,10 +605,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) size = ntohs (encoding->sizep); if (size > 0) { - rc = gcry_mpi_scan (&q, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&q, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizep); if (rc) { @@ -627,10 +623,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) size = ntohs (encoding->sizeq); if (size > 0) { - rc = gcry_mpi_scan (&p, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&p, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizeq); if (rc) { @@ -652,10 +647,9 @@ ksk_decode_key (const struct KskRsaPrivateKeyBinaryEncoded *encoding) pos; if (size > 0) { - rc = gcry_mpi_scan (&u, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&u, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); if (rc) { LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index 03f6c0e98..bb105437d 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c @@ -71,8 +71,8 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i) ul = UINT32_MAX - (UINT32_MAX % i); do { - gcry_randomize ((unsigned char *) &ret, - sizeof (uint32_t), GCRY_STRONG_RANDOM); + gcry_randomize ((unsigned char *) &ret, sizeof (uint32_t), + GCRY_STRONG_RANDOM); } while (ret >= ul); return ret % i; @@ -147,8 +147,8 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max) ul = UINT64_MAX - (UINT64_MAX % max); do { - gcry_randomize ((unsigned char *) &ret, - sizeof (uint64_t), GCRY_STRONG_RANDOM); + gcry_randomize ((unsigned char *) &ret, sizeof (uint64_t), + GCRY_STRONG_RANDOM); } while (ret >= ul); return ret % max; @@ -195,8 +195,8 @@ static struct GNUNET_OS_Process *genproc; * blocked gathering entropy. */ static void -entropy_generator (void *cls, - const char *what, int printchar, int current, int total) +entropy_generator (void *cls, const char *what, int printchar, int current, + int total) { unsigned long code; enum GNUNET_OS_ProcessStatusType type; @@ -234,11 +234,10 @@ entropy_generator (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting `%s' process to generate entropy\n"), "find"); - genproc = GNUNET_OS_start_process (NULL, NULL, "sh", - "sh", - "-c", - "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null", - NULL); + genproc = + GNUNET_OS_start_process (NULL, NULL, "sh", "sh", "-c", + "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null", + NULL); } diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 6be2f53c0..3607998e4 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c @@ -108,10 +108,10 @@ GNUNET_CRYPTO_rsa_key_create () gcry_sexp_t s_key; gcry_sexp_t s_keyparam; - GNUNET_assert (0 == gcry_sexp_build (&s_keyparam, - NULL, - "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))", - HOSTKEY_LEN)); + GNUNET_assert (0 == + gcry_sexp_build (&s_keyparam, NULL, + "(genkey(rsa(nbits %d)(rsa-use-e 3:257)))", + HOSTKEY_LEN)); GNUNET_assert (0 == gcry_pk_genkey (&s_key, s_keyparam)); gcry_sexp_release (s_keyparam); #if EXTRA_CHECKS @@ -133,8 +133,8 @@ GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) } static int -key_from_sexp (gcry_mpi_t * array, - gcry_sexp_t sexp, const char *topname, const char *elems) +key_from_sexp (gcry_mpi_t * array, gcry_sexp_t sexp, const char *topname, + const char *elems) { gcry_sexp_t list, l2; const char *s; @@ -192,8 +192,8 @@ key_from_sexp (gcry_mpi_t * array, void GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey *priv, - struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pub) + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded + *pub) { gcry_mpi_t skey[2]; size_t size; @@ -211,14 +211,15 @@ GNUNET_CRYPTO_rsa_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey pub->sizen = htons (GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH); pub->padding = 0; size = GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH; - GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, - &pub->key[0], size, &size, skey[0])); + GNUNET_assert (0 == + gcry_mpi_print (GCRYMPI_FMT_USG, &pub->key[0], size, &size, + skey[0])); adjust (&pub->key[0], size, GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH); size = GNUNET_CRYPTO_RSA_KEY_LENGTH - GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH; GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, - &pub->key - [GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], + &pub-> + key[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], size, &size, skey[1])); adjust (&pub->key[GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH], size, GNUNET_CRYPTO_RSA_KEY_LENGTH - @@ -271,8 +272,8 @@ public2PrivateKey (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded gcry_mpi_release (n); return NULL; } - rc = gcry_sexp_build (&result, - &erroff, "(public-key(rsa(n %m)(e %m)))", n, e); + rc = gcry_sexp_build (&result, &erroff, "(public-key(rsa(n %m)(e %m)))", n, + e); gcry_mpi_release (n); gcry_mpi_release (e); if (rc) @@ -329,9 +330,10 @@ rsa_encode_key (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) { if (pkv[i] != NULL) { - GNUNET_assert (0 == gcry_mpi_aprint (GCRYMPI_FMT_USG, - (unsigned char **) &pbu[i], - &sizes[i], pkv[i])); + GNUNET_assert (0 == + gcry_mpi_aprint (GCRYMPI_FMT_USG, + (unsigned char **) &pbu[i], &sizes[i], + pkv[i])); size += sizes[i]; } else @@ -399,10 +401,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) pos = 0; size = ntohs (encoding->sizen); - rc = gcry_mpi_scan (&n, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&n, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizen); if (rc) { @@ -410,10 +411,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) return NULL; } size = ntohs (encoding->sizee); - rc = gcry_mpi_scan (&e, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&e, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizee); if (rc) { @@ -422,10 +422,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) return NULL; } size = ntohs (encoding->sized); - rc = gcry_mpi_scan (&d, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&d, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sized); if (rc) { @@ -438,10 +437,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) size = ntohs (encoding->sizep); if (size > 0) { - rc = gcry_mpi_scan (&q, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&q, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizep); if (rc) { @@ -457,10 +455,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) size = ntohs (encoding->sizeq); if (size > 0) { - rc = gcry_mpi_scan (&p, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&p, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); pos += ntohs (encoding->sizeq); if (rc) { @@ -481,10 +478,9 @@ GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len) ntohs (encoding->len) - sizeof (struct RsaPrivateKeyBinaryEncoded) - pos; if (size > 0) { - rc = gcry_mpi_scan (&u, - GCRYMPI_FMT_USG, - &((const unsigned char *) (&encoding[1]))[pos], - size, &size); + rc = gcry_mpi_scan (&u, GCRYMPI_FMT_USG, + &((const unsigned char *) (&encoding[1]))[pos], size, + &size); if (rc) { LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); @@ -577,9 +573,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) while (GNUNET_YES != GNUNET_DISK_file_test (filename)) { fd = GNUNET_DISK_file_open (filename, - GNUNET_DISK_OPEN_WRITE | - GNUNET_DISK_OPEN_CREATE | - GNUNET_DISK_OPEN_FAILIFEXISTS, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE + | GNUNET_DISK_OPEN_FAILIFEXISTS, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); if (NULL == fd) @@ -590,8 +585,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) { /* must exist but not be accessible, fail for good! */ if (0 != ACCESS (filename, R_OK)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, - "access", filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "access", + filename); else GNUNET_break (0); /* what is going on!? */ return NULL; @@ -605,8 +600,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) while (GNUNET_YES != GNUNET_DISK_file_lock (fd, 0, - sizeof (struct - RsaPrivateKeyBinaryEncoded), + sizeof (struct RsaPrivateKeyBinaryEncoded), GNUNET_YES)) { sleep (1); @@ -614,9 +608,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) { ec = errno; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("Could not aquire lock on file `%s': %s...\n"), - filename, STRERROR (ec)); + _("Could not aquire lock on file `%s': %s...\n"), filename, + STRERROR (ec)); } } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -662,8 +655,8 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) { ec = errno; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Could not aquire lock on file `%s': %s...\n"), - filename, STRERROR (ec)); + _("Could not aquire lock on file `%s': %s...\n"), filename, + STRERROR (ec)); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("This may be ok if someone is currently generating a hostkey.\n")); @@ -754,10 +747,9 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) * @returns GNUNET_SYSERR on error, GNUNET_OK if ok */ int -GNUNET_CRYPTO_rsa_encrypt (const void *block, - size_t size, - const struct - GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey, +GNUNET_CRYPTO_rsa_encrypt (const void *block, size_t size, + const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded + *publicKey, struct GNUNET_CRYPTO_RsaEncryptedData *target) { gcry_sexp_t result; @@ -786,9 +778,9 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block, GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "a")); gcry_sexp_release (result); isize = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); - GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, - (unsigned char *) target, isize, &isize, - rval)); + GNUNET_assert (0 == + gcry_mpi_print (GCRYMPI_FMT_USG, (unsigned char *) target, + isize, &isize, rval)); gcry_mpi_release (rval); adjust (&target->encoding[0], isize, sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); @@ -807,8 +799,8 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block, */ ssize_t GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, - const struct GNUNET_CRYPTO_RsaEncryptedData * - block, void *result, size_t max) + const struct GNUNET_CRYPTO_RsaEncryptedData * block, + void *result, size_t max) { gcry_sexp_t resultsexp; gcry_sexp_t data; @@ -822,12 +814,12 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, GNUNET_assert (0 == gcry_pk_testkey (key->sexp)); #endif size = sizeof (struct GNUNET_CRYPTO_RsaEncryptedData); - GNUNET_assert (0 == gcry_mpi_scan (&val, - GCRYMPI_FMT_USG, &block->encoding[0], - size, &size)); GNUNET_assert (0 == - gcry_sexp_build (&data, &erroff, - "(enc-val(flags)(rsa(a %m)))", val)); + gcry_mpi_scan (&val, GCRYMPI_FMT_USG, &block->encoding[0], + size, &size)); + GNUNET_assert (0 == + gcry_sexp_build (&data, &erroff, "(enc-val(flags)(rsa(a %m)))", + val)); gcry_mpi_release (val); GNUNET_assert (0 == gcry_pk_decrypt (&resultsexp, data, key->sexp)); gcry_sexp_release (data); @@ -858,8 +850,8 @@ GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey * key, */ int GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key, - const struct GNUNET_CRYPTO_RsaSignaturePurpose - *purpose, struct GNUNET_CRYPTO_RsaSignature *sig) + const struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose, + struct GNUNET_CRYPTO_RsaSignature *sig) { gcry_sexp_t result; gcry_sexp_t data; @@ -886,9 +878,9 @@ GNUNET_CRYPTO_rsa_sign (const struct GNUNET_CRYPTO_RsaPrivateKey *key, GNUNET_assert (0 == key_from_sexp (&rval, result, "rsa", "s")); gcry_sexp_release (result); ssize = sizeof (struct GNUNET_CRYPTO_RsaSignature); - GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, - (unsigned char *) sig, ssize, &ssize, - rval)); + GNUNET_assert (0 == + gcry_mpi_print (GCRYMPI_FMT_USG, (unsigned char *) sig, ssize, + &ssize, rval)); gcry_mpi_release (rval); adjust (sig->sig, ssize, sizeof (struct GNUNET_CRYPTO_RsaSignature)); return GNUNET_OK; @@ -927,9 +919,9 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose, return GNUNET_SYSERR; /* purpose mismatch */ GNUNET_CRYPTO_hash (validate, ntohl (validate->size), &hc); size = sizeof (struct GNUNET_CRYPTO_RsaSignature); - GNUNET_assert (0 == gcry_mpi_scan (&val, - GCRYMPI_FMT_USG, - (const unsigned char *) sig, size, &size)); + GNUNET_assert (0 == + gcry_mpi_scan (&val, GCRYMPI_FMT_USG, + (const unsigned char *) sig, size, &size)); GNUNET_assert (0 == gcry_sexp_build (&sigdata, &erroff, "(sig-val(rsa(s %m)))", val)); @@ -937,9 +929,10 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose, bufSize = strlen (FORMATSTRING) + 1; buff = GNUNET_malloc (bufSize); memcpy (buff, FORMATSTRING, bufSize); - memcpy (&buff[strlen (FORMATSTRING) - - strlen - ("0123456789012345678901234567890123456789012345678901234567890123))")], + memcpy (&buff + [strlen (FORMATSTRING) - + strlen + ("0123456789012345678901234567890123456789012345678901234567890123))")], &hc, sizeof (GNUNET_HashCode)); GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0)); GNUNET_free (buff); @@ -957,8 +950,8 @@ GNUNET_CRYPTO_rsa_verify (uint32_t purpose, if (rc) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("RSA signature verification failed at %s:%d: %s\n"), - __FILE__, __LINE__, gcry_strerror (rc)); + _("RSA signature verification failed at %s:%d: %s\n"), __FILE__, + __LINE__, gcry_strerror (rc)); return GNUNET_SYSERR; } return GNUNET_OK; diff --git a/src/util/disk.c b/src/util/disk.c index dd7db7d73..6ba5db773 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -172,8 +172,7 @@ getSizeRec (void *cls, const char *fn) #endif if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)) gfsd->total += buf.st_size; - if ((S_ISDIR (buf.st_mode)) && - (0 == ACCESS (fn, X_OK)) && + if ((S_ISDIR (buf.st_mode)) && (0 == ACCESS (fn, X_OK)) && ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))) { if (GNUNET_SYSERR == GNUNET_DISK_directory_scan (fn, &getSizeRec, gfsd)) @@ -255,8 +254,8 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset, * @return GNUNET_SYSERR on error, GNUNET_OK on success */ int -GNUNET_DISK_file_size (const char *filename, - uint64_t * size, int includeSymLinks) +GNUNET_DISK_file_size (const char *filename, uint64_t * size, + int includeSymLinks) { struct GetFileSizeData gfsd; int ret; @@ -286,8 +285,8 @@ GNUNET_DISK_file_size (const char *filename, * @return GNUNET_OK on success */ int -GNUNET_DISK_file_get_identifiers (const char *filename, - uint64_t * dev, uint64_t * ino) +GNUNET_DISK_file_get_identifiers (const char *filename, uint64_t * dev, + uint64_t * ino) { #if LINUX struct stat sbuf; @@ -427,8 +426,8 @@ GNUNET_DISK_get_blocks_available (const char *part) if (!GetDiskFreeSpace (szDrive, &dwDummy, &dwDummy, &dwBlocks, &dwDummy)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("`%s' failed for drive `%s': %u\n"), - "GetDiskFreeSpace", szDrive, GetLastError ()); + _("`%s' failed for drive `%s': %u\n"), "GetDiskFreeSpace", + szDrive, GetLastError ()); return -1; } @@ -772,15 +771,14 @@ GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle * h, * @return number of bytes written on success, GNUNET_SYSERR on error */ ssize_t -GNUNET_DISK_fn_write (const char *fn, const void *buffer, - size_t n, enum GNUNET_DISK_AccessPermissions mode) +GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, + enum GNUNET_DISK_AccessPermissions mode) { struct GNUNET_DISK_FileHandle *fh; ssize_t ret; fh = GNUNET_DISK_file_open (fn, - GNUNET_DISK_OPEN_WRITE - | GNUNET_DISK_OPEN_TRUNCATE + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE | GNUNET_DISK_OPEN_CREATE, mode); if (!fh) return GNUNET_SYSERR; @@ -862,10 +860,7 @@ GNUNET_DISK_directory_scan (const char *dirName, /* dname can end in "/" only if dname == "/"; * if dname does not end in "/", we need to add * a "/" (otherwise, we must not!) */ - GNUNET_snprintf (name, - n_size, - "%s%s%s", - dname, + GNUNET_snprintf (name, n_size, "%s%s%s", dname, (strcmp (dname, DIR_SEPARATOR_STR) == 0) ? "" : DIR_SEPARATOR_STR, finfo->d_name); if (GNUNET_OK != callback (callback_cls, name)) @@ -954,8 +949,8 @@ directory_iterator_task (void *cls, * GNUNET_SYSERR if abort was YES */ int -GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator - *iter, int can) +GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator *iter, + int can) { struct dirent *finfo; @@ -972,8 +967,8 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator if ((0 == strcmp (finfo->d_name, ".")) || (0 == strcmp (finfo->d_name, ".."))) continue; - GNUNET_asprintf (&iter->next_name, - "%s%s%s", iter->dirname, DIR_SEPARATOR_STR, finfo->d_name); + GNUNET_asprintf (&iter->next_name, "%s%s%s", iter->dirname, + DIR_SEPARATOR_STR, finfo->d_name); break; } if (finfo == NULL) @@ -981,8 +976,8 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES); return GNUNET_NO; } - GNUNET_SCHEDULER_add_with_priority (iter->priority, - &directory_iterator_task, iter); + GNUNET_SCHEDULER_add_with_priority (iter->priority, &directory_iterator_task, + iter); return GNUNET_YES; } @@ -1101,13 +1096,14 @@ GNUNET_DISK_file_copy (const char *src, const char *dst) GNUNET_DISK_PERM_NONE); if (!in) return GNUNET_SYSERR; - out = GNUNET_DISK_file_open (dst, GNUNET_DISK_OPEN_WRITE - | GNUNET_DISK_OPEN_CREATE | - GNUNET_DISK_OPEN_FAILIFEXISTS, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE | - GNUNET_DISK_PERM_GROUP_READ | - GNUNET_DISK_PERM_GROUP_WRITE); + out = + GNUNET_DISK_file_open (dst, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | + GNUNET_DISK_OPEN_FAILIFEXISTS, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE | + GNUNET_DISK_PERM_GROUP_READ | + GNUNET_DISK_PERM_GROUP_WRITE); if (!out) { GNUNET_DISK_file_close (in); @@ -1152,8 +1148,8 @@ GNUNET_DISK_filename_canonicalize (char *fn) { c = *idx; - if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || - c == '"' || c == '<' || c == '>' || c == '|') + if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '"' || + c == '<' || c == '>' || c == '|') { *idx = '_'; } @@ -1181,8 +1177,8 @@ GNUNET_DISK_file_change_owner (const char *filename, const char *user) if (pws == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Cannot obtain information about user `%s': %s\n"), - user, STRERROR (errno)); + _("Cannot obtain information about user `%s': %s\n"), user, + STRERROR (errno)); return GNUNET_SYSERR; } if (0 != chown (filename, pws->pw_uid, pws->pw_gid)) @@ -1226,8 +1222,9 @@ GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, off_t lockStart, memset (&o, 0, sizeof (OVERLAPPED)); o.Offset = lockStart; - if (!LockFileEx (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) - | LOCKFILE_FAIL_IMMEDIATELY, 0, lockEnd - lockStart, 0, &o)) + if (!LockFileEx + (fh->h, (excl ? LOCKFILE_EXCLUSIVE_LOCK : 0) | LOCKFILE_FAIL_IMMEDIATELY, + 0, lockEnd - lockStart, 0, &o)) { SetErrnoFromWinError (GetLastError ()); return GNUNET_SYSERR; @@ -1295,8 +1292,7 @@ GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, off_t unlockStart, * @return IO handle on success, NULL on error */ struct GNUNET_DISK_FileHandle * -GNUNET_DISK_file_open (const char *fn, - enum GNUNET_DISK_OpenFlags flags, +GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm) { char *expfn; @@ -1385,8 +1381,9 @@ GNUNET_DISK_file_open (const char *fn, } /* TODO: access priviledges? */ - h = CreateFile (expfn, access, FILE_SHARE_DELETE | FILE_SHARE_READ - | FILE_SHARE_WRITE, NULL, disp, FILE_ATTRIBUTE_NORMAL, NULL); + h = CreateFile (expfn, access, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + disp, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { SetErrnoFromWinError (GetLastError ()); @@ -1713,10 +1710,9 @@ GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h) Note that the return value is either NO_ERROR or GetLastError, unlike CreatePipe, which returns a bool for success or failure. */ static int -create_selectable_pipe (PHANDLE read_pipe_ptr, - PHANDLE write_pipe_ptr, - LPSECURITY_ATTRIBUTES sa_ptr, - DWORD psize, DWORD dwReadMode, DWORD dwWriteMode) +create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr, + LPSECURITY_ATTRIBUTES sa_ptr, DWORD psize, + DWORD dwReadMode, DWORD dwWriteMode) { /* Default to error. */ *read_pipe_ptr = *write_pipe_ptr = INVALID_HANDLE_VALUE; @@ -1921,10 +1917,9 @@ GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write) SetErrnoFromWinError (GetLastError ()); return NULL; } - if (!DuplicateHandle (GetCurrentProcess (), p->fd[0]->h, - GetCurrentProcess (), &tmp_handle, 0, - inherit_read == GNUNET_YES ? TRUE : FALSE, - DUPLICATE_SAME_ACCESS)) + if (!DuplicateHandle + (GetCurrentProcess (), p->fd[0]->h, GetCurrentProcess (), &tmp_handle, 0, + inherit_read == GNUNET_YES ? TRUE : FALSE, DUPLICATE_SAME_ACCESS)) { SetErrnoFromWinError (GetLastError ()); CloseHandle (p->fd[0]->h); @@ -1935,10 +1930,9 @@ GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write) CloseHandle (p->fd[0]->h); p->fd[0]->h = tmp_handle; - if (!DuplicateHandle (GetCurrentProcess (), p->fd[1]->h, - GetCurrentProcess (), &tmp_handle, 0, - inherit_write == GNUNET_YES ? TRUE : FALSE, - DUPLICATE_SAME_ACCESS)) + if (!DuplicateHandle + (GetCurrentProcess (), p->fd[1]->h, GetCurrentProcess (), &tmp_handle, 0, + inherit_write == GNUNET_YES ? TRUE : FALSE, DUPLICATE_SAME_ACCESS)) { SetErrnoFromWinError (GetLastError ()); CloseHandle (p->fd[0]->h); @@ -2093,8 +2087,7 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p) * @return pipe handle on success, NULL on error */ struct GNUNET_DISK_FileHandle * -GNUNET_DISK_npipe_create (char **fn, - enum GNUNET_DISK_OpenFlags flags, +GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm) { #ifdef MINGW @@ -2226,8 +2219,7 @@ GNUNET_DISK_npipe_create (char **fn, * @return pipe handle on success, NULL on error */ struct GNUNET_DISK_FileHandle * -GNUNET_DISK_npipe_open (const char *fn, - enum GNUNET_DISK_OpenFlags flags, +GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm) { #ifdef MINGW diff --git a/src/util/getopt.c b/src/util/getopt.c index 2a35ab278..db81d1c3d 100644 --- a/src/util/getopt.c +++ b/src/util/getopt.c @@ -410,8 +410,8 @@ _getopt_initialize (argc, argv, optstring) { if (nonoption_flags_max_len == 0) { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') + if (__getopt_nonoption_flags == NULL || + __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { @@ -497,11 +497,9 @@ _getopt_initialize (argc, argv, optstring) long-named options. */ static int -GN_getopt_internal (int argc, - char *const *argv, - const char *optstring, - const struct GNoption *longopts, - int *longind, int long_only) +GN_getopt_internal (int argc, char *const *argv, const char *optstring, + const struct GNoption *longopts, int *longind, + int long_only) { static int __getopt_initialized = 0; static int GNopterr = 1; @@ -600,8 +598,8 @@ GN_getopt_internal (int argc, /* We have found another option-ARGV-element. * Skip the initial punctuation. */ - nextchar = (argv[GNoptind] + 1 - + (longopts != NULL && argv[GNoptind][1] == '-')); + nextchar = + (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-')); } /* Decode the current option-ARGV-element. */ @@ -619,11 +617,10 @@ GN_getopt_internal (int argc, * * This distinction seems to be the most useful approach. */ - if (longopts != NULL - && (argv[GNoptind][1] == '-' - || (long_only - && (argv[GNoptind][2] - || !my_index (optstring, argv[GNoptind][1]))))) + if (longopts != NULL && + (argv[GNoptind][1] == '-' || + (long_only && + (argv[GNoptind][2] || !my_index (optstring, argv[GNoptind][1]))))) { char *nameend; const struct GNoption *p; @@ -641,8 +638,8 @@ GN_getopt_internal (int argc, for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) + if ((unsigned int) (nameend - nextchar) == + (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -664,8 +661,8 @@ GN_getopt_internal (int argc, if (ambig && !exact) { if (GNopterr) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[GNoptind]); + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], + argv[GNoptind]); nextchar += strlen (nextchar); GNoptind++; return '?'; @@ -688,14 +685,12 @@ GN_getopt_internal (int argc, if (argv[GNoptind - 1][1] == '-') /* --option */ fprintf (stderr, - _ - ("%s: option `--%s' does not allow an argument\n"), + _("%s: option `--%s' does not allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, - _ - ("%s: option `%c%s' does not allow an argument\n"), + _("%s: option `%c%s' does not allow an argument\n"), argv[0], argv[GNoptind - 1][0], pfound->name); } nextchar += strlen (nextchar); @@ -712,8 +707,7 @@ GN_getopt_internal (int argc, { if (GNopterr) { - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), + fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[GNoptind - 1]); } nextchar += strlen (nextchar); @@ -735,19 +729,19 @@ GN_getopt_internal (int argc, * or the option starts with '--' or is not a valid short * option, then it's an error. * Otherwise interpret it as a short option. */ - if (!long_only || argv[GNoptind][1] == '-' - || my_index (optstring, *nextchar) == NULL) + if (!long_only || argv[GNoptind][1] == '-' || + my_index (optstring, *nextchar) == NULL) { if (GNopterr) { if (argv[GNoptind][1] == '-') /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], + nextchar); else /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[GNoptind][0], nextchar); + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], + argv[GNoptind][0], nextchar); } nextchar = (char *) ""; GNoptind++; @@ -849,8 +843,8 @@ GN_getopt_internal (int argc, if (ambig && !exact) { if (GNopterr) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[GNoptind]); + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], + argv[GNoptind]); nextchar += strlen (nextchar); GNoptind++; return '?'; @@ -881,8 +875,7 @@ GN_getopt_internal (int argc, else { if (GNopterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), + fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[GNoptind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; @@ -930,8 +923,8 @@ GN_getopt_internal (int argc, if (GNopterr) { /* 1003.2 specifies the format of this message. */ - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), argv[0], c); + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); } if (optstring[0] == ':') c = ':'; @@ -950,9 +943,7 @@ GN_getopt_internal (int argc, } static int -GNgetopt_long (int argc, - char *const *argv, - const char *options, +GNgetopt_long (int argc, char *const *argv, const char *options, const struct GNoption *long_options, int *opt_index) { return GN_getopt_internal (argc, argv, options, long_options, opt_index, 0); @@ -1028,9 +1019,9 @@ GNUNET_GETOPT_run (const char *binaryOptions, clpc.currentArgument = GNoptind - 1; if ((char) c == allOptions[i].shortName) { - cont = allOptions[i].processor (&clpc, - allOptions[i].scls, - allOptions[i].name, GNoptarg); + cont = + allOptions[i].processor (&clpc, allOptions[i].scls, + allOptions[i].name, GNoptarg); break; } } diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index aa85bf536..d0c8c0e6a 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c @@ -166,9 +166,8 @@ OUTER: * @return GNUNET_OK */ int -GNUNET_GETOPT_increment_value (struct - GNUNET_GETOPT_CommandLineProcessorContext *ctx, - void *scls, const char *option, +GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext + *ctx, void *scls, const char *option, const char *value) { int *val = scls; @@ -218,9 +217,8 @@ GNUNET_GETOPT_set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, * @return GNUNET_OK */ int -GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext - *ctx, void *scls, const char *option, - const char *value) +GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, + void *scls, const char *option, const char *value) { char **val = scls; @@ -246,9 +244,8 @@ GNUNET_GETOPT_set_string (struct GNUNET_GETOPT_CommandLineProcessorContext * @return GNUNET_OK if parsing the value worked */ int -GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext - *ctx, void *scls, const char *option, - const char *value) +GNUNET_GETOPT_set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, + void *scls, const char *option, const char *value) { unsigned long long *val = scls; diff --git a/src/util/gnunet-config-diff.c b/src/util/gnunet-config-diff.c index 02ffa77a1..207b9518a 100644 --- a/src/util/gnunet-config-diff.c +++ b/src/util/gnunet-config-diff.c @@ -14,8 +14,7 @@ main (int argc, char **argv) } i1 = GNUNET_CONFIGURATION_create (); i2 = GNUNET_CONFIGURATION_create (); - if ((GNUNET_OK != - GNUNET_CONFIGURATION_load (i1, argv[1])) || + if ((GNUNET_OK != GNUNET_CONFIGURATION_load (i1, argv[1])) || (GNUNET_OK != GNUNET_CONFIGURATION_load (i2, argv[2]))) return 1; if (GNUNET_OK != GNUNET_CONFIGURATION_write_diffs (i1, i2, argv[2])) diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c index 125d6665f..131693dd1 100644 --- a/src/util/gnunet-resolver.c +++ b/src/util/gnunet-resolver.c @@ -50,9 +50,8 @@ printer (void *cls, const struct sockaddr *addr, socklen_t addrlen) * @param cfg configuration */ static void -run (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { if (args[0] == NULL) return; @@ -73,11 +72,8 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_END }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "gnunet-resolver [hostname]", - gettext_noop - ("Test GNUnet DNS resolver code."), + GNUNET_PROGRAM_run (argc, argv, "gnunet-resolver [hostname]", + gettext_noop ("Test GNUnet DNS resolver code."), options, &run, NULL)) ? 0 : 1; } diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index f49ec3882..5d4c5c224 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c @@ -87,8 +87,9 @@ getnameinfo_resolve (struct IPCache *cache) { char hostname[256]; - if (0 == getnameinfo (cache->sa, - cache->salen, hostname, sizeof (hostname), NULL, 0, 0)) + if (0 == + getnameinfo (cache->sa, cache->salen, hostname, sizeof (hostname), NULL, + 0, 0)) cache->addr = GNUNET_strdup (hostname); } #endif @@ -108,12 +109,14 @@ gethostbyaddr_resolve (struct IPCache *cache) switch (cache->sa->sa_family) { case AF_INET: - ent = gethostbyaddr (&((struct sockaddr_in *) cache->sa)->sin_addr, - sizeof (struct in_addr), AF_INET); + ent = + gethostbyaddr (&((struct sockaddr_in *) cache->sa)->sin_addr, + sizeof (struct in_addr), AF_INET); break; case AF_INET6: - ent = gethostbyaddr (&((struct sockaddr_in6 *) cache->sa)->sin6_addr, - sizeof (struct in6_addr), AF_INET6); + ent = + gethostbyaddr (&((struct sockaddr_in6 *) cache->sa)->sin6_addr, + sizeof (struct in6_addr), AF_INET6); break; default: ent = NULL; @@ -225,8 +228,7 @@ get_ip_as_string (struct GNUNET_SERVER_Client *client, } tc = GNUNET_SERVER_transmit_context_create (client); if (cache->addr != NULL) - GNUNET_SERVER_transmit_context_append_data (tc, - cache->addr, + GNUNET_SERVER_transmit_context_append_data (tc, cache->addr, strlen (cache->addr) + 1, GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, @@ -256,11 +258,10 @@ getaddrinfo_resolve (struct GNUNET_SERVER_TransmitContext *tc, if (0 != (s = getaddrinfo (hostname, NULL, &hints, &result))) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Could not resolve `%s' (%s): %s\n"), hostname, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Could not resolve `%s' (%s): %s\n"), + hostname, (domain == - AF_INET) ? "IPv4" : ((domain == - AF_INET6) ? "IPv6" : "any"), + AF_INET) ? "IPv4" : ((domain == AF_INET6) ? "IPv6" : "any"), gai_strerror (s)); if ((s == EAI_BADFLAGS) || (s == EAI_MEMORY) #ifndef MINGW @@ -278,8 +279,7 @@ getaddrinfo_resolve (struct GNUNET_SERVER_TransmitContext *tc, pos = result; while (pos != NULL) { - GNUNET_SERVER_transmit_context_append_data (tc, - pos->ai_addr, + GNUNET_SERVER_transmit_context_append_data (tc, pos->ai_addr, pos->ai_addrlen, GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); pos = pos->ai_next; @@ -314,8 +314,8 @@ gethostbyname2_resolve (struct GNUNET_SERVER_TransmitContext *tc, if (hp == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Could not find IP of host `%s': %s\n"), - hostname, hstrerror (h_errno)); + _("Could not find IP of host `%s': %s\n"), hostname, + hstrerror (h_errno)); return GNUNET_SYSERR; } GNUNET_assert (hp->h_addrtype == domain); @@ -328,9 +328,7 @@ gethostbyname2_resolve (struct GNUNET_SERVER_TransmitContext *tc, a4.sin_len = (u_char) sizeof (struct sockaddr_in); #endif memcpy (&a4.sin_addr, hp->h_addr_list[0], hp->h_length); - GNUNET_SERVER_transmit_context_append_data (tc, - &a4, - sizeof (a4), + GNUNET_SERVER_transmit_context_append_data (tc, &a4, sizeof (a4), GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); } else @@ -342,9 +340,7 @@ gethostbyname2_resolve (struct GNUNET_SERVER_TransmitContext *tc, a6.sin6_len = (u_char) sizeof (struct sockaddr_in6); #endif memcpy (&a6.sin6_addr, hp->h_addr_list[0], hp->h_length); - GNUNET_SERVER_transmit_context_append_data (tc, - &a6, - sizeof (a6), + GNUNET_SERVER_transmit_context_append_data (tc, &a6, sizeof (a6), GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); } return GNUNET_OK; @@ -363,8 +359,8 @@ gethostbyname_resolve (struct GNUNET_SERVER_TransmitContext *tc, if (hp == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Could not find IP of host `%s': %s\n"), - hostname, hstrerror (h_errno)); + _("Could not find IP of host `%s': %s\n"), hostname, + hstrerror (h_errno)); return GNUNET_SYSERR; } if (hp->h_addrtype != AF_INET) @@ -379,9 +375,7 @@ gethostbyname_resolve (struct GNUNET_SERVER_TransmitContext *tc, addr.sin_len = (u_char) sizeof (struct sockaddr_in); #endif memcpy (&addr.sin_addr, hp->h_addr_list[0], hp->h_length); - GNUNET_SERVER_transmit_context_append_data (tc, - &addr, - sizeof (addr), + GNUNET_SERVER_transmit_context_append_data (tc, &addr, sizeof (addr), GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE); return GNUNET_OK; } @@ -396,8 +390,8 @@ gethostbyname_resolve (struct GNUNET_SERVER_TransmitContext *tc, * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" */ static void -get_ip_from_hostname (struct GNUNET_SERVER_Client *client, - const char *hostname, int domain) +get_ip_from_hostname (struct GNUNET_SERVER_Client *client, const char *hostname, + int domain) { int ret; struct GNUNET_SERVER_TransmitContext *tc; @@ -430,8 +424,7 @@ get_ip_from_hostname (struct GNUNET_SERVER_Client *client, * @param message the actual message */ static void -handle_get (void *cls, - struct GNUNET_SERVER_Client *client, +handle_get (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { uint16_t msize; @@ -464,8 +457,8 @@ handle_get (void *cls, return; } #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Resolver asked to look up `%s'.\n"), hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolver asked to look up `%s'.\n"), + hostname); #endif get_ip_from_hostname (client, hostname, domain); } @@ -527,8 +520,7 @@ handle_get (void *cls, * @param cfg configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -552,11 +544,10 @@ main (int argc, char *const *argv) int ret; struct IPCache *pos; - ret = (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "resolver", GNUNET_SERVICE_OPTION_NONE, - &run, NULL)) ? 0 : 1; + ret = + (GNUNET_OK == + GNUNET_SERVICE_run (argc, argv, "resolver", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; while (head != NULL) { diff --git a/src/util/network.c b/src/util/network.c index b533ce183..e071b8b54 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -212,8 +212,7 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc, int gsn = getsockname (desc->fd, &name, &namelen); if (gsn == 0) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Accepting connection on `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Accepting connection on `%s'\n", GNUNET_a2s (&name, namelen)); } #endif @@ -357,8 +356,8 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; if (0 != unlink (un->sun_path)) - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "unlink", un->sun_path); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", + un->sun_path); } #endif #endif @@ -480,8 +479,8 @@ GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, * @param desc socket */ ssize_t -GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle - * desc) +GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle * + desc) { int error; @@ -645,9 +644,8 @@ GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle * desc, * @return GNUNET_OK on success, GNUNET_SYSERR otherwise */ int -GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, - int level, int option_name, - const void *option_value, +GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, int level, + int option_name, const void *option_value, socklen_t option_len) { int ret; @@ -945,8 +943,8 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, { #ifdef MINGW GNUNET_CONTAINER_slist_add (fds->handles, - GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, - h, sizeof (struct GNUNET_DISK_FileHandle)); + GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, h, + sizeof (struct GNUNET_DISK_FileHandle)); #else int fd; @@ -1569,10 +1567,9 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, "send to the socket %d returned %d (%u)\n", i, status, error); #endif - if (status == 0 - || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) - || (status == -1 && gso_result == 0 && error == WSAENOTCONN && - so_error == WSAECONNREFUSED)) + if (status == 0 || (error != WSAEWOULDBLOCK && error != WSAENOTCONN) || + (status == -1 && gso_result == 0 && error == WSAENOTCONN && + so_error == WSAECONNREFUSED)) { FD_SET (wfds->sds.fd_array[i], &awrite); retcode += 1; diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 188401abb..00825f2b7 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -57,9 +57,9 @@ get_path_from_proc_maps () return NULL; while (NULL != fgets (line, sizeof (line), f)) { - if ((1 == sscanf (line, - "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", - dir)) && (NULL != (lgu = strstr (dir, "libgnunetutil")))) + if ((1 == + sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) && + (NULL != (lgu = strstr (dir, "libgnunetutil")))) { lgu[0] = '\0'; fclose (f); @@ -476,8 +476,8 @@ GNUNET_OS_check_helper_binary (const char *binary) } if (0 != STAT (p, &statbuf)) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("stat (%s) failed: %s\n"), p, STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("stat (%s) failed: %s\n"), p, + STRERROR (errno)); GNUNET_free (p); return GNUNET_SYSERR; } diff --git a/src/util/os_network.c b/src/util/os_network.c index af8046814..21376f94c 100644 --- a/src/util/os_network.c +++ b/src/util/os_network.c @@ -131,15 +131,12 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, /* Set entry */ memset (bPhysAddr, 0, MAXLEN_PHYSADDR); - memcpy (bPhysAddr, - pTable->table[dwIfIdx].bPhysAddr, + memcpy (bPhysAddr, pTable->table[dwIfIdx].bPhysAddr, pTable->table[dwIfIdx].dwPhysAddrLen); snprintf (szEntry, 1000, "%s (%s - %I64u)", - pszIfName ? pszIfName : (char *) - pTable->table[dwIfIdx].bDescr, inet_ntop (AF_INET, - &dwIP, dst, - INET_ADDRSTRLEN), + pszIfName ? pszIfName : (char *) pTable->table[dwIfIdx]. + bDescr, inet_ntop (AF_INET, &dwIP, dst, INET_ADDRSTRLEN), *((unsigned long long *) bPhysAddr)); szEntry[1000] = 0; @@ -153,8 +150,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, sa.sin_addr.S_un.S_addr = dwIP; if (GNUNET_OK != - proc (proc_cls, - szEntry, + proc (proc_cls, szEntry, pTable->table[dwIfIdx].dwIndex == dwExternalNIC, (const struct sockaddr *) &sa, sizeof (sa))) break; @@ -176,8 +172,8 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, { for (ifa_ptr = ifa_first; ifa_ptr != NULL; ifa_ptr = ifa_ptr->ifa_next) { - if (ifa_ptr->ifa_name != NULL && - ifa_ptr->ifa_addr != NULL && (ifa_ptr->ifa_flags & IFF_UP) != 0) + if (ifa_ptr->ifa_name != NULL && ifa_ptr->ifa_addr != NULL && + (ifa_ptr->ifa_flags & IFF_UP) != 0) { if ((ifa_ptr->ifa_addr->sa_family != AF_INET) && (ifa_ptr->ifa_addr->sa_family != AF_INET6)) @@ -186,11 +182,10 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, alen = sizeof (struct sockaddr_in); else alen = sizeof (struct sockaddr_in6); - if (GNUNET_OK != proc (proc_cls, - ifa_ptr->ifa_name, - 0 == strcmp (ifa_ptr->ifa_name, - GNUNET_DEFAULT_INTERFACE), - ifa_ptr->ifa_addr, alen)) + if (GNUNET_OK != + proc (proc_cls, ifa_ptr->ifa_name, + 0 == strcmp (ifa_ptr->ifa_name, GNUNET_DEFAULT_INTERFACE), + ifa_ptr->ifa_addr, alen)) break; } } @@ -261,9 +256,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, #endif a4.sin_addr = v4; if (GNUNET_OK != - proc (proc_cls, - ifc, - 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), + proc (proc_cls, ifc, 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), (const struct sockaddr *) &a4, sizeof (a4))) break; continue; @@ -278,9 +271,7 @@ GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, #endif a6.sin6_addr = v6; if (GNUNET_OK != - proc (proc_cls, - ifc, - 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), + proc (proc_cls, ifc, 0 == strcmp (ifc, GNUNET_DEFAULT_INTERFACE), (const struct sockaddr *) &a6, sizeof (a6))) break; continue; diff --git a/src/util/os_priority.c b/src/util/os_priority.c index bccde8d46..d27642a58 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -60,19 +60,20 @@ parent_control_handler (void *cls, int sig; #if DEBUG_OS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "`%s' invoked because of %d\n", __FUNCTION__, tc->reason); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", + __FUNCTION__, tc->reason); #endif - if (tc->reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN | - GNUNET_SCHEDULER_REASON_TIMEOUT | - GNUNET_SCHEDULER_REASON_PREREQ_DONE)) + if (tc-> + reason & (GNUNET_SCHEDULER_REASON_SHUTDOWN | + GNUNET_SCHEDULER_REASON_TIMEOUT | + GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { GNUNET_DISK_npipe_close (control_pipe); } else { - if (GNUNET_DISK_file_read (control_pipe, - &sig, sizeof (sig)) != sizeof (sig)) + if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) != + sizeof (sig)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read"); GNUNET_DISK_npipe_close (control_pipe); @@ -80,12 +81,12 @@ parent_control_handler (void *cls, else { #if DEBUG_OS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got control code %d from parent\n", sig); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", + sig); #endif GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - control_pipe, - &parent_control_handler, control_pipe); + control_pipe, &parent_control_handler, + control_pipe); raise (sig); } } @@ -111,10 +112,10 @@ GNUNET_OS_install_parent_control_handler (void *cls, GNUNET_OS_CONTROL_PIPE, env_buf); return; } - control_pipe = GNUNET_DISK_npipe_open (env_buf, - GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + control_pipe = + GNUNET_DISK_npipe_open (env_buf, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (control_pipe == NULL) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "open", env_buf); @@ -125,8 +126,7 @@ GNUNET_OS_install_parent_control_handler (void *cls, "Adding parent control handler pipe `%s' to the scheduler\n", env_buf); #endif - GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - control_pipe, + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe, &parent_control_handler, control_pipe); } @@ -219,13 +219,14 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) */ while (1) { - ret = GNUNET_NETWORK_socket_select (rfds, NULL, efds, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_relative_get_unit (), - 5000)); - - if (ret < 1 || GNUNET_NETWORK_fdset_handle_isset (efds, - proc->control_pipe)) + ret = + GNUNET_NETWORK_socket_select (rfds, NULL, efds, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_relative_get_unit (), + 5000)); + + if (ret < 1 || + GNUNET_NETWORK_fdset_handle_isset (efds, proc->control_pipe)) { /* Just to be sure */ PLIBC_KILL (proc->pid, sig); @@ -234,8 +235,8 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) } else { - if (GNUNET_DISK_file_read (proc->control_pipe, &ret, - sizeof (ret)) != GNUNET_OK) + if (GNUNET_DISK_file_read (proc->control_pipe, &ret, sizeof (ret)) != + GNUNET_OK) res = PLIBC_KILL (proc->pid, sig); /* Child signaled shutdown is in progress */ @@ -394,8 +395,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, errno = 0; if ((delta != 0) && (rprio == nice (delta)) && (errno != 0)) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, "nice"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, + "nice"); return GNUNET_SYSERR; } } @@ -403,8 +404,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc, { if (0 != setpriority (PRIO_PROCESS, pid, rprio)) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | - GNUNET_ERROR_TYPE_BULK, "setpriority"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, + "setpriority"); return GNUNET_SYSERR; } } @@ -552,10 +553,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, int fd_stdin_write; #if ENABLE_WINDOWS_WORKAROUNDS - control_pipe = GNUNET_DISK_npipe_create (&childpipename, - GNUNET_DISK_OPEN_WRITE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + control_pipe = + GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (control_pipe == NULL) return NULL; #endif @@ -776,10 +777,10 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin, start.hStdOutput = stdout_handle; } - control_pipe = GNUNET_DISK_npipe_create (&childpipename, - GNUNET_DISK_OPEN_WRITE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + control_pipe = + GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (control_pipe == NULL) { GNUNET_free (cmd); @@ -865,8 +866,8 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, * @return process ID of the new process, -1 on error */ struct GNUNET_OS_Process * -GNUNET_OS_start_process_v (const int *lsocks, - const char *filename, char *const argv[]) +GNUNET_OS_start_process_v (const int *lsocks, const char *filename, + char *const argv[]) { #if ENABLE_WINDOWS_WORKAROUNDS struct GNUNET_DISK_FileHandle *control_pipe = NULL; @@ -887,10 +888,10 @@ GNUNET_OS_start_process_v (const int *lsocks, unsigned int ls; #if ENABLE_WINDOWS_WORKAROUNDS - control_pipe = GNUNET_DISK_npipe_create (&childpipename, - GNUNET_DISK_OPEN_WRITE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + control_pipe = + GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (control_pipe == NULL) return NULL; #endif @@ -1121,10 +1122,10 @@ GNUNET_OS_start_process_v (const int *lsocks, memset (&start, 0, sizeof (start)); start.cb = sizeof (start); - control_pipe = GNUNET_DISK_npipe_create (&childpipename, - GNUNET_DISK_OPEN_WRITE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + control_pipe = + GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (control_pipe == NULL) { GNUNET_free (cmd); @@ -1414,9 +1415,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) proc (cmd->proc_cls, NULL); return; } - ret = GNUNET_DISK_file_read (cmd->r, - &cmd->buf[cmd->off], - sizeof (cmd->buf) - cmd->off); + ret = + GNUNET_DISK_file_read (cmd->r, &cmd->buf[cmd->off], + sizeof (cmd->buf) - cmd->off); if (ret <= 0) { if ((cmd->off > 0) && (cmd->off < sizeof (cmd->buf))) @@ -1457,10 +1458,9 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return NULL on error */ struct GNUNET_OS_CommandHandle * -GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, - void *proc_cls, - struct GNUNET_TIME_Relative timeout, - const char *binary, ...) +GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls, + struct GNUNET_TIME_Relative timeout, const char *binary, + ...) { struct GNUNET_OS_CommandHandle *cmd; struct GNUNET_OS_Process *eip; diff --git a/src/util/peer.c b/src/util/peer.c index 91a706040..62fa0e2f2 100644 --- a/src/util/peer.c +++ b/src/util/peer.c @@ -148,8 +148,7 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid) table[ret].rc = 1; table[ret].pid = ret; GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multihashmap_put (map, - &pid->hashPubKey, + GNUNET_CONTAINER_multihashmap_put (map, &pid->hashPubKey, (void *) (long) ret, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); return ret; @@ -182,8 +181,8 @@ GNUNET_PEER_decrement_rcs (const GNUNET_PEER_Id *ids, unsigned int count) { GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (map, - &table[id]. - id.hashPubKey, + &table[id].id. + hashPubKey, (void *) (long) id)); table[id].pid = free_list_start; free_list_start = id; @@ -211,8 +210,8 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta) { GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (map, - &table[id]. - id.hashPubKey, + &table[id].id. + hashPubKey, (void *) (long) id)); table[id].pid = free_list_start; free_list_start = id; diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c index d883776b4..689781835 100644 --- a/src/util/perf_crypto_hash.c +++ b/src/util/perf_crypto_hash.c @@ -58,12 +58,12 @@ main (int argc, char *argv[]) start = GNUNET_TIME_absolute_get (); perfHash (); printf ("Hash perf took %llu ms\n", - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value); GAUGER ("UTIL", "Cryptographic hashing", 1024 * 64 * 1024 / (1 + - GNUNET_TIME_absolute_get_duration - (start).rel_value), "kb/s"); + GNUNET_TIME_absolute_get_duration (start). + rel_value), "kb/s"); return 0; } diff --git a/src/util/plugin.c b/src/util/plugin.c index b1c979dff..08b32b295 100644 --- a/src/util/plugin.c +++ b/src/util/plugin.c @@ -84,8 +84,7 @@ plugin_init () err = lt_dlinit (); if (err > 0) { - fprintf (stderr, - _("Initialization of plugin mechanism failed: %s!\n"), + fprintf (stderr, _("Initialization of plugin mechanism failed: %s!\n"), lt_dlerror ()); return; } diff --git a/src/util/program.c b/src/util/program.c index cccb7db73..f1e95477d 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -124,9 +124,7 @@ cmd_sorter (__const void *a1, __const void *a2) * @return GNUNET_SYSERR on error, GNUNET_OK on success */ int -GNUNET_PROGRAM_run (int argc, - char *const *argv, - const char *binaryName, +GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls) @@ -217,13 +215,10 @@ GNUNET_PROGRAM_run (int argc, lpfx = GNUNET_strdup (binaryName); if (NULL != (spc = strstr (lpfx, " "))) *spc = '\0'; - if ((-1 == (ret = GNUNET_GETOPT_run (binaryName, - allopts, - (unsigned int) argc, argv))) || - ((GNUNET_OK != - GNUNET_log_setup (lpfx, - loglev, - logfile)) || + if ((-1 == + (ret = + GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv))) || + ((GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile)) || (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cc.cfgfile)))) { GNUNET_CONFIGURATION_destroy (cfg); diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index 254decb76..85a485098 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c @@ -99,8 +99,7 @@ internal_notify (const GNUNET_HashCode * id, */ int GNUNET_PSEUDONYM_discovery_callback_register (const struct - GNUNET_CONFIGURATION_Handle - *cfg, + GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PSEUDONYM_Iterator iterator, void *closure) { @@ -155,16 +154,14 @@ GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator * @return filename of the pseudonym (if psid != NULL) or directory with the data (if psid == NULL) */ static char * -get_data_filename (const struct GNUNET_CONFIGURATION_Handle - *cfg, const char *prefix, const GNUNET_HashCode * psid) +get_data_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *prefix, const GNUNET_HashCode * psid) { struct GNUNET_CRYPTO_HashAsciiEncoded enc; if (psid != NULL) GNUNET_CRYPTO_hash_to_enc (psid, &enc); - return GNUNET_DISK_get_home_filename (cfg, - GNUNET_CLIENT_SERVICE_NAME, - prefix, + return GNUNET_DISK_get_home_filename (cfg, GNUNET_CLIENT_SERVICE_NAME, prefix, (psid == NULL) ? NULL : (const char *) &enc, NULL); @@ -228,8 +225,8 @@ write_pseudonym_info (const struct GNUNET_CONFIGURATION_Handle *cfg, static int read_info (const struct GNUNET_CONFIGURATION_Handle *cfg, const GNUNET_HashCode * nsid, - struct GNUNET_CONTAINER_MetaData **meta, - int32_t * ranking, char **ns_name) + struct GNUNET_CONTAINER_MetaData **meta, int32_t * ranking, + char **ns_name) { char *fn; char *emsg; @@ -309,16 +306,17 @@ GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, if (GNUNET_OK == read_info (cfg, nsid, &meta, rank, &name)) { if ((meta != NULL) && (name == NULL)) - name = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METATYPE_FILENAME, - EXTRACTOR_METATYPE_DESCRIPTION, - EXTRACTOR_METATYPE_SUBJECT, - EXTRACTOR_METATYPE_PUBLISHER, - EXTRACTOR_METATYPE_AUTHOR_NAME, - EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METATYPE_SUMMARY, - -1); + name = + GNUNET_CONTAINER_meta_data_get_first_by_types (meta, + EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METATYPE_FILENAME, + EXTRACTOR_METATYPE_DESCRIPTION, + EXTRACTOR_METATYPE_SUBJECT, + EXTRACTOR_METATYPE_PUBLISHER, + EXTRACTOR_METATYPE_AUTHOR_NAME, + EXTRACTOR_METATYPE_COMMENT, + EXTRACTOR_METATYPE_SUMMARY, + -1); if (meta != NULL) { GNUNET_CONTAINER_meta_data_destroy (meta); @@ -334,15 +332,16 @@ GNUNET_PSEUDONYM_id_to_name (const struct GNUNET_CONFIGURATION_Handle *cfg, len = 0; if (0 == STAT (fn, &sbuf)) GNUNET_DISK_file_size (fn, &len, GNUNET_YES); - fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_CREATE - | GNUNET_DISK_OPEN_READWRITE, + fh = GNUNET_DISK_file_open (fn, + GNUNET_DISK_OPEN_CREATE | + GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); i = 0; idx = -1; while ((len >= sizeof (GNUNET_HashCode)) && - (sizeof (GNUNET_HashCode) - == GNUNET_DISK_file_read (fh, &nh, sizeof (GNUNET_HashCode)))) + (sizeof (GNUNET_HashCode) == + GNUNET_DISK_file_read (fh, &nh, sizeof (GNUNET_HashCode)))) { if (0 == memcmp (&nh, nsid, sizeof (GNUNET_HashCode))) { @@ -407,8 +406,9 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (fn); return GNUNET_SYSERR; } - fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_CREATE - | GNUNET_DISK_OPEN_READWRITE, + fh = GNUNET_DISK_file_open (fn, + GNUNET_DISK_OPEN_CREATE | + GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); GNUNET_free (fn); diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index ef48faf59..3aa8bff9c 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c @@ -191,17 +191,16 @@ check_config (const struct GNUNET_CONFIGURATION_Handle *cfg) v6.sin6_len = sizeof (v6); #endif if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "resolver", "HOSTNAME", &hostname)) + GNUNET_CONFIGURATION_get_value_string (cfg, "resolver", "HOSTNAME", + &hostname)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Must specify `%s' for `%s' in configuration!\n"), - "HOSTNAME", "resolver"); + _("Must specify `%s' for `%s' in configuration!\n"), "HOSTNAME", + "resolver"); GNUNET_assert (0); } - if ((1 != inet_pton (AF_INET, - hostname, - &v4)) || (1 != inet_pton (AF_INET6, hostname, &v6))) + if ((1 != inet_pton (AF_INET, hostname, &v4)) || + (1 != inet_pton (AF_INET6, hostname, &v6))) { GNUNET_free (hostname); return; @@ -288,9 +287,8 @@ no_resolve (const struct sockaddr *sa, socklen_t salen) if (salen != sizeof (struct sockaddr_in)) return NULL; if (NULL == - inet_ntop (AF_INET, - &((struct sockaddr_in *) sa)->sin_addr, - inet4, INET_ADDRSTRLEN)) + inet_ntop (AF_INET, &((struct sockaddr_in *) sa)->sin_addr, inet4, + INET_ADDRSTRLEN)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); return NULL; @@ -301,9 +299,8 @@ no_resolve (const struct sockaddr *sa, socklen_t salen) if (salen != sizeof (struct sockaddr_in6)) return NULL; if (NULL == - inet_ntop (AF_INET6, - &((struct sockaddr_in6 *) sa)->sin6_addr, - inet6, INET6_ADDRSTRLEN)) + inet_ntop (AF_INET6, &((struct sockaddr_in6 *) sa)->sin6_addr, inet6, + INET6_ADDRSTRLEN)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); return NULL; @@ -427,15 +424,13 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) } #if DEBUG_RESOLVER GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Resolver returns `%s' for IP `%s'.\n"), - hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len)); + _("Resolver returns `%s' for IP `%s'.\n"), hostname, + GNUNET_a2s ((const void *) &rh[1], rh->data_len)); #endif if (rh->was_transmitted != GNUNET_SYSERR) rh->name_callback (rh->cls, hostname); rh->received_response = GNUNET_YES; - GNUNET_CLIENT_receive (client, - &handle_response, - rh, + GNUNET_CLIENT_receive (client, &handle_response, rh, GNUNET_TIME_absolute_get_remaining (rh->timeout)); } /* return lookup results to caller */ @@ -459,16 +454,13 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) { char *ips = no_resolve (sa, salen); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Resolver returns `%s' for `%s'.\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for `%s'.\n", ips, (const char *) &rh[1]); GNUNET_free (ips); } #endif rh->addr_callback (rh->cls, sa, salen); - GNUNET_CLIENT_receive (client, - &handle_response, - rh, + GNUNET_CLIENT_receive (client, &handle_response, rh, GNUNET_TIME_absolute_get_remaining (rh->timeout)); } } @@ -610,8 +602,9 @@ process_requests () { /* nothing to do, release socket really soon if there is nothing * else happening... */ - s_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, - &shutdown_task, NULL); + s_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, + &shutdown_task, NULL); return; } if (GNUNET_YES == rh->was_transmitted) @@ -628,8 +621,7 @@ process_requests () "Transmitting DNS resolution request to DNS service\n"); #endif if (GNUNET_OK != - GNUNET_CLIENT_transmit_and_get_response (client, - &msg->header, + GNUNET_CLIENT_transmit_and_get_response (client, &msg->header, GNUNET_TIME_absolute_get_remaining (rh->timeout), GNUNET_YES, &handle_response, rh)) @@ -726,8 +718,7 @@ reconnect () * @return handle that can be used to cancel the request, NULL on error */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_ip_get (const char *hostname, - int domain, +GNUNET_RESOLVER_ip_get (const char *hostname, int domain, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_AddressCallback callback, void *callback_cls) @@ -754,13 +745,9 @@ GNUNET_RESOLVER_ip_get (const char *hostname, rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); rh->direction = GNUNET_NO; /* first, check if this is a numeric address */ - if (((1 == inet_pton (AF_INET, - hostname, - &v4)) && + if (((1 == inet_pton (AF_INET, hostname, &v4)) && ((domain == AF_INET) || (domain == AF_UNSPEC))) || - ((1 == inet_pton (AF_INET6, - hostname, - &v6)) && + ((1 == inet_pton (AF_INET6, hostname, &v6)) && ((domain == AF_INET6) || (domain == AF_UNSPEC)))) { rh->task = GNUNET_SCHEDULER_add_now (&numeric_resolution, rh); @@ -826,8 +813,7 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return handle that can be used to cancel the request */ struct GNUNET_RESOLVER_RequestHandle * -GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, - socklen_t salen, +GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen, int do_resolve, struct GNUNET_TIME_Relative timeout, GNUNET_RESOLVER_HostnameCallback callback, @@ -881,19 +867,19 @@ GNUNET_RESOLVER_local_fqdn_get () if (0 != gethostname (hostname, sizeof (hostname) - 1)) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "gethostname"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "gethostname"); return NULL; } #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Resolving our FQDN `%s'\n"), hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), + hostname); #endif host = gethostbyname (hostname); if (NULL == host) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Could not resolve our FQDN : %s\n"), hstrerror (h_errno)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not resolve our FQDN : %s\n"), + hstrerror (h_errno)); return NULL; } return GNUNET_strdup (host->h_name); @@ -919,13 +905,13 @@ GNUNET_RESOLVER_hostname_resolve (int domain, if (0 != gethostname (hostname, sizeof (hostname) - 1)) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "gethostname"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "gethostname"); return NULL; } #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Resolving our hostname `%s'\n"), hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our hostname `%s'\n"), + hostname); #endif return GNUNET_RESOLVER_ip_get (hostname, domain, timeout, callback, cls); } diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 9412457f6..844531b37 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -349,8 +349,7 @@ is_pending (GNUNET_SCHEDULER_TaskIdentifier id) * @param timeout next timeout (updated) */ static void -update_sets (struct GNUNET_NETWORK_FDSet *rs, - struct GNUNET_NETWORK_FDSet *ws, +update_sets (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws, struct GNUNET_TIME_Relative *timeout) { struct Task *pos; @@ -434,8 +433,7 @@ set_overlaps (const struct GNUNET_NETWORK_FDSet *ready, * @return GNUNET_YES if we can run it, GNUNET_NO if not. */ static int -is_ready (struct Task *task, - struct GNUNET_TIME_Absolute now, +is_ready (struct Task *task, struct GNUNET_TIME_Absolute now, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws) { @@ -525,8 +523,8 @@ check_ready (const struct GNUNET_NETWORK_FDSet *rs, { #if DEBUG_TASKS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Checking readiness of task: %llu / %p\n", - pos->id, pos->callback_cls); + "Checking readiness of task: %llu / %p\n", pos->id, + pos->callback_cls); #endif next = pos->next; if (GNUNET_YES == is_ready (pos, now, rs, ws)) @@ -657,11 +655,10 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) DELAY_THRESHOLD.rel_value) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Task %llu took %llums to be scheduled\n", - pos->id, - (unsigned long long) - GNUNET_TIME_absolute_get_duration - (pos->start_time).rel_value); + "Task %llu took %llums to be scheduled\n", pos->id, + (unsigned long long) GNUNET_TIME_absolute_get_duration (pos-> + start_time). + rel_value); } #endif tc.reason = pos->reason; @@ -678,17 +675,16 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) abort (); // added to ready in previous select loop! #if DEBUG_TASKS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Running task: %llu / %p\n", pos->id, pos->callback_cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running task: %llu / %p\n", pos->id, + pos->callback_cls); #endif pos->callback (pos->callback_cls, &tc); #if EXECINFO int i; for (i = 0; i < pos->num_backtrace_strings; i++) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Task %llu trace %d: %s\n", - pos->id, i, pos->backtrace_strings[i]); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Task %llu trace %d: %s\n", pos->id, + i, pos->backtrace_strings[i]); #endif active_task = NULL; destroy_task (pos); @@ -809,8 +805,8 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) #endif current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; current_lifeness = GNUNET_YES; - GNUNET_SCHEDULER_add_continuation (task, - task_cls, GNUNET_SCHEDULER_REASON_STARTUP); + GNUNET_SCHEDULER_add_continuation (task, task_cls, + GNUNET_SCHEDULER_REASON_STARTUP); #if ENABLE_WINDOWS_WORKAROUNDS active_task = (void *) (long) -1; /* force passing of sanity check */ GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO, @@ -1031,8 +1027,8 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) } ret = t->callback_cls; #if DEBUG_TASKS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Canceling task: %llu / %p\n", task, t->callback_cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Canceling task: %llu / %p\n", task, + t->callback_cls); #endif destroy_task (t); return ret; @@ -1049,8 +1045,7 @@ GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_TaskIdentifier task) * @param reason reason for task invocation */ void -GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, - void *task_cls, +GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, void *task_cls, enum GNUNET_SCHEDULER_Reason reason) { struct Task *t; @@ -1080,8 +1075,8 @@ GNUNET_SCHEDULER_add_continuation (GNUNET_SCHEDULER_Task task, t->priority = current_priority; t->lifeness = current_lifeness; #if DEBUG_TASKS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding continuation task: %llu / %p\n", t->id, t->callback_cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding continuation task: %llu / %p\n", + t->id, t->callback_cls); #endif queue_ready_task (t); } @@ -1109,8 +1104,7 @@ GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, GNUNET_SCHEDULER_Task task, void *task_cls) { return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, - prerequisite_task, - GNUNET_TIME_UNIT_ZERO, + prerequisite_task, GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, task_cls); } @@ -1128,10 +1122,9 @@ GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_Task task, void *task_cls) { - return GNUNET_SCHEDULER_add_select (prio, - GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_UNIT_ZERO, - NULL, NULL, task, task_cls); + return GNUNET_SCHEDULER_add_select (prio, GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, + task_cls); } @@ -1212,23 +1205,23 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, pending_timeout_last = t; #if DEBUG_TASKS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding task: %llu / %p\n", t->id, t->callback_cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, + t->callback_cls); #endif #if EXECINFO int i; for (i = 0; i < t->num_backtrace_strings; i++) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, + t->backtrace_strings[i]); #endif return t->id; #else /* unoptimized version */ return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_TASK, delay, - NULL, NULL, task, task_cls); + GNUNET_SCHEDULER_NO_TASK, delay, NULL, + NULL, task, task_cls); #endif } @@ -1248,8 +1241,8 @@ GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_Task task, void *task_cls) { return GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_UNIT_ZERO, - NULL, NULL, task, task_cls); + GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, + task_cls); } @@ -1274,10 +1267,11 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, { GNUNET_SCHEDULER_TaskIdentifier ret; - ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_TASK, - GNUNET_TIME_UNIT_ZERO, - NULL, NULL, task, task_cls); + ret = + GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_KEEP, + GNUNET_SCHEDULER_NO_TASK, + GNUNET_TIME_UNIT_ZERO, NULL, NULL, task, + task_cls); GNUNET_assert (pending->id == ret); pending->lifeness = lifeness; return ret; @@ -1314,8 +1308,8 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, */ #ifndef MINGW GNUNET_SCHEDULER_TaskIdentifier -add_without_sets (struct GNUNET_TIME_Relative delay, - int rfd, int wfd, GNUNET_SCHEDULER_Task task, void *task_cls) +add_without_sets (struct GNUNET_TIME_Relative delay, int rfd, int wfd, + GNUNET_SCHEDULER_Task task, void *task_cls) { struct Task *t; @@ -1346,8 +1340,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, int i; for (i = 0; i < t->num_backtrace_strings; i++) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Trace: %s\n", t->backtrace_strings[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trace: %s\n", + t->backtrace_strings[i]); #endif GNUNET_assert (0); } @@ -1364,8 +1358,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, int i; for (i = 0; i < t->num_backtrace_strings; i++) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Trace: %s\n", t->backtrace_strings[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trace: %s\n", + t->backtrace_strings[i]); #endif GNUNET_assert (0); } @@ -1386,15 +1380,15 @@ add_without_sets (struct GNUNET_TIME_Relative delay, pending = t; max_priority_added = GNUNET_MAX (max_priority_added, t->priority); #if DEBUG_TASKS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding task: %llu / %p\n", t->id, t->callback_cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, + t->callback_cls); #endif #if EXECINFO int i; for (i = 0; i < t->num_backtrace_strings; i++) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, + t->backtrace_strings[i]); #endif return t->id; } @@ -1430,14 +1424,15 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, GNUNET_assert (rfd != NULL); rs = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_set (rs, rfd); - ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), - GNUNET_SCHEDULER_NO_TASK, delay, - rs, NULL, task, task_cls); + ret = + GNUNET_SCHEDULER_add_select (check_priority (current_priority), + GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, + task, task_cls); GNUNET_NETWORK_fdset_destroy (rs); return ret; #else - return add_without_sets (delay, - GNUNET_NETWORK_get_fd (rfd), -1, task, task_cls); + return add_without_sets (delay, GNUNET_NETWORK_get_fd (rfd), -1, task, + task_cls); #endif } @@ -1470,15 +1465,16 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, GNUNET_assert (wfd != NULL); ws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_set (ws, wfd); - ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), - GNUNET_SCHEDULER_NO_TASK, delay, - NULL, ws, task, task_cls); + ret = + GNUNET_SCHEDULER_add_select (check_priority (current_priority), + GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, + task, task_cls); GNUNET_NETWORK_fdset_destroy (ws); return ret; #else GNUNET_assert (GNUNET_NETWORK_get_fd (wfd) >= 0); - return add_without_sets (delay, - -1, GNUNET_NETWORK_get_fd (wfd), task, task_cls); + return add_without_sets (delay, -1, GNUNET_NETWORK_get_fd (wfd), task, + task_cls); #endif } @@ -1511,9 +1507,10 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, GNUNET_assert (rfd != NULL); rs = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_handle_set (rs, rfd); - ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), - GNUNET_SCHEDULER_NO_TASK, delay, - rs, NULL, task, task_cls); + ret = + GNUNET_SCHEDULER_add_select (check_priority (current_priority), + GNUNET_SCHEDULER_NO_TASK, delay, rs, NULL, + task, task_cls); GNUNET_NETWORK_fdset_destroy (rs); return ret; #else @@ -1554,9 +1551,10 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, GNUNET_assert (wfd != NULL); ws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_handle_set (ws, wfd); - ret = GNUNET_SCHEDULER_add_select (check_priority (current_priority), - GNUNET_SCHEDULER_NO_TASK, - delay, NULL, ws, task, task_cls); + ret = + GNUNET_SCHEDULER_add_select (check_priority (current_priority), + GNUNET_SCHEDULER_NO_TASK, delay, NULL, ws, + task, task_cls); GNUNET_NETWORK_fdset_destroy (ws); return ret; #else @@ -1605,8 +1603,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, */ GNUNET_SCHEDULER_TaskIdentifier GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, - GNUNET_SCHEDULER_TaskIdentifier - prerequisite_task, + GNUNET_SCHEDULER_TaskIdentifier prerequisite_task, struct GNUNET_TIME_Relative delay, const struct GNUNET_NETWORK_FDSet *rs, const struct GNUNET_NETWORK_FDSet *ws, @@ -1648,22 +1645,22 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, t->timeout = GNUNET_TIME_relative_to_absolute (delay); t->priority = check_priority ((prio == - GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority - : prio); + GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : + prio); t->lifeness = current_lifeness; t->next = pending; pending = t; max_priority_added = GNUNET_MAX (max_priority_added, t->priority); #if DEBUG_TASKS - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding task: %llu / %p\n", t->id, t->callback_cls); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding task: %llu / %p\n", t->id, + t->callback_cls); #endif #if EXECINFO int i; for (i = 0; i < t->num_backtrace_strings; i++) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Task %llu trace %d: %s\n", t->id, i, t->backtrace_strings[i]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Task %llu trace %d: %s\n", t->id, i, + t->backtrace_strings[i]); #endif return t->id; } diff --git a/src/util/server.c b/src/util/server.c index 935cf04f8..504391bc7 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -381,9 +381,7 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind"); if (port != 0) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("`%s' failed for port %d (%s).\n"), - "bind", port, + _("`%s' failed for port %d (%s).\n"), "bind", port, (serverAddr->sa_family == AF_INET) ? "IPv4" : "IPv6"); eno = 0; } @@ -391,15 +389,12 @@ open_listen_socket (const struct sockaddr *serverAddr, socklen_t socklen) { if (port != 0) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("`%s' failed for port %d (%s): address already in use\n"), + _("`%s' failed for port %d (%s): address already in use\n"), "bind", port, (serverAddr->sa_family == AF_INET) ? "IPv4" : "IPv6"); else if (serverAddr->sa_family == AF_UNIX) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("`%s' failed for `%s': address already in use\n"), - "bind", + _("`%s' failed for `%s': address already in use\n"), "bind", ((const struct sockaddr_un *) serverAddr)->sun_path); } @@ -483,12 +478,11 @@ GNUNET_SERVER_create_with_sockets (GNUNET_CONNECTION_AccessCheck access, * (typically, "port" already in use) */ struct GNUNET_SERVER_Handle * -GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, - void *access_cls, +GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, void *access_cls, struct sockaddr *const *serverAddr, const socklen_t * socklen, - struct GNUNET_TIME_Relative - idle_timeout, int require_found) + struct GNUNET_TIME_Relative idle_timeout, + int require_found) { struct GNUNET_NETWORK_Handle **lsocks; unsigned int i; @@ -521,8 +515,7 @@ GNUNET_SERVER_create (GNUNET_CONNECTION_AccessCheck access, { lsocks = NULL; } - return GNUNET_SERVER_create_with_sockets (access, access_cls, - lsocks, + return GNUNET_SERVER_create_with_sockets (access, access_cls, lsocks, idle_timeout, require_found); } @@ -610,17 +603,17 @@ warn_no_receive_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_SERVER_Client *client = cls; - client->warn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &warn_no_receive_done, - client); + client->warn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &warn_no_receive_done, client); if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Processing code for message of type %u did not call GNUNET_SERVER_receive_done after %llums\n"), (unsigned int) client->warn_type, - (unsigned long long) - GNUNET_TIME_absolute_get_duration - (client->warn_start).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_duration (client-> + warn_start). + rel_value); } @@ -737,11 +730,9 @@ GNUNET_SERVER_inject (struct GNUNET_SERVER_Handle *server, * @param addrlen length of addr * @param errCode code indicating errors receiving, 0 for success */ -static void -process_incoming (void *cls, - const void *buf, - size_t available, - const struct sockaddr *addr, socklen_t addrlen, int errCode); +static void process_incoming (void *cls, const void *buf, size_t available, + const struct sockaddr *addr, socklen_t addrlen, + int errCode); /** @@ -760,8 +751,7 @@ process_incoming (void *cls, static void process_mst (struct GNUNET_SERVER_Client *client, int ret) { - while ((ret != GNUNET_SYSERR) && - (client->server != NULL) && + while ((ret != GNUNET_SYSERR) && (client->server != NULL) && (GNUNET_YES != client->shutdown_now) && (0 == client->suspended)) { if (ret == GNUNET_OK) @@ -774,8 +764,8 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret) #endif GNUNET_CONNECTION_receive (client->connection, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, - client->idle_timeout, - &process_incoming, client); + client->idle_timeout, &process_incoming, + client); break; } #if DEBUG_SERVER @@ -817,9 +807,7 @@ process_mst (struct GNUNET_SERVER_Client *client, int ret) * @param errCode code indicating errors receiving, 0 for success */ static void -process_incoming (void *cls, - const void *buf, - size_t available, +process_incoming (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) { struct GNUNET_SERVER_Client *client = cls; @@ -834,8 +822,7 @@ process_incoming (void *cls, end = GNUNET_TIME_absolute_add (client->last_activity, client->idle_timeout); if ((buf == NULL) && (available == 0) && (addr == NULL) && (errCode == 0) && - (client->shutdown_now != GNUNET_YES) && - (server != NULL) && + (client->shutdown_now != GNUNET_YES) && (server != NULL) && (GNUNET_YES == GNUNET_CONNECTION_check (client->connection)) && (end.abs_value > now.abs_value)) { @@ -852,10 +839,7 @@ process_incoming (void *cls, &process_incoming, client); return; } - if ((buf == NULL) || - (available == 0) || - (errCode != 0) || - (server == NULL) || + if ((buf == NULL) || (available == 0) || (errCode != 0) || (server == NULL) || (client->shutdown_now == GNUNET_YES) || (GNUNET_YES != GNUNET_CONNECTION_check (client->connection))) { @@ -864,8 +848,7 @@ process_incoming (void *cls, return; } #if DEBUG_SERVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Server receives %u bytes from `%s'.\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server receives %u bytes from `%s'.\n", (unsigned int) available, GNUNET_a2s (addr, addrlen)); #endif GNUNET_SERVER_client_keep (client); @@ -928,8 +911,7 @@ restart_processing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param message the actual message */ static void -client_message_tokenizer_callback (void *cls, - void *client, +client_message_tokenizer_callback (void *cls, void *client, const struct GNUNET_MessageHeader *message) { struct GNUNET_SERVER_Handle *server = cls; @@ -963,17 +945,15 @@ client_message_tokenizer_callback (void *cls, * "client_drop" on the return value eventually) */ struct GNUNET_SERVER_Client * -GNUNET_SERVER_connect_socket (struct - GNUNET_SERVER_Handle - *server, +GNUNET_SERVER_connect_socket (struct GNUNET_SERVER_Handle *server, struct GNUNET_CONNECTION_Handle *connection) { struct GNUNET_SERVER_Client *client; client = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Client)); client->connection = connection; - client->mst = GNUNET_SERVER_mst_create (&client_message_tokenizer_callback, - server); + client->mst = + GNUNET_SERVER_mst_create (&client_message_tokenizer_callback, server); client->reference_count = 1; client->server = server; client->last_activity = GNUNET_TIME_absolute_get (); @@ -1274,8 +1254,7 @@ GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client, { client->callback_cls = callback_cls; client->callback = callback; - return GNUNET_CONNECTION_notify_transmit_ready (client->connection, - size, + return GNUNET_CONNECTION_notify_transmit_ready (client->connection, size, timeout, &transmit_ready_callback_wrapper, client); diff --git a/src/util/server_mst.c b/src/util/server_mst.c index f48ef5475..07a7b30b8 100644 --- a/src/util/server_mst.c +++ b/src/util/server_mst.c @@ -119,9 +119,8 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb, */ int GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst, - void *client_identity, - const char *buf, - size_t size, int purge, int one_shot) + void *client_identity, const char *buf, size_t size, + int purge, int one_shot) { const struct GNUNET_MessageHeader *hdr; size_t delta; diff --git a/src/util/server_nc.c b/src/util/server_nc.c index f8e300029..a1cb43f00 100644 --- a/src/util/server_nc.c +++ b/src/util/server_nc.c @@ -323,10 +323,10 @@ transmit_message (void *cls, size_t size, void *buf) "Have %u messages left in NC queue, will try transmission again\n", cl->num_pending); #endif - cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, - ntohs (pml->msg->size), - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_message, cl); + cl->th = + GNUNET_SERVER_notify_transmit_ready (cl->client, ntohs (pml->msg->size), + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_message, cl); } else GNUNET_assert (cl->num_pending == 0); @@ -344,8 +344,8 @@ transmit_message (void *cls, size_t size, void *buf) */ static void do_unicast (struct GNUNET_SERVER_NotificationContext *nc, - struct ClientList *client, - const struct GNUNET_MessageHeader *msg, int can_drop) + struct ClientList *client, const struct GNUNET_MessageHeader *msg, + int can_drop) { struct PendingMessageList *pml; uint16_t size; @@ -354,8 +354,8 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Dropping message of type %u and size %u due to full queue (%u entries)\n", - ntohs (msg->type), - ntohs (msg->size), (unsigned int) nc->queue_length); + ntohs (msg->type), ntohs (msg->size), + (unsigned int) nc->queue_length); return; /* drop! */ } if (client->num_pending > nc->queue_length) @@ -371,21 +371,20 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc, #if DEBUG_SERVER_NC GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding message of type %u and size %u to pending queue (which has %u entries)\n", - ntohs (msg->type), - ntohs (msg->size), (unsigned int) nc->queue_length); + ntohs (msg->type), ntohs (msg->size), + (unsigned int) nc->queue_length); #endif memcpy (&pml[1], msg, size); /* append */ - GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, - client->pending_tail, pml); + GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, client->pending_tail, + pml); if (client->th == NULL) - client->th = GNUNET_SERVER_notify_transmit_ready (client->client, - ntohs - (client->pending_head-> - msg->size), - GNUNET_TIME_UNIT_FOREVER_REL, - &transmit_message, - client); + client->th = + GNUNET_SERVER_notify_transmit_ready (client->client, + ntohs (client->pending_head->msg-> + size), + GNUNET_TIME_UNIT_FOREVER_REL, + &transmit_message, client); } diff --git a/src/util/server_tc.c b/src/util/server_tc.c index eda82e50f..127131032 100644 --- a/src/util/server_tc.c +++ b/src/util/server_tc.c @@ -103,13 +103,13 @@ transmit_response (void *cls, size_t size, void *buf) } else { - if (NULL == GNUNET_SERVER_notify_transmit_ready (tc->client, - GNUNET_MIN - (MIN_BLOCK_SIZE, - tc->total - tc->off), - GNUNET_TIME_absolute_get_remaining - (tc->timeout), - &transmit_response, tc)) + if (NULL == + GNUNET_SERVER_notify_transmit_ready (tc->client, + GNUNET_MIN (MIN_BLOCK_SIZE, + tc->total - tc->off), + GNUNET_TIME_absolute_get_remaining + (tc->timeout), &transmit_response, + tc)) { GNUNET_break (0); GNUNET_SERVER_receive_done (tc->client, GNUNET_SYSERR); diff --git a/src/util/service.c b/src/util/service.c index 308267bd6..9b60dc56b 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -99,12 +99,10 @@ parse_ipv4_specification (const char *routeList) pos = 0; while (i < count) { - cnt = sscanf (&routeList[pos], - "%u.%u.%u.%u/%u.%u.%u.%u;", - &temps[0], - &temps[1], - &temps[2], - &temps[3], &temps[4], &temps[5], &temps[6], &temps[7]); + cnt = + sscanf (&routeList[pos], "%u.%u.%u.%u/%u.%u.%u.%u;", &temps[0], + &temps[1], &temps[2], &temps[3], &temps[4], &temps[5], + &temps[6], &temps[7]); if (cnt == 8) { for (j = 0; j < 8; j++) @@ -115,8 +113,7 @@ parse_ipv4_specification (const char *routeList) GNUNET_free (result); return NULL; } - result[i].network.s_addr - = + result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]); result[i].netmask.s_addr = @@ -129,9 +126,9 @@ parse_ipv4_specification (const char *routeList) continue; } /* try second notation */ - cnt = sscanf (&routeList[pos], - "%u.%u.%u.%u/%u;", - &temps[0], &temps[1], &temps[2], &temps[3], &slash); + cnt = + sscanf (&routeList[pos], "%u.%u.%u.%u/%u;", &temps[0], &temps[1], + &temps[2], &temps[3], &slash); if (cnt == 5) { for (j = 0; j < 4; j++) @@ -142,8 +139,7 @@ parse_ipv4_specification (const char *routeList) GNUNET_free (result); return NULL; } - result[i].network.s_addr - = + result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]); if ((slash <= 32) && (slash >= 0)) @@ -151,8 +147,8 @@ parse_ipv4_specification (const char *routeList) result[i].netmask.s_addr = 0; while (slash > 0) { - result[i].netmask.s_addr - = (result[i].netmask.s_addr >> 1) + 0x80000000; + result[i].netmask.s_addr = + (result[i].netmask.s_addr >> 1) + 0x80000000; slash--; } result[i].netmask.s_addr = htonl (result[i].netmask.s_addr); @@ -174,8 +170,9 @@ parse_ipv4_specification (const char *routeList) } /* try third notation */ slash = 32; - cnt = sscanf (&routeList[pos], - "%u.%u.%u.%u;", &temps[0], &temps[1], &temps[2], &temps[3]); + cnt = + sscanf (&routeList[pos], "%u.%u.%u.%u;", &temps[0], &temps[1], + &temps[2], &temps[3]); if (cnt == 4) { for (j = 0; j < 4; j++) @@ -186,8 +183,7 @@ parse_ipv4_specification (const char *routeList) GNUNET_free (result); return NULL; } - result[i].network.s_addr - = + result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]); result[i].netmask.s_addr = 0; @@ -203,15 +199,15 @@ parse_ipv4_specification (const char *routeList) i++; continue; } - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid format for IP: `%s'\n"), &routeList[pos]); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid format for IP: `%s'\n"), + &routeList[pos]); GNUNET_free (result); return NULL; /* error */ } if (pos < strlen (routeList)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid format for IP: `%s'\n"), &routeList[pos]); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid format for IP: `%s'\n"), + &routeList[pos]); GNUNET_free (result); return NULL; /* oops */ } @@ -259,8 +255,7 @@ parse_ipv6_specification (const char *routeListX) if (routeList[len - 1] != ';') { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _ - ("Invalid network notation (does not end with ';': `%s')\n"), + _("Invalid network notation (does not end with ';': `%s')\n"), routeList); GNUNET_free (routeList); return NULL; @@ -313,8 +308,8 @@ parse_ipv6_specification (const char *routeListX) } while (bits > 0) { - result[i].netmask.s6_addr[off] - = (result[i].netmask.s6_addr[off] >> 1) + 0x80; + result[i].netmask.s6_addr[off] = + (result[i].netmask.s6_addr[off] >> 1) + 0x80; bits--; } } @@ -550,16 +545,15 @@ write_test (void *cls, size_t size, void *buf) * @param message the actual message */ static void -handle_test (void *cls, - struct GNUNET_SERVER_Client *client, +handle_test (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { /* simply bounce message back to acknowledge */ - if (NULL == GNUNET_SERVER_notify_transmit_ready (client, - sizeof (struct - GNUNET_MessageHeader), - GNUNET_TIME_UNIT_FOREVER_REL, - &write_test, client)) + if (NULL == + GNUNET_SERVER_notify_transmit_ready (client, + sizeof (struct GNUNET_MessageHeader), + GNUNET_TIME_UNIT_FOREVER_REL, + &write_test, client)) GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); } @@ -591,8 +585,7 @@ static const struct GNUNET_SERVER_MessageHandler defhandlers[] = { * for unknown address family (will be denied). */ static int -check_access (void *cls, - const struct GNUNET_CONNECTION_Credentials *uc, +check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc, const struct sockaddr *addr, socklen_t addrlen) { struct GNUNET_SERVICE_Context *sctx = cls; @@ -606,19 +599,17 @@ check_access (void *cls, GNUNET_assert (addrlen == sizeof (struct sockaddr_in)); i4 = (const struct sockaddr_in *) addr; ret = ((sctx->v4_allowed == NULL) || - (check_ipv4_listed (sctx->v4_allowed, - &i4->sin_addr))) - && ((sctx->v4_denied == NULL) || - (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr))); + (check_ipv4_listed (sctx->v4_allowed, &i4->sin_addr))) && + ((sctx->v4_denied == NULL) || + (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr))); break; case AF_INET6: GNUNET_assert (addrlen == sizeof (struct sockaddr_in6)); i6 = (const struct sockaddr_in6 *) addr; ret = ((sctx->v6_allowed == NULL) || - (check_ipv6_listed (sctx->v6_allowed, - &i6->sin6_addr))) - && ((sctx->v6_denied == NULL) || - (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); + (check_ipv6_listed (sctx->v6_allowed, &i6->sin6_addr))) && + ((sctx->v6_denied == NULL) || + (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr))); break; #ifndef WINDOWS case AF_UNIX: @@ -626,11 +617,10 @@ check_access (void *cls, if ((sctx->match_uid == GNUNET_YES) || (sctx->match_gid == GNUNET_YES)) ret = GNUNET_NO; if ((uc != NULL) && - ((sctx->match_uid != GNUNET_YES) || - (uc->uid == geteuid ()) || - (uc->uid == getuid ())) && - ((sctx->match_gid != GNUNET_YES) || - (uc->gid == getegid ()) || (uc->gid == getgid ()))) + ((sctx->match_uid != GNUNET_YES) || (uc->uid == geteuid ()) || + (uc->uid == getuid ())) && ((sctx->match_gid != GNUNET_YES) || + (uc->gid == getegid ()) || + (uc->gid == getgid ()))) ret = GNUNET_YES; else GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -639,8 +629,8 @@ check_access (void *cls, break; #endif default: - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Unknown address family %d\n"), addr->sa_family); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Unknown address family %d\n"), + addr->sa_family); return GNUNET_SYSERR; } if (ret != GNUNET_OK) @@ -664,8 +654,7 @@ get_pid_file_name (struct GNUNET_SERVICE_Context *sctx) char *pif; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, - sctx->serviceName, + GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->serviceName, "PIDFILE", &pif)) return NULL; return pif; @@ -676,8 +665,8 @@ get_pid_file_name (struct GNUNET_SERVICE_Context *sctx) * Parse an IPv4 access control list. */ static int -process_acl4 (struct IPv4NetworkSet **ret, - struct GNUNET_SERVICE_Context *sctx, const char *option) +process_acl4 (struct IPv4NetworkSet **ret, struct GNUNET_SERVICE_Context *sctx, + const char *option) { char *opt; @@ -705,8 +694,8 @@ process_acl4 (struct IPv4NetworkSet **ret, * Parse an IPv4 access control list. */ static int -process_acl6 (struct IPv6NetworkSet **ret, - struct GNUNET_SERVICE_Context *sctx, const char *option) +process_acl6 (struct IPv6NetworkSet **ret, struct GNUNET_SERVICE_Context *sctx, + const char *option) { char *opt; @@ -738,8 +727,8 @@ process_acl6 (struct IPv6NetworkSet **ret, * @param unixpath path to add */ static void -add_unixpath (struct sockaddr **saddrs, - socklen_t * saddrlens, const char *unixpath) +add_unixpath (struct sockaddr **saddrs, socklen_t * saddrlens, + const char *unixpath) { #ifdef AF_UNIX struct sockaddr_un *un; @@ -816,9 +805,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "DISABLEV6")) { if (GNUNET_SYSERR == - (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg, - serviceName, - "DISABLEV6"))) + (disablev6 = + GNUNET_CONFIGURATION_get_value_yesno (cfg, serviceName, "DISABLEV6"))) return GNUNET_SYSERR; } else @@ -830,8 +818,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); if (NULL == desc) { - if ((errno == ENOBUFS) || - (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) + if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || + (errno == EACCES)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); return GNUNET_SYSERR; @@ -853,8 +841,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "PORT")) { GNUNET_break (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_number (cfg, - serviceName, + GNUNET_CONFIGURATION_get_value_number (cfg, serviceName, "PORT", &port)); if (port > 65535) { @@ -869,8 +856,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, if (GNUNET_CONFIGURATION_have_value (cfg, serviceName, "BINDTO")) { GNUNET_break (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, - serviceName, + GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, "BINDTO", &hostname)); } else @@ -878,11 +864,11 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, unixpath = NULL; #ifdef AF_UNIX - if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, - serviceName, "UNIXPATH")) - && (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, "UNIXPATH", - &unixpath)) && + if ((GNUNET_YES == + GNUNET_CONFIGURATION_have_value (cfg, serviceName, "UNIXPATH")) && + (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (cfg, serviceName, "UNIXPATH", + &unixpath)) && (0 < strlen (unixpath))) { /* probe UNIX support */ @@ -901,8 +887,8 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0); if (NULL == desc) { - if ((errno == ENOBUFS) || - (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) + if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || + (errno == EACCES)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); GNUNET_free_non_null (hostname); @@ -955,11 +941,10 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, memset (&hints, 0, sizeof (struct addrinfo)); if (disablev6) hints.ai_family = AF_INET; - if ((0 != (ret = getaddrinfo (hostname, - NULL, &hints, &res))) || (res == NULL)) + if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) || + (res == NULL)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to resolve `%s': %s\n"), + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to resolve `%s': %s\n"), hostname, gai_strerror (ret)); GNUNET_free (hostname); GNUNET_free_non_null (unixpath); @@ -1006,8 +991,7 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName, if ((pos->ai_socktype != SOCK_STREAM) && (pos->ai_socktype != 0)) continue; /* huh? */ #if DEBUG_SERVICE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Service `%s' will bind to `%s'\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n", serviceName, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen)); #endif if (pos->ai_family == AF_INET) @@ -1130,8 +1114,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->serviceName, "TIMEOUT")) { if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (sctx->cfg, - sctx->serviceName, + GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->serviceName, "TIMEOUT", &idleout)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1144,13 +1127,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) else sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL; - if (GNUNET_CONFIGURATION_have_value (sctx->cfg, - sctx->serviceName, "TOLERANT")) + if (GNUNET_CONFIGURATION_have_value + (sctx->cfg, sctx->serviceName, "TOLERANT")) { if (GNUNET_SYSERR == - (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, - sctx->serviceName, - "TOLERANT"))) + (tolerant = + GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName, + "TOLERANT"))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Specified value for `%s' of service `%s' is invalid\n"), @@ -1164,19 +1147,17 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) #ifndef MINGW errno = 0; if ((NULL != (lpid = getenv ("LISTEN_PID"))) && - (1 == sscanf (lpid, "%u", &pid)) && - (getpid () == (pid_t) pid) && + (1 == sscanf (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) && (NULL != (nfds = getenv ("LISTEN_FDS"))) && - (1 == sscanf (nfds, "%u", &cnt)) && - (cnt > 0) && (cnt < FD_SETSIZE) && (cnt + 4 < FD_SETSIZE)) + (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && + (cnt + 4 < FD_SETSIZE)) { sctx->lsocks = GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1)); while (0 < cnt--) { flags = fcntl (3 + cnt, F_GETFD); - if ((flags < 0) || - (0 != (flags & FD_CLOEXEC)) || + if ((flags < 0) || (0 != (flags & FD_CLOEXEC)) || (NULL == (sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt)))) { @@ -1199,17 +1180,16 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) if ((sctx->lsocks == NULL) && (GNUNET_SYSERR == - GNUNET_SERVICE_get_server_addresses (sctx->serviceName, - sctx->cfg, + GNUNET_SERVICE_get_server_addresses (sctx->serviceName, sctx->cfg, &sctx->addrs, &sctx->addrlens))) return GNUNET_SYSERR; sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES; - sctx->match_uid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, - sctx->serviceName, - "UNIX_MATCH_UID"); - sctx->match_gid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, - sctx->serviceName, - "UNIX_MATCH_GID"); + sctx->match_uid = + GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName, + "UNIX_MATCH_UID"); + sctx->match_gid = + GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName, + "UNIX_MATCH_GID"); process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM"); process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM"); process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6"); @@ -1230,8 +1210,7 @@ get_user_name (struct GNUNET_SERVICE_Context *sctx) char *un; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, - sctx->serviceName, + GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->serviceName, "USERNAME", &un)) return NULL; return un; @@ -1319,17 +1298,13 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_RESOLVER_connect (sctx->cfg); if (sctx->lsocks != NULL) - sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, - sctx, - sctx->lsocks, - sctx->timeout, - sctx->require_found); + sctx->server = + GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, + sctx->timeout, sctx->require_found); else - sctx->server = GNUNET_SERVER_create (&check_access, - sctx, - sctx->addrs, - sctx->addrlens, - sctx->timeout, sctx->require_found); + sctx->server = + GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, + sctx->timeout, sctx->require_found); if (sctx->server == NULL) { if (sctx->addrs != NULL) @@ -1337,10 +1312,9 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) i = 0; while (sctx->addrs[i] != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Failed to start `%s' at `%s'\n"), - sctx->serviceName, - GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Failed to start `%s' at `%s'\n"), + sctx->serviceName, GNUNET_a2s (sctx->addrs[i], + sctx->addrlens[i])); i++; } } @@ -1351,8 +1325,8 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { /* install a task that will kill the server * process if the scheduler ever gets a shutdown signal */ - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &shutdown_task, sctx->server); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, + sctx->server); } sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers)); memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers)); @@ -1372,10 +1346,9 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) i = 0; while (sctx->addrs[i] != NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Service `%s' runs at %s\n"), - sctx->serviceName, - GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i])); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' runs at %s\n"), + sctx->serviceName, GNUNET_a2s (sctx->addrs[i], + sctx->addrlens[i])); i++; } } @@ -1480,8 +1453,8 @@ set_user_id (struct GNUNET_SERVICE_Context *sctx) if (pws == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Cannot obtain information about user `%s': %s\n"), - user, errno == 0 ? _("No such user") : STRERROR (errno)); + _("Cannot obtain information about user `%s': %s\n"), user, + errno == 0 ? _("No such user") : STRERROR (errno)); GNUNET_free (user); return GNUNET_SYSERR; } @@ -1537,11 +1510,9 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx) * if we shutdown nicely */ int -GNUNET_SERVICE_run (int argc, - char *const *argv, - const char *serviceName, - enum GNUNET_SERVICE_Options opt, - GNUNET_SERVICE_Main task, void *task_cls) +GNUNET_SERVICE_run (int argc, char *const *argv, const char *serviceName, + enum GNUNET_SERVICE_Options opt, GNUNET_SERVICE_Main task, + void *task_cls) { #define HANDLE_ERROR do { err = 1; GNUNET_break (0); goto shutdown; } while (0) @@ -1583,8 +1554,8 @@ GNUNET_SERVICE_run (int argc, sctx.serviceName = serviceName; sctx.cfg = cfg = GNUNET_CONFIGURATION_create (); /* setup subsystems */ - if (GNUNET_SYSERR == GNUNET_GETOPT_run (serviceName, service_options, argc, - argv)) + if (GNUNET_SYSERR == + GNUNET_GETOPT_run (serviceName, service_options, argc, argv)) goto shutdown; if (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile)) HANDLE_ERROR; @@ -1598,8 +1569,8 @@ GNUNET_SERVICE_run (int argc, goto shutdown; #if DEBUG_SERVICE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Service `%s' runs with configuration from `%s'\n", - serviceName, cfg_fn); + "Service `%s' runs with configuration from `%s'\n", serviceName, + cfg_fn); #endif if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "testing", "skew_offset", @@ -1679,17 +1650,13 @@ GNUNET_SERVICE_start (const char *serviceName, return NULL; } if (sctx->lsocks != NULL) - sctx->server = GNUNET_SERVER_create_with_sockets (&check_access, - sctx, - sctx->lsocks, - sctx->timeout, - sctx->require_found); + sctx->server = + GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks, + sctx->timeout, sctx->require_found); else - sctx->server = GNUNET_SERVER_create (&check_access, - sctx, - sctx->addrs, - sctx->addrlens, - sctx->timeout, sctx->require_found); + sctx->server = + GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens, + sctx->timeout, sctx->require_found); if (NULL == sctx->server) { diff --git a/src/util/strings.c b/src/util/strings.c index a95981690..e2ca69e10 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -96,8 +96,8 @@ GNUNET_STRINGS_buffer_fill (char *buffer, size_t size, unsigned int count, ...) * in the buffer, or 0 on error. */ unsigned int -GNUNET_STRINGS_buffer_tokenize (const char *buffer, - size_t size, unsigned int count, ...) +GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size, + unsigned int count, ...) { unsigned int start; unsigned int needed; @@ -314,8 +314,7 @@ GNUNET_STRINGS_filename_expand (const char *fil) } n = strlen (fm) + 1 + strlen (fil_ptr) + 1; buffer = GNUNET_malloc (n); - GNUNET_snprintf (buffer, n, "%s%s%s", - fm, + GNUNET_snprintf (buffer, n, "%s%s%s", fm, (fm[strlen (fm) - 1] == DIR_SEPARATOR) ? "" : DIR_SEPARATOR_STR, fil_ptr); GNUNET_free (fm); diff --git a/src/util/test_client.c b/src/util/test_client.c index 9c2abb016..f9d961ab6 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c @@ -70,8 +70,7 @@ copy_msg (void *cls, size_t size, void *buf) * Callback that just bounces the message back to the sender. */ static void -echo_cb (void *cls, - struct GNUNET_SERVER_Client *client, +echo_cb (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct CopyContext *cc; @@ -148,13 +147,10 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif sa.sin_family = AF_INET; sa.sin_port = htons (PORT); - server = GNUNET_SERVER_create (NULL, - NULL, - sap, - slens, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MILLISECONDS, 10000), - GNUNET_NO); + server = + GNUNET_SERVER_create (NULL, NULL, sap, slens, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MILLISECONDS, 10000), GNUNET_NO); GNUNET_assert (server != NULL); handlers[0].callback_cls = cls; handlers[1].callback_cls = cls; @@ -166,8 +162,8 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) sizeof (struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_SECONDS, - GNUNET_NO, - &make_msg, NULL)); + GNUNET_NO, &make_msg, + NULL)); GNUNET_CLIENT_receive (client, &recv_bounce, cls, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 10000)); @@ -186,8 +182,8 @@ check () cfg = GNUNET_CONFIGURATION_create (); GNUNET_CONFIGURATION_set_value_number (cfg, MYNAME, "PORT", PORT); GNUNET_CONFIGURATION_set_value_string (cfg, MYNAME, "HOSTNAME", "localhost"); - GNUNET_CONFIGURATION_set_value_string (cfg, - "resolver", "HOSTNAME", "localhost"); + GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", + "localhost"); ok = 1; GNUNET_SCHEDULER_run (&task, &ok); GNUNET_CONFIGURATION_destroy (cfg); diff --git a/src/util/test_common_endian.c b/src/util/test_common_endian.c index fb556c7f4..a709abec6 100644 --- a/src/util/test_common_endian.c +++ b/src/util/test_common_endian.c @@ -33,8 +33,8 @@ main (int argc, char *argv[]) CHECK (1); CHECK (0x12345678); CHECK (123456789012345LL); - if ((0x1234567890ABCDEFLL != - GNUNET_htonll (0xEFCDAB9078563412LL)) && 42 != htonl (42)) + if ((0x1234567890ABCDEFLL != GNUNET_htonll (0xEFCDAB9078563412LL)) && + 42 != htonl (42)) return 1; return 0; } diff --git a/src/util/test_common_logging.c b/src/util/test_common_logging.c index da200d62a..39ef58267 100644 --- a/src/util/test_common_logging.c +++ b/src/util/test_common_logging.c @@ -27,8 +27,8 @@ #include "gnunet_common.h" static void -my_log (void *ctx, enum GNUNET_ErrorType kind, - const char *component, const char *date, const char *msg) +my_log (void *ctx, enum GNUNET_ErrorType kind, const char *component, + const char *date, const char *msg) { unsigned int *c = ctx; diff --git a/src/util/test_configuration.c b/src/util/test_configuration.c index 8bad5b5d4..2737cb4f7 100644 --- a/src/util/test_configuration.c +++ b/src/util/test_configuration.c @@ -75,8 +75,8 @@ initDiffsCBData (struct DiffsCBData *cbData) * and comparing configuration */ static void -diffsCallBack (void *cls, - const char *section, const char *option, const char *value) +diffsCallBack (void *cls, const char *section, const char *option, + const char *value) { struct DiffsCBData *cbData = cls; int cbOption = cbData->callBackOption; @@ -90,15 +90,15 @@ diffsCallBack (void *cls, { GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, "new-value"); - GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, - option, "new-value"); + GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, + "new-value"); } break; case EDIT_ALL: GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, option, "new-value"); - GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, - option, "new-value"); + GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, option, + "new-value"); break; case ADD_NEW_ENTRY: { @@ -107,8 +107,8 @@ diffsCallBack (void *cls, if (hit == 0) { hit = 1; - GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, - "new-key", "new-value"); + GNUNET_CONFIGURATION_set_value_string (cbData->cfg, section, "new-key", + "new-value"); GNUNET_CONFIGURATION_set_value_string (cbData->cfgDiffs, section, "new-key", "new-value"); } @@ -183,8 +183,8 @@ editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option) GNUNET_asprintf (&key, "key%d", i); GNUNET_CONFIGURATION_set_value_string (cfg, "new-section", key, "new-value"); - GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, - "new-section", key, "new-value"); + GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs, "new-section", + key, "new-value"); GNUNET_free (key); } break; @@ -282,8 +282,8 @@ testConfig () return 2; } GNUNET_free (c); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, - "test", "five", &l)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_number (cfg, "test", "five", &l)) { GNUNET_break (0); return 3; @@ -364,9 +364,9 @@ testConfigFilenames () int idx; idx = 0; - if (3 != GNUNET_CONFIGURATION_iterate_value_filenames (cfg, - "FILENAMES", - "test", &check, &idx)) + if (3 != + GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", + &check, &idx)) { GNUNET_break (0); return 8; @@ -374,60 +374,54 @@ testConfigFilenames () if (idx != 3) return 16; if (GNUNET_OK != - GNUNET_CONFIGURATION_remove_value_filename (cfg, - "FILENAMES", - "test", "/File Name")) + GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", + "/File Name")) { GNUNET_break (0); return 24; } if (GNUNET_NO != - GNUNET_CONFIGURATION_remove_value_filename (cfg, - "FILENAMES", - "test", "/File Name")) + GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", + "/File Name")) { GNUNET_break (0); return 32; } if (GNUNET_NO != - GNUNET_CONFIGURATION_remove_value_filename (cfg, - "FILENAMES", "test", "Stuff")) + GNUNET_CONFIGURATION_remove_value_filename (cfg, "FILENAMES", "test", + "Stuff")) { GNUNET_break (0); return 40; } if (GNUNET_NO != - GNUNET_CONFIGURATION_append_value_filename (cfg, - "FILENAMES", - "test", "/Hello")) + GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", + "/Hello")) { GNUNET_break (0); return 48; } if (GNUNET_NO != - GNUNET_CONFIGURATION_append_value_filename (cfg, - "FILENAMES", - "test", "/World")) + GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", + "/World")) { GNUNET_break (0); return 56; } if (GNUNET_YES != - GNUNET_CONFIGURATION_append_value_filename (cfg, - "FILENAMES", - "test", "/File 1")) + GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", + "/File 1")) { GNUNET_break (0); return 64; } if (GNUNET_YES != - GNUNET_CONFIGURATION_append_value_filename (cfg, - "FILENAMES", - "test", "/File 2")) + GNUNET_CONFIGURATION_append_value_filename (cfg, "FILENAMES", "test", + "/File 2")) { GNUNET_break (0); return 72; @@ -437,9 +431,9 @@ testConfigFilenames () want[1] = "/World"; want[2] = "/File 1"; want[3] = "/File 2"; - if (4 != GNUNET_CONFIGURATION_iterate_value_filenames (cfg, - "FILENAMES", - "test", &check, &idx)) + if (4 != + GNUNET_CONFIGURATION_iterate_value_filenames (cfg, "FILENAMES", "test", + &check, &idx)) { GNUNET_break (0); return 80; diff --git a/src/util/test_connection.c b/src/util/test_connection.c index 3519522ef..cb69f4036 100644 --- a/src/util/test_connection.c +++ b/src/util/test_connection.c @@ -75,9 +75,7 @@ open_listen_socket () } static void -receive_check (void *cls, - const void *buf, - size_t available, +receive_check (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) { int *ok = cls; @@ -93,11 +91,10 @@ receive_check (void *cls, #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receive needs more data\n"); #endif - GNUNET_CONNECTION_receive (asock, - 1024, + GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 5), - &receive_check, cls); + (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, + cls); } else { @@ -127,8 +124,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks to receive on accepted socket\n"); #endif - GNUNET_CONNECTION_receive (asock, - 1024, + GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, cls); @@ -162,15 +158,14 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test asks for write notification\n"); #endif GNUNET_assert (NULL != - GNUNET_CONNECTION_notify_transmit_ready (csock, - 12, + GNUNET_CONNECTION_notify_transmit_ready (csock, 12, GNUNET_TIME_UNIT_SECONDS, &make_hello, NULL)); #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n"); #endif - GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - ls, &run_accept, cls); + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, + cls); } @@ -185,8 +180,8 @@ check () ok = 1; cfg = GNUNET_CONFIGURATION_create (); - GNUNET_CONFIGURATION_set_value_string (cfg, - "resolver", "HOSTNAME", "localhost"); + GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", + "localhost"); GNUNET_SCHEDULER_run (&task, &ok); GNUNET_CONFIGURATION_destroy (cfg); return ok; diff --git a/src/util/test_connection_addressing.c b/src/util/test_connection_addressing.c index 111894a36..2d08acc3c 100644 --- a/src/util/test_connection_addressing.c +++ b/src/util/test_connection_addressing.c @@ -67,9 +67,9 @@ open_listen_socket () if (GNUNET_NETWORK_socket_setsockopt (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); - if (GNUNET_OK != GNUNET_NETWORK_socket_bind (desc, - (const struct sockaddr *) &sa, - sizeof (sa))) + if (GNUNET_OK != + GNUNET_NETWORK_socket_bind (desc, (const struct sockaddr *) &sa, + sizeof (sa))) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "bind"); @@ -81,9 +81,7 @@ open_listen_socket () static void -receive_check (void *cls, - const void *buf, - size_t available, +receive_check (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) { int *ok = cls; @@ -93,11 +91,10 @@ receive_check (void *cls, sofar += available; if (sofar < 12) { - GNUNET_CONNECTION_receive (asock, - 1024, + GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 5), - &receive_check, cls); + (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, + cls); } else { @@ -132,8 +129,7 @@ run_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (0 == memcmp (&expect, v4, alen)); GNUNET_free (addr); GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); - GNUNET_CONNECTION_receive (asock, - 1024, + GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &receive_check, cls); @@ -162,18 +158,18 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) v4.sin_family = AF_INET; v4.sin_port = htons (PORT); v4.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - csock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, - (const struct sockaddr - *) &v4, sizeof (v4)); + csock = + GNUNET_CONNECTION_create_from_sockaddr (AF_INET, + (const struct sockaddr *) &v4, + sizeof (v4)); GNUNET_assert (csock != NULL); GNUNET_assert (NULL != - GNUNET_CONNECTION_notify_transmit_ready (csock, - 12, + GNUNET_CONNECTION_notify_transmit_ready (csock, 12, GNUNET_TIME_UNIT_SECONDS, &make_hello, NULL)); GNUNET_CONNECTION_destroy (csock, GNUNET_YES); - GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - ls, &run_accept, cls); + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, + cls); } diff --git a/src/util/test_connection_receive_cancel.c b/src/util/test_connection_receive_cancel.c index d635f5742..aa1672455 100644 --- a/src/util/test_connection_receive_cancel.c +++ b/src/util/test_connection_receive_cancel.c @@ -76,9 +76,7 @@ open_listen_socket () static void -dead_receive (void *cls, - const void *buf, - size_t available, +dead_receive (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) { GNUNET_assert (0); @@ -93,8 +91,7 @@ run_accept_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (asock != NULL); GNUNET_assert (GNUNET_YES == GNUNET_CONNECTION_check (asock)); GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); - GNUNET_CONNECTION_receive (asock, - 1024, + GNUNET_CONNECTION_receive (asock, 1024, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &dead_receive, cls); } @@ -121,10 +118,10 @@ task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (lsock != NULL); csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); - GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - ls, &run_accept_cancel, cls); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &receive_cancel_task, cls); + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, ls, + &run_accept_cancel, cls); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &receive_cancel_task, + cls); } @@ -139,8 +136,8 @@ check_receive_cancel () ok = 1; cfg = GNUNET_CONFIGURATION_create (); - GNUNET_CONFIGURATION_set_value_string (cfg, - "resolver", "HOSTNAME", "localhost"); + GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", + "localhost"); GNUNET_SCHEDULER_run (&task_receive_cancel, &ok); GNUNET_CONFIGURATION_destroy (cfg); return ok; diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 3989d654a..2338665cb 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c @@ -94,8 +94,7 @@ send_kilo (void *cls, size_t size, void *buf) memset (buf, 42, 1024); GNUNET_assert (NULL != - GNUNET_CONNECTION_notify_transmit_ready (csock, - 1024, + GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, GNUNET_TIME_UNIT_SECONDS, &send_kilo, cls)); return 1024; @@ -112,8 +111,7 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); GNUNET_assert (NULL != - GNUNET_CONNECTION_notify_transmit_ready (csock, - 1024, + GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, GNUNET_TIME_UNIT_SECONDS, &send_kilo, cls)); } @@ -130,8 +128,8 @@ check_timeout () ok = 1; cfg = GNUNET_CONFIGURATION_create (); - GNUNET_CONFIGURATION_set_value_string (cfg, - "resolver", "HOSTNAME", "localhost"); + GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", + "localhost"); GNUNET_SCHEDULER_run (&task_timeout, &ok); GNUNET_CONFIGURATION_destroy (cfg); return ok; diff --git a/src/util/test_connection_timeout_no_connect.c b/src/util/test_connection_timeout_no_connect.c index ea4a32412..2e8f9be2e 100644 --- a/src/util/test_connection_timeout_no_connect.c +++ b/src/util/test_connection_timeout_no_connect.c @@ -57,8 +57,7 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); GNUNET_assert (NULL != - GNUNET_CONNECTION_notify_transmit_ready (csock, - 1024, + GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, GNUNET_TIME_UNIT_SECONDS, &handle_timeout, cls)); @@ -76,8 +75,8 @@ check_timeout () ok = 1; cfg = GNUNET_CONFIGURATION_create (); - GNUNET_CONFIGURATION_set_value_string (cfg, - "resolver", "HOSTNAME", "localhost"); + GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", + "localhost"); GNUNET_SCHEDULER_run (&task_timeout, &ok); GNUNET_CONFIGURATION_destroy (cfg); return ok; diff --git a/src/util/test_connection_transmit_cancel.c b/src/util/test_connection_transmit_cancel.c index 4280edf1d..d81c32a6c 100644 --- a/src/util/test_connection_transmit_cancel.c +++ b/src/util/test_connection_transmit_cancel.c @@ -51,8 +51,7 @@ task_transmit_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); GNUNET_assert (csock != NULL); - th = GNUNET_CONNECTION_notify_transmit_ready (csock, - 12, + th = GNUNET_CONNECTION_notify_transmit_ready (csock, 12, GNUNET_TIME_UNIT_MINUTES, ¬_run, cls); GNUNET_assert (NULL != th); @@ -74,8 +73,8 @@ check_transmit_cancel () ok = 1; cfg = GNUNET_CONFIGURATION_create (); - GNUNET_CONFIGURATION_set_value_string (cfg, - "resolver", "HOSTNAME", "localhost"); + GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", + "localhost"); GNUNET_SCHEDULER_run (&task_transmit_cancel, &ok); GNUNET_CONFIGURATION_destroy (cfg); return ok; diff --git a/src/util/test_container_bloomfilter.c b/src/util/test_container_bloomfilter.c index 49cddac7c..c14adb075 100644 --- a/src/util/test_container_bloomfilter.c +++ b/src/util/test_container_bloomfilter.c @@ -127,8 +127,8 @@ main (int argc, char *argv[]) if (ok2 != 200) { - printf ("Got %d elements out of 200 " - "expected after initialization.\n", ok2); + printf ("Got %d elements out of 200 " "expected after initialization.\n", + ok2); GNUNET_CONTAINER_bloomfilter_free (bf); GNUNET_CONTAINER_bloomfilter_free (bfi); return -1; diff --git a/src/util/test_container_heap.c b/src/util/test_container_heap.c index 7b352241c..62d675bbb 100644 --- a/src/util/test_container_heap.c +++ b/src/util/test_container_heap.c @@ -29,8 +29,7 @@ #include "gnunet_container_lib.h" static int -iterator_callback (void *cls, - struct GNUNET_CONTAINER_HeapNode *node, +iterator_callback (void *cls, struct GNUNET_CONTAINER_HeapNode *node, void *element, GNUNET_CONTAINER_HeapCostType cost) { return GNUNET_OK; diff --git a/src/util/test_container_meta_data.c b/src/util/test_container_meta_data.c index cee550f96..fe1dd79c1 100644 --- a/src/util/test_container_meta_data.c +++ b/src/util/test_container_meta_data.c @@ -41,20 +41,17 @@ testMeta (int i) m = GNUNET_CONTAINER_meta_data_create (); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_insert (m, - "", - EXTRACTOR_METATYPE_TITLE, + GNUNET_CONTAINER_meta_data_insert (m, "", EXTRACTOR_METATYPE_TITLE, EXTRACTOR_METAFORMAT_UTF8, - "text/plain", - "TestTitle", strlen ("TestTitle") + 1)) + "text/plain", "TestTitle", + strlen ("TestTitle") + 1)) ABORT (m); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_insert (m, - "", + GNUNET_CONTAINER_meta_data_insert (m, "", EXTRACTOR_METATYPE_AUTHOR_NAME, EXTRACTOR_METAFORMAT_UTF8, - "text/plain", - "TestTitle", strlen ("TestTitle") + 1)) + "text/plain", "TestTitle", + strlen ("TestTitle") + 1)) ABORT (m); if (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (m, "", EXTRACTOR_METATYPE_TITLE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", "TestTitle", strlen ("TestTitle") + 1)) /* dup! */ ABORT (m); @@ -63,8 +60,7 @@ testMeta (int i) if (2 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL)) ABORT (m); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_delete (m, - EXTRACTOR_METATYPE_AUTHOR_NAME, + GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME, "TestTitle", strlen ("TestTitle") + 1)) ABORT (m); if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_AUTHOR_NAME, "TestTitle", strlen ("TestTitle") + 1)) /* already gone */ @@ -72,8 +68,7 @@ testMeta (int i) if (1 != GNUNET_CONTAINER_meta_data_iterate (m, NULL, NULL)) ABORT (m); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_delete (m, - EXTRACTOR_METATYPE_TITLE, + GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE, "TestTitle", strlen ("TestTitle") + 1)) ABORT (m); if (GNUNET_OK == GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_TITLE, "TestTitle", strlen ("TestTitle") + 1)) /* already gone */ @@ -82,12 +77,10 @@ testMeta (int i) ABORT (m); for (j = 0; j < i; j++) { - GNUNET_snprintf (val, - sizeof (val), - "%s.%d", "A teststring that should compress well.", j); + GNUNET_snprintf (val, sizeof (val), "%s.%d", + "A teststring that should compress well.", j); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_insert (m, - "", + GNUNET_CONTAINER_meta_data_insert (m, "", EXTRACTOR_METATYPE_UNKNOWN, EXTRACTOR_METAFORMAT_UTF8, "text/plain", val, strlen (val) + 1)) @@ -98,9 +91,9 @@ testMeta (int i) size = GNUNET_CONTAINER_meta_data_get_serialized_size (m); sval = NULL; - if (size != GNUNET_CONTAINER_meta_data_serialize (m, - &sval, size, - GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) + if (size != + GNUNET_CONTAINER_meta_data_serialize (m, &sval, size, + GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) { GNUNET_free_non_null (sval); ABORT (m); @@ -112,13 +105,11 @@ testMeta (int i) ABORT (m); for (j = 0; j < i; j++) { - GNUNET_snprintf (val, - sizeof (val), "%s.%d", + GNUNET_snprintf (val, sizeof (val), "%s.%d", "A teststring that should compress well.", j); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_delete (m, - EXTRACTOR_METATYPE_UNKNOWN, - val, strlen (val) + 1)) + GNUNET_CONTAINER_meta_data_delete (m, EXTRACTOR_METATYPE_UNKNOWN, val, + strlen (val) + 1)) { ABORT (m); } @@ -142,17 +133,16 @@ testMetaMore (int i) for (q = 0; q <= i; q++) { GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q); - GNUNET_CONTAINER_meta_data_insert (meta, - "", + GNUNET_CONTAINER_meta_data_insert (meta, "", q % EXTRACTOR_metatype_get_max (), - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", txt, strlen (txt) + 1); + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + txt, strlen (txt) + 1); } size = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); data = GNUNET_malloc (size * 4); - if (size != GNUNET_CONTAINER_meta_data_serialize (meta, - &data, size * 4, - GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) + if (size != + GNUNET_CONTAINER_meta_data_serialize (meta, &data, size * 4, + GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) { GNUNET_free (data); ABORT (meta); @@ -171,25 +161,23 @@ testMetaLink () m = GNUNET_CONTAINER_meta_data_create (); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_insert (m, - "", + GNUNET_CONTAINER_meta_data_insert (m, "", EXTRACTOR_METATYPE_UNKNOWN, EXTRACTOR_METAFORMAT_UTF8, - "text/plain", - "link", strlen ("link") + 1)) + "text/plain", "link", + strlen ("link") + 1)) ABORT (m); if (GNUNET_OK != - GNUNET_CONTAINER_meta_data_insert (m, - "", + GNUNET_CONTAINER_meta_data_insert (m, "", EXTRACTOR_METATYPE_FILENAME, EXTRACTOR_METAFORMAT_UTF8, - "text/plain", - "lib-link.m4", + "text/plain", "lib-link.m4", strlen ("lib-link.m4") + 1)) ABORT (m); val = NULL; - size = GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) - 1, - GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); + size = + GNUNET_CONTAINER_meta_data_serialize (m, &val, (size_t) - 1, + GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); GNUNET_CONTAINER_meta_data_destroy (m); m = GNUNET_CONTAINER_meta_data_deserialize (val, size); GNUNET_free (val); @@ -215,17 +203,13 @@ check () for (q = 0; q <= i; q++) { GNUNET_snprintf (txt, 128, "%u -- %u\n", i, q); - GNUNET_CONTAINER_meta_data_insert (meta, - "", + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_UNKNOWN, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "TestTitle", strlen ("TestTitle") + 1); - GNUNET_CONTAINER_meta_data_insert (meta2, - "", + GNUNET_CONTAINER_meta_data_insert (meta2, "", EXTRACTOR_METATYPE_UNKNOWN, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", + EXTRACTOR_METAFORMAT_UTF8, "text/plain", "TestTitle", strlen ("TestTitle") + 1); } @@ -303,9 +287,10 @@ check () } //check meta_data_get_first_by_types - str = GNUNET_CONTAINER_meta_data_get_first_by_types (meta, - EXTRACTOR_METATYPE_UNKNOWN, - -1); + str = + GNUNET_CONTAINER_meta_data_get_first_by_types (meta, + EXTRACTOR_METATYPE_UNKNOWN, + -1); GNUNET_assert (NULL != str); if (str[0] != 'T') { diff --git a/src/util/test_container_multihashmap.c b/src/util/test_container_multihashmap.c index c16b2df22..ba621c17e 100644 --- a/src/util/test_container_multihashmap.c +++ b/src/util/test_container_multihashmap.c @@ -54,27 +54,23 @@ testMap (int i) CHECK (0 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); CHECK (0 == GNUNET_CONTAINER_multihashmap_get_multiple (m, &k1, NULL, NULL)); - CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, - &k1, - "v1", - GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); + CHECK (GNUNET_OK == + GNUNET_CONTAINER_multihashmap_put (m, &k1, "v1", + GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); CHECK (1 == GNUNET_CONTAINER_multihashmap_size (m)); ret = GNUNET_CONTAINER_multihashmap_get (m, &k1); GNUNET_assert (ret != NULL); CHECK (0 == strcmp ("v1", ret)); - CHECK (GNUNET_NO == GNUNET_CONTAINER_multihashmap_put (m, - &k1, - "v1", - GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); + CHECK (GNUNET_NO == + GNUNET_CONTAINER_multihashmap_put (m, &k1, "v1", + GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE)); CHECK (1 == GNUNET_CONTAINER_multihashmap_size (m)); - CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, - &k1, - "v2", - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); - CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, - &k1, - "v3", - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); + CHECK (GNUNET_OK == + GNUNET_CONTAINER_multihashmap_put (m, &k1, "v2", + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); + CHECK (GNUNET_OK == + GNUNET_CONTAINER_multihashmap_put (m, &k1, "v3", + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); CHECK (3 == GNUNET_CONTAINER_multihashmap_size (m)); CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (m, &k1, "v3")); CHECK (2 == GNUNET_CONTAINER_multihashmap_size (m)); @@ -85,10 +81,9 @@ testMap (int i) CHECK (2 == GNUNET_CONTAINER_multihashmap_iterate (m, NULL, NULL)); CHECK (2 == GNUNET_CONTAINER_multihashmap_remove_all (m, &k1)); for (j = 0; j < 1024; j++) - CHECK (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (m, - &k1, - "v2", - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); + CHECK (GNUNET_OK == + GNUNET_CONTAINER_multihashmap_put (m, &k1, "v2", + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); GNUNET_CONTAINER_multihashmap_destroy (m); return 0; } diff --git a/src/util/test_container_slist.c b/src/util/test_container_slist.c index 13c12bc5a..4a277dab5 100644 --- a/src/util/test_container_slist.c +++ b/src/util/test_container_slist.c @@ -46,8 +46,7 @@ main (int argc, char *argv[]) GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0); for (i = 0; i < 100; i++) - GNUNET_CONTAINER_slist_add (l, - GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, + GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, &i, sizeof (i)); GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 100); @@ -105,8 +104,7 @@ main (int argc, char *argv[]) GNUNET_assert (GNUNET_CONTAINER_slist_count (l) == 0); for (i = 0; i < 100; i++) - GNUNET_CONTAINER_slist_add (l, - GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, + GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT, &i, sizeof (i)); /*check slist_append */ GNUNET_CONTAINER_slist_append (l, l); @@ -145,8 +143,7 @@ main (int argc, char *argv[]) { ip = GNUNET_malloc (sizeof (int)); *ip = i; - GNUNET_CONTAINER_slist_add (l, - GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC, + GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC, ip, sizeof (int)); } //creat_add diff --git a/src/util/test_crypto_aes.c b/src/util/test_crypto_aes.c index 968c7f40f..971e9afbe 100644 --- a/src/util/test_crypto_aes.c +++ b/src/util/test_crypto_aes.c @@ -39,22 +39,21 @@ testSymcipher () char res[100]; GNUNET_CRYPTO_aes_create_session_key (&key); - size = GNUNET_CRYPTO_aes_encrypt (TESTSTRING, - strlen (TESTSTRING) + 1, - &key, - (const struct - GNUNET_CRYPTO_AesInitializationVector *) - INITVALUE, result); + size = + GNUNET_CRYPTO_aes_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &key, + (const struct + GNUNET_CRYPTO_AesInitializationVector *) + INITVALUE, result); if (size == -1) { printf ("symciphertest failed: encryptBlock returned %d\n", size); return 1; } - size = GNUNET_CRYPTO_aes_decrypt (result, size, - &key, - (const struct - GNUNET_CRYPTO_AesInitializationVector *) - INITVALUE, res); + size = + GNUNET_CRYPTO_aes_decrypt (result, size, &key, + (const struct + GNUNET_CRYPTO_AesInitializationVector *) + INITVALUE, res); if (strlen (TESTSTRING) + 1 != size) { printf ("symciphertest failed: decryptBlock returned %d\n", size); @@ -101,17 +100,15 @@ verifyCrypto () if (ntohl (key.crc32) != (unsigned int) 38125195LL) { - printf ("Static key has different CRC: %u - %u\n", - ntohl (key.crc32), key.crc32); + printf ("Static key has different CRC: %u - %u\n", ntohl (key.crc32), + key.crc32); ret = 1; goto error; } if (GNUNET_CRYPTO_AES_KEY_LENGTH != - GNUNET_CRYPTO_aes_encrypt (plain, - GNUNET_CRYPTO_AES_KEY_LENGTH, - &key, + GNUNET_CRYPTO_aes_encrypt (plain, GNUNET_CRYPTO_AES_KEY_LENGTH, &key, (const struct GNUNET_CRYPTO_AesInitializationVector *) "testtesttesttest", result)) @@ -131,9 +128,7 @@ verifyCrypto () res = GNUNET_malloc (GNUNET_CRYPTO_AES_KEY_LENGTH); if (GNUNET_CRYPTO_AES_KEY_LENGTH != - GNUNET_CRYPTO_aes_decrypt (result, - GNUNET_CRYPTO_AES_KEY_LENGTH, - &key, + GNUNET_CRYPTO_aes_decrypt (result, GNUNET_CRYPTO_AES_KEY_LENGTH, &key, (const struct GNUNET_CRYPTO_AesInitializationVector *) "testtesttesttest", res)) diff --git a/src/util/test_crypto_aes_weak.c b/src/util/test_crypto_aes_weak.c index f54835b3d..a0161b575 100644 --- a/src/util/test_crypto_aes_weak.c +++ b/src/util/test_crypto_aes_weak.c @@ -94,9 +94,10 @@ testWeakKey () weak_key.crc32 = htonl (GNUNET_CRYPTO_crc32_n (&weak_key, GNUNET_CRYPTO_AES_KEY_LENGTH)); - size = GNUNET_CRYPTO_aes_encrypt (WEAK_KEY_TESTSTRING, - strlen (WEAK_KEY_TESTSTRING) + 1, - &weak_key, &INITVALUE, result); + size = + GNUNET_CRYPTO_aes_encrypt (WEAK_KEY_TESTSTRING, + strlen (WEAK_KEY_TESTSTRING) + 1, &weak_key, + &INITVALUE, result); if (size == -1) { @@ -139,8 +140,8 @@ getWeakKeys () /*printf("Got to run number %d.\n", number_of_runs); */ GNUNET_CRYPTO_aes_create_session_key (&sessionkey); - rc = gcry_cipher_open (&handle, - GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, 0); + rc = gcry_cipher_open (&handle, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, + 0); if (rc) { @@ -188,8 +189,8 @@ main (int argc, char *argv[]) } else { - printf ("\n%d weak keys found in %d runs.\n", - weak_keys, MAX_WEAK_KEY_TRIALS); + printf ("\n%d weak keys found in %d runs.\n", weak_keys, + MAX_WEAK_KEY_TRIALS); } } diff --git a/src/util/test_crypto_hkdf.c b/src/util/test_crypto_hkdf.c index a9b742922..752116194 100644 --- a/src/util/test_crypto_hkdf.c +++ b/src/util/test_crypto_hkdf.c @@ -43,8 +43,8 @@ tc1 () { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c }; - unsigned char - info[10] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; + unsigned char info[10] = + { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; unsigned char okm[42] = { 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, @@ -149,8 +149,8 @@ tc4 () { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c }; - unsigned char - info[10] = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; + unsigned char info[10] = + { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }; unsigned char okm[42] = { 0x08, 0x5a, 0x01, 0xea, 0x1b, 0x10, 0xf3, 0x69, 0x33, 0x06, 0x8b, 0x56, 0xef, 0xa5, 0xad, 0x81, 0xa4, 0xf1, 0x4b, 0x82, 0x2f, 0x5b, diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c index 184f9f137..d4340f3ea 100644 --- a/src/util/test_crypto_ksk.c +++ b/src/util/test_crypto_ksk.c @@ -66,9 +66,8 @@ testCorrectKey () snprintf (out, sizeof (out), "%02x", ((unsigned char *) &pkey)[i]); if (0 != strncmp (out, &want[i * 2], 2)) { - fprintf (stderr, - " Failed! Wanted %.2s but got %2s at %d\n", - &want[i * 2], out, i); + fprintf (stderr, " Failed! Wanted %.2s but got %2s at %d\n", &want[i * 2], + out, i); return GNUNET_SYSERR; } } @@ -144,17 +143,17 @@ testEncryptDecrypt (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) for (i = 0; i < ITER; i++) { fprintf (stderr, "."); - if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, - strlen (TESTSTRING) + 1, - &pkey, &target)) + if (GNUNET_SYSERR == + GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &pkey, + &target)) { fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); ok++; continue; } - if (-1 == GNUNET_CRYPTO_rsa_decrypt (hostkey, - &target, result, - strlen (TESTSTRING) + 1)) + if (-1 == + GNUNET_CRYPTO_rsa_decrypt (hostkey, &target, result, + strlen (TESTSTRING) + 1)) { fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); ok++; @@ -162,16 +161,15 @@ testEncryptDecrypt (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) } if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0) { - printf ("%s != %.*s - testEncryptDecrypt failed!\n", - TESTSTRING, MAX_TESTVAL, result); + printf ("%s != %.*s - testEncryptDecrypt failed!\n", TESTSTRING, + MAX_TESTVAL, result); ok++; continue; } } - printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", - ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value, ok); + printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", ITER, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value, ok); if (ok == 0) return GNUNET_OK; else @@ -203,26 +201,25 @@ testSignVerify (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey) continue; } if (GNUNET_SYSERR == - GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, - &purp, &sig, &pkey)) + GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig, + &pkey)) { printf ("GNUNET_CRYPTO_rsa_verify failed!\n"); ok = GNUNET_SYSERR; continue; } if (GNUNET_SYSERR != - GNUNET_CRYPTO_rsa_verify - (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, &purp, &sig, &pkey)) + GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, + &purp, &sig, &pkey)) { printf ("GNUNET_CRYPTO_rsa_verify failed to fail!\n"); ok = GNUNET_SYSERR; continue; } } - printf ("%d RSA sign/verify operations %llums\n", - ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value); + printf ("%d RSA sign/verify operations %llums\n", ITER, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value); return ok; } diff --git a/src/util/test_crypto_rsa.c b/src/util/test_crypto_rsa.c index d7c23731e..bf058d285 100644 --- a/src/util/test_crypto_rsa.c +++ b/src/util/test_crypto_rsa.c @@ -56,17 +56,17 @@ testEncryptDecrypt () for (i = 0; i < ITER; i++) { fprintf (stderr, "."); - if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, - strlen (TESTSTRING) + 1, - &pkey, &target)) + if (GNUNET_SYSERR == + GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &pkey, + &target)) { fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); ok++; continue; } - if (-1 == GNUNET_CRYPTO_rsa_decrypt (hostkey, - &target, result, - strlen (TESTSTRING) + 1)) + if (-1 == + GNUNET_CRYPTO_rsa_decrypt (hostkey, &target, result, + strlen (TESTSTRING) + 1)) { fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); ok++; @@ -75,16 +75,15 @@ testEncryptDecrypt () } if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0) { - printf ("%s != %.*s - testEncryptDecrypt failed!\n", - TESTSTRING, (int) MAX_TESTVAL, result); + printf ("%s != %.*s - testEncryptDecrypt failed!\n", TESTSTRING, + (int) MAX_TESTVAL, result); ok++; continue; } } - printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", - ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value, ok); + printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", ITER, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value, ok); GNUNET_CRYPTO_rsa_key_free (hostkey); if (ok == 0) return GNUNET_OK; @@ -112,19 +111,18 @@ testEncryptPerformance () for (i = 0; i < ITER; i++) { fprintf (stderr, "."); - if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, - strlen (TESTSTRING) + 1, - &pkey, &target)) + if (GNUNET_SYSERR == + GNUNET_CRYPTO_rsa_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, &pkey, + &target)) { fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); ok++; continue; } } - printf ("%d RSA encrypt operations %llu ms (%d failures)\n", - ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value, ok); + printf ("%d RSA encrypt operations %llu ms (%d failures)\n", ITER, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value, ok); GNUNET_CRYPTO_rsa_key_free (hostkey); if (ok != 0) return GNUNET_SYSERR; @@ -154,19 +152,18 @@ testEncryptDecryptSK () { fprintf (stderr, "."); GNUNET_CRYPTO_aes_create_session_key (&insk); - if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (&insk, - sizeof (struct - GNUNET_CRYPTO_AesSessionKey), - &pkey, &target)) + if (GNUNET_SYSERR == + GNUNET_CRYPTO_rsa_encrypt (&insk, + sizeof (struct GNUNET_CRYPTO_AesSessionKey), + &pkey, &target)) { fprintf (stderr, "GNUNET_CRYPTO_rsa_encrypt returned SYSERR\n"); ok++; continue; } - if (-1 == GNUNET_CRYPTO_rsa_decrypt (hostkey, - &target, &outsk, - sizeof (struct - GNUNET_CRYPTO_AesSessionKey))) + if (-1 == + GNUNET_CRYPTO_rsa_decrypt (hostkey, &target, &outsk, + sizeof (struct GNUNET_CRYPTO_AesSessionKey))) { fprintf (stderr, "GNUNET_CRYPTO_rsa_decrypt returned SYSERR\n"); ok++; @@ -180,10 +177,9 @@ testEncryptDecryptSK () continue; } } - printf ("%d RSA encrypt/decrypt SK operations %llums (%d failures)\n", - ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value, ok); + printf ("%d RSA encrypt/decrypt SK operations %llums (%d failures)\n", ITER, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value, ok); GNUNET_CRYPTO_rsa_key_free (hostkey); if (ok != 0) return GNUNET_SYSERR; @@ -219,26 +215,25 @@ testSignVerify () continue; } if (GNUNET_SYSERR == - GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, - &purp, &sig, &pkey)) + GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TEST, &purp, &sig, + &pkey)) { printf ("GNUNET_CRYPTO_rsa_verify failed!\n"); ok = GNUNET_SYSERR; continue; } if (GNUNET_SYSERR != - GNUNET_CRYPTO_rsa_verify - (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, &purp, &sig, &pkey)) + GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_OWN, + &purp, &sig, &pkey)) { printf ("GNUNET_CRYPTO_rsa_verify failed to fail!\n"); ok = GNUNET_SYSERR; continue; } } - printf ("%d RSA sign/verify operations %llums\n", - ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value); + printf ("%d RSA sign/verify operations %llums\n", ITER, + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value); GNUNET_CRYPTO_rsa_key_free (hostkey); return ok; } @@ -273,8 +268,8 @@ testSignPerformance () } } printf ("%d RSA sign operations %llu ms\n", ITER, - (unsigned long long) - GNUNET_TIME_absolute_get_duration (start).rel_value); + (unsigned long long) GNUNET_TIME_absolute_get_duration (start). + rel_value); GNUNET_CRYPTO_rsa_key_free (hostkey); return ok; } diff --git a/src/util/test_disk.c b/src/util/test_disk.c index d8d8021e5..91154a6f5 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c @@ -37,8 +37,7 @@ testReadWrite () int ret; if (strlen (TESTSTRING) != - GNUNET_DISK_fn_write (".testfile", TESTSTRING, - strlen (TESTSTRING), + GNUNET_DISK_fn_write (".testfile", TESTSTRING, strlen (TESTSTRING), GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) return 1; @@ -53,9 +52,8 @@ testReadWrite () tmp[ret] = '\0'; if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) { - fprintf (stderr, - "Error in testReadWrite: *%s* != *%s* for file %s\n", - tmp, TESTSTRING, ".testfile"); + fprintf (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp, + TESTSTRING, ".testfile"); return 1; } GNUNET_DISK_file_copy (".testfile", ".testfile2"); @@ -63,16 +61,15 @@ testReadWrite () ret = GNUNET_DISK_fn_read (".testfile2", tmp, sizeof (tmp) - 1); if (ret < 0) { - fprintf (stderr, - "Error reading file `%s' in testReadWrite\n", ".testfile2"); + fprintf (stderr, "Error reading file `%s' in testReadWrite\n", + ".testfile2"); return 1; } tmp[ret] = '\0'; if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1)) { - fprintf (stderr, - "Error in testReadWrite: *%s* != *%s* for file %s\n", - tmp, TESTSTRING, ".testfile2"); + fprintf (stderr, "Error in testReadWrite: *%s* != *%s* for file %s\n", tmp, + TESTSTRING, ".testfile2"); return 1; } @@ -91,8 +88,9 @@ testOpenClose () uint64_t size; long avail; - fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, + fh = GNUNET_DISK_file_open (".testfile", + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh)); @@ -108,8 +106,9 @@ testOpenClose () GNUNET_log_skip (1, GNUNET_NO); avail = GNUNET_DISK_get_blocks_available (".testfile"); GNUNET_log_skip (0, GNUNET_NO); - fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE - | GNUNET_DISK_OPEN_CREATE, + fh = GNUNET_DISK_file_open (".testfile", + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ); GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid (fh)); @@ -156,8 +155,7 @@ testDirScan () } static void -iter_callback (void *cls, - struct GNUNET_DISK_DirectoryIterator *di, +iter_callback (void *cls, struct GNUNET_DISK_DirectoryIterator *di, const char *filename, const char *dirname) { int *i = cls; diff --git a/src/util/test_os_network.c b/src/util/test_os_network.c index e92eba2c9..583a5fb82 100644 --- a/src/util/test_os_network.c +++ b/src/util/test_os_network.c @@ -34,9 +34,8 @@ * (success). */ static int -proc (void *cls, - const char *name, - int isDefault, const struct sockaddr *addr, socklen_t addrlen) +proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr, + socklen_t addrlen) { int *ok = cls; char buf[INET6_ADDRSTRLEN]; @@ -45,9 +44,9 @@ proc (void *cls, return GNUNET_OK; inet_ntop (addr->sa_family, - (addr->sa_family == AF_INET) ? - (void *) &((struct sockaddr_in *) addr)->sin_addr : - (void *) &((struct sockaddr_in6 *) addr)->sin6_addr, + (addr->sa_family == + AF_INET) ? (void *) &((struct sockaddr_in *) addr)-> + sin_addr : (void *) &((struct sockaddr_in6 *) addr)->sin6_addr, buf, sizeof (buf)); if ((0 == strcmp ("::1", buf)) || (0 == strcmp ("127.0.0.1", buf))) *ok = 0; diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c index 4137118fa..36dd42a23 100644 --- a/src/util/test_os_start_process.c +++ b/src/util/test_os_start_process.c @@ -125,8 +125,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } - proc = GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn, - "test_gnunet_echo_hello", "-", NULL); + proc = + GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn, + "test_gnunet_echo_hello", "-", NULL); GNUNET_free (fn); /* Close the write end of the read pipe */ diff --git a/src/util/test_program.c b/src/util/test_program.c index 9ea5b1510..faeb4e716 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c @@ -57,9 +57,8 @@ static struct GNUNET_GETOPT_CommandLineOption options4[] = { */ static void -runner (void *cls, - char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +runner (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ok = cls; @@ -92,26 +91,18 @@ check () }; GNUNET_assert (GNUNET_OK == - GNUNET_PROGRAM_run (7, - argv, - "test_program", - "A test", options1, &runner, &ok)); + GNUNET_PROGRAM_run (7, argv, "test_program", "A test", + options1, &runner, &ok)); GNUNET_assert (GNUNET_OK == - GNUNET_PROGRAM_run (7, - argv, - "test_program", - "A test", options2, &runner, &ok)); + GNUNET_PROGRAM_run (7, argv, "test_program", "A test", + options2, &runner, &ok)); GNUNET_assert (GNUNET_OK == - GNUNET_PROGRAM_run (7, - argv, - "test_program", - "A test", options3, &runner, &ok)); + GNUNET_PROGRAM_run (7, argv, "test_program", "A test", + options3, &runner, &ok)); GNUNET_assert (GNUNET_OK == - GNUNET_PROGRAM_run (7, - argv, - "test_program", - "A test", options4, &runner, &ok)); + GNUNET_PROGRAM_run (7, argv, "test_program", "A test", + options4, &runner, &ok)); return ok; } diff --git a/src/util/test_pseudonym.c b/src/util/test_pseudonym.c index dfdcbb1bb..20a3d3d96 100644 --- a/src/util/test_pseudonym.c +++ b/src/util/test_pseudonym.c @@ -38,15 +38,12 @@ static struct GNUNET_CONTAINER_MetaData *meta; static GNUNET_HashCode id1; static int -iter (void *cls, - const GNUNET_HashCode * - pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating) +iter (void *cls, const GNUNET_HashCode * pseudonym, + const struct GNUNET_CONTAINER_MetaData *md, int rating) { int *ok = cls; - if ((0 == memcmp (pseudonym, - &id1, - sizeof (GNUNET_HashCode))) && + if ((0 == memcmp (pseudonym, &id1, sizeof (GNUNET_HashCode))) && (!GNUNET_CONTAINER_meta_data_test_equal (md, meta))) { *ok = GNUNET_NO; @@ -56,9 +53,7 @@ iter (void *cls, } static int -noti_callback (void *cls, - const GNUNET_HashCode * - pseudonym, +noti_callback (void *cls, const GNUNET_HashCode * pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating) { int *ret = cls; @@ -68,9 +63,7 @@ noti_callback (void *cls, } static int -fake_noti_callback (void *cls, - const GNUNET_HashCode * - pseudonym, +fake_noti_callback (void *cls, const GNUNET_HashCode * pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating) { int *ret = cls; @@ -80,8 +73,7 @@ fake_noti_callback (void *cls, } static int -false_callback (void *cls, - const GNUNET_HashCode * pseudonym, +false_callback (void *cls, const GNUNET_HashCode * pseudonym, const struct GNUNET_CONTAINER_MetaData *md, int rating) { return GNUNET_OK; @@ -125,8 +117,7 @@ main (int argc, char *argv[]) notiCount = 0; fakenotiCount = 0; count = 0; - GNUNET_PSEUDONYM_discovery_callback_register (cfg, - &fake_noti_callback, + GNUNET_PSEUDONYM_discovery_callback_register (cfg, &fake_noti_callback, &fakenotiCount); GNUNET_PSEUDONYM_discovery_callback_register (cfg, ¬i_callback, ¬iCount); @@ -137,11 +128,9 @@ main (int argc, char *argv[]) /* ACTUAL TEST CODE */ old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL); meta = GNUNET_CONTAINER_meta_data_create (); - GNUNET_CONTAINER_meta_data_insert (meta, - "", - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", "test", strlen ("test") + 1); + GNUNET_CONTAINER_meta_data_insert (meta, "", EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METAFORMAT_UTF8, "text/plain", + "test", strlen ("test") + 1); GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1); GNUNET_PSEUDONYM_add (cfg, &id1, meta); CHECK (notiCount == 1); @@ -155,14 +144,12 @@ main (int argc, char *argv[]) CHECK (notiCount == 3); newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok); CHECK (old < newVal); - GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_meta_data_insert (meta, - "", - EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", - m, - strlen (m) + - 1)); + GNUNET_assert (GNUNET_OK == + GNUNET_CONTAINER_meta_data_insert (meta, "", + EXTRACTOR_METATYPE_COMMENT, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", m, + strlen (m) + 1)); GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id3); GNUNET_PSEUDONYM_add (cfg, &id3, meta); name3 = GNUNET_PSEUDONYM_id_to_name (cfg, &id3); diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index 8058fa287..563f204eb 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c @@ -65,16 +65,16 @@ check_localhost_num (void *cls, const char *hostname) if (0 == strcmp (hostname, "127.0.0.1")) { #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received correct hostname `%s'.\n", hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct hostname `%s'.\n", + hostname); #endif (*ok) &= ~4; } else { #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received invalid hostname `%s'.\n", hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received invalid hostname `%s'.\n", + hostname); #endif GNUNET_break (0); } @@ -91,8 +91,8 @@ check_localhost (void *cls, const char *hostname) if (0 == strcmp (hostname, "localhost")) { #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received correct hostname `%s'.\n", hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct hostname `%s'.\n", + hostname); #endif (*ok) &= ~2; } @@ -139,20 +139,20 @@ check_local_fqdn (void *cls, const char *gnunet_fqdn) if (0 != gethostname (hostname, sizeof (hostname) - 1)) { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | - GNUNET_ERROR_TYPE_BULK, "gethostname"); + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, + "gethostname"); return; } #if DEBUG_RESOLVER - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Resolving our FQDN `%s'\n"), hostname); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Resolving our FQDN `%s'\n"), + hostname); #endif host = gethostbyname (hostname); if (NULL == host) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Could not resolve our FQDN : %s %u\n"), - hstrerror (h_errno), h_errno); + _("Could not resolve our FQDN : %s %u\n"), hstrerror (h_errno), + h_errno); return; } @@ -224,8 +224,8 @@ check_rootserver_name (void *cls, const char *hostname) } static void -run (void *cls, char *const *args, - const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ok = cls; struct sockaddr_in sa; @@ -283,8 +283,9 @@ run (void *cls, char *const *args, } /* Comparing to resolved address to the address the root name server should have */ - if (strcmp (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]), - ROOTSERVER_IP) != 0) + if (strcmp + (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]), + ROOTSERVER_IP) != 0) { #if DEBUG_RESOLVER GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -318,8 +319,8 @@ run (void *cls, char *const *args, GNUNET_break (0); } - rootserver - = gethostbyaddr (&rootserver_addr, sizeof (rootserver_addr), AF_INET); + rootserver = + gethostbyaddr (&rootserver_addr, sizeof (rootserver_addr), AF_INET); if (rootserver == NULL) { /* Error: resolving IP addresses does not work */ diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index d5a701692..3d8ae979c 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c @@ -50,8 +50,8 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (2 == *ok); (*ok) = 3; /* t3 will go before t4: higher priority */ - GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, - &task3, cls); + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task3, + cls); } static void @@ -106,8 +106,8 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); (*ok) = 8; - GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, - &taskLast, cls); + GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, &taskLast, + cls); GNUNET_SCHEDULER_shutdown (); } @@ -123,10 +123,10 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (NULL != p); fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ); fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE); - GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - fds[0], &taskRd, cls); - GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, - fds[1], &taskWrt, cls); + GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[0], &taskRd, + cls); + GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, fds[1], + &taskWrt, cls); } @@ -225,8 +225,8 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (1 == *ok); *ok = 0; - GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, - &taskNeverRun, NULL)); + GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after + (GNUNET_SCHEDULER_NO_TASK, &taskNeverRun, NULL)); } diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index b98e76eeb..8bcfa096e 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c @@ -66,8 +66,8 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MILLISECONDS, i), - &test_task, NULL); + (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task, + NULL); i += INCR; } @@ -76,8 +76,8 @@ check () { target = GNUNET_TIME_absolute_get (); GNUNET_SCHEDULER_run (&test_task, NULL); - FPRINTF (stdout, - "Sleep precision: %llu ms. ", cumDelta / 1000 / (MAXV / INCR)); + FPRINTF (stdout, "Sleep precision: %llu ms. ", + cumDelta / 1000 / (MAXV / INCR)); if (cumDelta <= 10 * MAXV / INCR) fprintf (stdout, "Timer precision is excellent.\n"); else if (cumDelta <= 50 * MAXV / INCR) /* 50 ms average deviation */ diff --git a/src/util/test_server.c b/src/util/test_server.c index 577a841ff..59bf8a2f4 100644 --- a/src/util/test_server.c +++ b/src/util/test_server.c @@ -60,8 +60,7 @@ finish_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -recv_fin_cb (void *cls, - struct GNUNET_SERVER_Client *client, +recv_fin_cb (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GNUNET_assert (ok == 5); @@ -98,8 +97,7 @@ reply_msg (void *cls, size_t size, void *buf) static void -recv_cb (void *cls, - struct GNUNET_SERVER_Client *client, +recv_cb (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GNUNET_assert (ok == 2); @@ -111,8 +109,8 @@ recv_cb (void *cls, GNUNET_assert (NULL != GNUNET_SERVER_notify_transmit_ready (client, ntohs (message->size), - TIMEOUT, - &reply_msg, NULL)); + TIMEOUT, &reply_msg, + NULL)); } diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index 03d57a222..8010695e8 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c @@ -80,8 +80,7 @@ server_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -recv_cb (void *cls, - struct GNUNET_SERVER_Client *client, +recv_cb (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GNUNET_assert (ok == 2); diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c index 4b9d84059..06a4b71d6 100644 --- a/src/util/test_server_with_client.c +++ b/src/util/test_server_with_client.c @@ -57,8 +57,7 @@ send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -recv_cb (void *cls, - struct GNUNET_SERVER_Client *argclient, +recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient, const struct GNUNET_MessageHeader *message) { void *addr; @@ -169,13 +168,10 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif sa.sin_family = AF_INET; sa.sin_port = htons (PORT); - server = GNUNET_SERVER_create (NULL, - NULL, - sap, - slens, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MILLISECONDS, 250), - GNUNET_NO); + server = + GNUNET_SERVER_create (NULL, NULL, sap, slens, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO); GNUNET_assert (server != NULL); handlers[0].callback_cls = cls; GNUNET_SERVER_add_handlers (server, handlers); @@ -187,8 +183,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "localhost"); client = GNUNET_CLIENT_connect ("test", cfg); GNUNET_assert (client != NULL); - GNUNET_CLIENT_notify_transmit_ready (client, - 256, + GNUNET_CLIENT_notify_transmit_ready (client, 256, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO, ¬ify_ready, NULL); diff --git a/src/util/test_server_with_client_unix.c b/src/util/test_server_with_client_unix.c index 00df21129..99af4e8c3 100644 --- a/src/util/test_server_with_client_unix.c +++ b/src/util/test_server_with_client_unix.c @@ -55,8 +55,7 @@ send_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -recv_cb (void *cls, - struct GNUNET_SERVER_Client *argclient, +recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient, const struct GNUNET_MessageHeader *message) { switch (ok) @@ -156,13 +155,10 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) slens[0] = sizeof (un); sap[1] = NULL; slens[1] = 0; - server = GNUNET_SERVER_create (NULL, - NULL, - sap, - slens, - GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MILLISECONDS, 250), - GNUNET_NO); + server = + GNUNET_SERVER_create (NULL, NULL, sap, slens, + GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO); GNUNET_assert (server != NULL); handlers[0].callback_cls = cls; GNUNET_SERVER_add_handlers (server, handlers); @@ -175,8 +171,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) client = GNUNET_CLIENT_connect ("test", cfg); GNUNET_assert (client != NULL); - GNUNET_CLIENT_notify_transmit_ready (client, - 256, + GNUNET_CLIENT_notify_transmit_ready (client, 256, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), GNUNET_NO, ¬ify_ready, NULL); diff --git a/src/util/test_service.c b/src/util/test_service.c index daafa6cd3..4d1608191 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c @@ -71,8 +71,8 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Client connecting, waiting to transmit\n"); GNUNET_CLIENT_notify_transmit_ready (client, sizeof (struct GNUNET_MessageHeader), - GNUNET_TIME_UNIT_SECONDS, - GNUNET_NO, &build_msg, client); + GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, + &build_msg, client); } static void @@ -83,8 +83,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void -recv_cb (void *cls, - struct GNUNET_SERVER_Client *client, +recv_cb (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); @@ -105,15 +104,13 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { static void -runner (void *cls, - struct GNUNET_SERVER_Handle *server, +runner (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); GNUNET_SERVER_add_handlers (server, myhandlers); - GNUNET_CLIENT_service_test ("test_service", - cfg, GNUNET_TIME_UNIT_SECONDS, &ready, - (void *) cfg); + GNUNET_CLIENT_service_test ("test_service", cfg, GNUNET_TIME_UNIT_SECONDS, + &ready, (void *) cfg); } @@ -139,9 +136,7 @@ check () }; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); GNUNET_assert (GNUNET_OK == - GNUNET_SERVICE_run (5, - argv, - "test_service", + GNUNET_SERVICE_run (5, argv, "test_service", GNUNET_SERVICE_OPTION_NONE, &runner, &ok)); GNUNET_assert (0 == ok); return ok; @@ -160,20 +155,18 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); GNUNET_CLIENT_notify_transmit_ready (client, sizeof (struct GNUNET_MessageHeader), - GNUNET_TIME_UNIT_SECONDS, - GNUNET_NO, &build_msg, client); + GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, + &build_msg, client); } static void -runner6 (void *cls, - struct GNUNET_SERVER_Handle *server, +runner6 (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); GNUNET_SERVER_add_handlers (server, myhandlers); - GNUNET_CLIENT_service_test ("test_service6", - cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, - (void *) cfg); + GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, + &ready6, (void *) cfg); } /** @@ -197,11 +190,9 @@ check6 () }; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); GNUNET_assert (GNUNET_OK == - GNUNET_SERVICE_run (5, - argv, - "test_service6", - GNUNET_SERVICE_OPTION_NONE, - &runner6, &ok)); + GNUNET_SERVICE_run (5, argv, "test_service6", + GNUNET_SERVICE_OPTION_NONE, &runner6, + &ok)); GNUNET_assert (0 == ok); return ok; } @@ -209,9 +200,7 @@ check6 () static void -start_stop_main (void *cls, - char *const *args, - const char *cfgfile, +start_stop_main (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { int *ret = cls; @@ -245,10 +234,7 @@ check_start_stop () int ret = 1; GNUNET_assert (GNUNET_OK == - GNUNET_PROGRAM_run (5, - argv, - "test-service-program", - "no help", + GNUNET_PROGRAM_run (5, argv, "test-service-program", "no help", options, &start_stop_main, &ret)); GNUNET_break (0 == ret); @@ -278,8 +264,8 @@ main (int argc, char *argv[]) #endif if (NULL == s) { - if ((errno == ENOBUFS) || - (errno == ENOMEM) || (errno == ENFILE) || (errno == EACCES)) + if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || + (errno == EACCES)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); return 1; diff --git a/src/util/test_time.c b/src/util/test_time.c index 788884fcc..6a05b698c 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c @@ -108,8 +108,8 @@ check () GNUNET_assert (GNUNET_TIME_absolute_get_difference (future, now).rel_value == 0); - GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever).rel_value - == forever.abs_value); + GNUNET_assert (GNUNET_TIME_absolute_get_difference (zero, forever). + rel_value == forever.abs_value); past.abs_value = now.abs_value - 1000000; rel = GNUNET_TIME_absolute_get_duration (future); @@ -153,7 +153,8 @@ check () GNUNET_assert (forever.abs_value == GNUNET_TIME_absolute_subtract (forever, - GNUNET_TIME_UNIT_MINUTES).abs_value); + GNUNET_TIME_UNIT_MINUTES). + abs_value); /*check absolute subtract */ now.abs_value = 50000; rel.rel_value = 100000; diff --git a/src/util/time.c b/src/util/time.c index f4d4c4070..34880b08b 100644 --- a/src/util/time.c +++ b/src/util/time.c @@ -145,9 +145,8 @@ GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) * @return timestamp that is smaller */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_min (struct - GNUNET_TIME_Relative - t1, struct GNUNET_TIME_Relative t2) +GNUNET_TIME_relative_min (struct GNUNET_TIME_Relative t1, + struct GNUNET_TIME_Relative t2) { return (t1.rel_value < t2.rel_value) ? t1 : t2; } @@ -161,9 +160,8 @@ GNUNET_TIME_relative_min (struct * @return timestamp that is larger */ struct GNUNET_TIME_Relative -GNUNET_TIME_relative_max (struct - GNUNET_TIME_Relative - t1, struct GNUNET_TIME_Relative t2) +GNUNET_TIME_relative_max (struct GNUNET_TIME_Relative t1, + struct GNUNET_TIME_Relative t2) { return (t1.rel_value > t2.rel_value) ? t1 : t2; } @@ -178,9 +176,8 @@ GNUNET_TIME_relative_max (struct * @return timestamp that is smaller */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_min (struct - GNUNET_TIME_Absolute - t1, struct GNUNET_TIME_Absolute t2) +GNUNET_TIME_absolute_min (struct GNUNET_TIME_Absolute t1, + struct GNUNET_TIME_Absolute t2) { return (t1.abs_value < t2.abs_value) ? t1 : t2; } @@ -194,9 +191,8 @@ GNUNET_TIME_absolute_min (struct * @return timestamp that is smaller */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_max (struct - GNUNET_TIME_Absolute - t1, struct GNUNET_TIME_Absolute t2) +GNUNET_TIME_absolute_max (struct GNUNET_TIME_Absolute t1, + struct GNUNET_TIME_Absolute t2) { return (t1.abs_value > t2.abs_value) ? t1 : t2; } @@ -298,9 +294,8 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, * @return ZERO if start <= duration, or FOREVER if start time is FOREVER; start-duration otherwise */ struct GNUNET_TIME_Absolute -GNUNET_TIME_absolute_subtract (struct - GNUNET_TIME_Absolute - start, struct GNUNET_TIME_Relative duration) +GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, + struct GNUNET_TIME_Relative duration) { struct GNUNET_TIME_Absolute ret; @@ -368,8 +363,8 @@ GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, * assuming it continues at the same speed */ struct GNUNET_TIME_Relative -GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, - uint64_t finished, uint64_t total) +GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished, + uint64_t total) { struct GNUNET_TIME_Relative dur; double exp; diff --git a/src/util/winproc.c b/src/util/winproc.c index 4fa3ab484..9594c5d6f 100644 --- a/src/util/winproc.c +++ b/src/util/winproc.c @@ -100,8 +100,9 @@ GNInitWinEnv () /* Function to get CPU usage under Win NT */ if (hNTDLL) { - GNNtQuerySystemInformation = (TNtQuerySystemInformation) - GetProcAddress (hNTDLL, "NtQuerySystemInformation"); + GNNtQuerySystemInformation = + (TNtQuerySystemInformation) GetProcAddress (hNTDLL, + "NtQuerySystemInformation"); } else { @@ -113,13 +114,13 @@ GNInitWinEnv () if (hIphlpapi) { GNGetIfEntry = (TGetIfEntry) GetProcAddress (hIphlpapi, "GetIfEntry"); - GNGetIpAddrTable = (TGetIpAddrTable) GetProcAddress (hIphlpapi, - "GetIpAddrTable"); + GNGetIpAddrTable = + (TGetIpAddrTable) GetProcAddress (hIphlpapi, "GetIpAddrTable"); GNGetIfTable = (TGetIfTable) GetProcAddress (hIphlpapi, "GetIfTable"); - GNGetBestInterface = (TGetBestInterface) GetProcAddress (hIphlpapi, - "GetBestInterface"); - GGetAdaptersInfo = (TGetAdaptersInfo) GetProcAddress (hIphlpapi, - "GetAdaptersInfo"); + GNGetBestInterface = + (TGetBestInterface) GetProcAddress (hIphlpapi, "GetBestInterface"); + GGetAdaptersInfo = + (TGetAdaptersInfo) GetProcAddress (hIphlpapi, "GetAdaptersInfo"); } else { @@ -134,51 +135,57 @@ GNInitWinEnv () hAdvapi = LoadLibrary ("advapi32.dll"); if (hAdvapi) { - GNOpenSCManager = (TOpenSCManager) - GetProcAddress (hAdvapi, "OpenSCManagerA"); - GNCreateService = (TCreateService) - GetProcAddress (hAdvapi, "CreateServiceA"); - GNCloseServiceHandle = (TCloseServiceHandle) - GetProcAddress (hAdvapi, "CloseServiceHandle"); - GNDeleteService = (TDeleteService) - GetProcAddress (hAdvapi, "DeleteService"); - GNRegisterServiceCtrlHandler = (TRegisterServiceCtrlHandler) - GetProcAddress (hAdvapi, "RegisterServiceCtrlHandlerA"); - GNSetServiceStatus = (TSetServiceStatus) - GetProcAddress (hAdvapi, "SetServiceStatus"); - GNStartServiceCtrlDispatcher = (TStartServiceCtrlDispatcher) - GetProcAddress (hAdvapi, "StartServiceCtrlDispatcherA"); - GNControlService = (TControlService) - GetProcAddress (hAdvapi, "ControlService"); + GNOpenSCManager = + (TOpenSCManager) GetProcAddress (hAdvapi, "OpenSCManagerA"); + GNCreateService = + (TCreateService) GetProcAddress (hAdvapi, "CreateServiceA"); + GNCloseServiceHandle = + (TCloseServiceHandle) GetProcAddress (hAdvapi, "CloseServiceHandle"); + GNDeleteService = + (TDeleteService) GetProcAddress (hAdvapi, "DeleteService"); + GNRegisterServiceCtrlHandler = + (TRegisterServiceCtrlHandler) GetProcAddress (hAdvapi, + "RegisterServiceCtrlHandlerA"); + GNSetServiceStatus = + (TSetServiceStatus) GetProcAddress (hAdvapi, "SetServiceStatus"); + GNStartServiceCtrlDispatcher = + (TStartServiceCtrlDispatcher) GetProcAddress (hAdvapi, + "StartServiceCtrlDispatcherA"); + GNControlService = + (TControlService) GetProcAddress (hAdvapi, "ControlService"); GNOpenService = (TOpenService) GetProcAddress (hAdvapi, "OpenServiceA"); - GNLsaOpenPolicy = (TLsaOpenPolicy) - GetProcAddress (hAdvapi, "LsaOpenPolicy"); - GNLsaAddAccountRights = (TLsaAddAccountRights) - GetProcAddress (hAdvapi, "LsaAddAccountRights"); - GNLsaRemoveAccountRights = (TLsaRemoveAccountRights) - GetProcAddress (hAdvapi, "LsaRemoveAccountRights"); + GNLsaOpenPolicy = + (TLsaOpenPolicy) GetProcAddress (hAdvapi, "LsaOpenPolicy"); + GNLsaAddAccountRights = + (TLsaAddAccountRights) GetProcAddress (hAdvapi, "LsaAddAccountRights"); + GNLsaRemoveAccountRights = + (TLsaRemoveAccountRights) GetProcAddress (hAdvapi, + "LsaRemoveAccountRights"); GNLsaClose = (TLsaClose) GetProcAddress (hAdvapi, "LsaClose"); - GNLookupAccountName = (TLookupAccountName) - GetProcAddress (hAdvapi, "LookupAccountNameA"); - - GNGetFileSecurity = (TGetFileSecurity) - GetProcAddress (hAdvapi, "GetFileSecurityA"); - GNInitializeSecurityDescriptor = (TInitializeSecurityDescriptor) - GetProcAddress (hAdvapi, "InitializeSecurityDescriptor"); - GNGetSecurityDescriptorDacl = (TGetSecurityDescriptorDacl) - GetProcAddress (hAdvapi, "GetSecurityDescriptorDacl"); - GNGetAclInformation = (TGetAclInformation) - GetProcAddress (hAdvapi, "GetAclInformation"); - GNInitializeAcl = (TInitializeAcl) - GetProcAddress (hAdvapi, "InitializeAcl"); + GNLookupAccountName = + (TLookupAccountName) GetProcAddress (hAdvapi, "LookupAccountNameA"); + + GNGetFileSecurity = + (TGetFileSecurity) GetProcAddress (hAdvapi, "GetFileSecurityA"); + GNInitializeSecurityDescriptor = + (TInitializeSecurityDescriptor) GetProcAddress (hAdvapi, + "InitializeSecurityDescriptor"); + GNGetSecurityDescriptorDacl = + (TGetSecurityDescriptorDacl) GetProcAddress (hAdvapi, + "GetSecurityDescriptorDacl"); + GNGetAclInformation = + (TGetAclInformation) GetProcAddress (hAdvapi, "GetAclInformation"); + GNInitializeAcl = + (TInitializeAcl) GetProcAddress (hAdvapi, "InitializeAcl"); GNGetAce = (TGetAce) GetProcAddress (hAdvapi, "GetAce"); GNEqualSid = (TEqualSid) GetProcAddress (hAdvapi, "EqualSid"); GNAddAce = (TAddAce) GetProcAddress (hAdvapi, "AddAce"); - GNAddAccessAllowedAce = (TAddAccessAllowedAce) - GetProcAddress (hAdvapi, "AddAccessAllowedAce"); - GNSetNamedSecurityInfo = (TSetNamedSecurityInfo) - GetProcAddress (hAdvapi, "SetNamedSecurityInfoA"); + GNAddAccessAllowedAce = + (TAddAccessAllowedAce) GetProcAddress (hAdvapi, "AddAccessAllowedAce"); + GNSetNamedSecurityInfo = + (TSetNamedSecurityInfo) GetProcAddress (hAdvapi, + "SetNamedSecurityInfoA"); } else { @@ -215,8 +222,8 @@ GNInitWinEnv () if (hNetapi) { GNNetUserAdd = (TNetUserAdd) GetProcAddress (hNetapi, "NetUserAdd"); - GNNetUserSetInfo = (TNetUserSetInfo) - GetProcAddress (hNetapi, "NetUserSetInfo"); + GNNetUserSetInfo = + (TNetUserSetInfo) GetProcAddress (hNetapi, "NetUserSetInfo"); } else { diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c index de906af3b..324c136b0 100644 --- a/src/vpn/gnunet-daemon-exit.c +++ b/src/vpn/gnunet-daemon-exit.c @@ -522,8 +522,7 @@ tcp_from_helper (struct tcp_pkt *tcp, unsigned char *dadr, size_t addrlen, * Receive packets from the helper-process */ static void -message_token (void *cls __attribute__ ((unused)), - void *client +message_token (void *cls __attribute__ ((unused)), void *client __attribute__ ((unused)), const struct GNUNET_MessageHeader *message) { @@ -612,8 +611,8 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) "TCP_REDIRECTS", &cpy))) goto next; - for (redirect = strtok (cpy, " "); redirect != NULL; redirect = strtok - (NULL, " ")) + for (redirect = strtok (cpy, " "); redirect != NULL; + redirect = strtok (NULL, " ")) { if (NULL == (hostname = strstr (redirect, ":"))) { @@ -654,8 +653,7 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) char *ip4addr; GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, - "exit", + GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", &ip4addr)); GNUNET_assert (1 == inet_pton (AF_INET, ip4addr, serv->v4.ip4address)); @@ -668,8 +666,7 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) char *ip6addr; GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, - "exit", + GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR", &ip6addr)); GNUNET_assert (1 == inet_pton (AF_INET6, ip6addr, serv->v6.ip6address)); @@ -774,13 +771,10 @@ start_helper_and_schedule (void *cls, * When the helper dies, this function will be called again with the * helper_handle as cls. */ - helper_handle = start_helper (ifname, - ipv6addr, - ipv6prefix, - ipv4addr, - ipv4mask, - "exit-gnunet", - start_helper_and_schedule, message_token, NULL); + helper_handle = + start_helper (ifname, ipv6addr, ipv6prefix, ipv4addr, ipv4mask, + "exit-gnunet", start_helper_and_schedule, message_token, + NULL); GNUNET_free (ipv6addr); GNUNET_free (ipv6prefix); @@ -822,11 +816,11 @@ prepare_ipv4_packet (ssize_t len, ssize_t pktlen, void *payload, char *ipv4mask; GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, "exit", - "IPV4ADDR", &ipv4addr)); + GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", + &ipv4addr)); GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, "exit", - "IPV4MASK", &ipv4mask)); + GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", + &ipv4mask)); inet_pton (AF_INET, ipv4addr, &tmp); inet_pton (AF_INET, ipv4mask, &tmp2); GNUNET_free (ipv4addr); @@ -910,8 +904,8 @@ prepare_ipv6_packet (ssize_t len, ssize_t pktlen, void *payload, unsigned long long ipv6prefix; GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, "exit", - "IPV6ADDR", &ipv6addr)); + GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR", + &ipv6addr)); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "IPV6PREFIX", @@ -987,9 +981,10 @@ prepare_ipv6_packet (ssize_t len, ssize_t pktlen, void *payload, * The messages are one GNUNET_HashCode for the service followed by a struct tcp_pkt */ static int -receive_tcp_service (void *cls __attribute__ ((unused)), - struct GNUNET_MESH_Tunnel *tunnel, - void **tunnel_ctx __attribute__ ((unused)), +receive_tcp_service (void *cls + __attribute__ ((unused)), + struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), const struct GNUNET_MessageHeader *message, @@ -999,9 +994,9 @@ receive_tcp_service (void *cls __attribute__ ((unused)), GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet\n"); GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); - unsigned int pkt_len = ntohs (message->size) - sizeof (struct - GNUNET_MessageHeader) - - sizeof (GNUNET_HashCode); + unsigned int pkt_len = + ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - + sizeof (GNUNET_HashCode); /** Get the configuration from the services-hashmap. * @@ -1018,8 +1013,8 @@ receive_tcp_service (void *cls __attribute__ ((unused)), if (NULL == serv) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "No service found for TCP dpt %d!\n", *tcp_desc); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "No service found for TCP dpt %d!\n", + *tcp_desc); return GNUNET_YES; } @@ -1045,7 +1040,8 @@ receive_tcp_service (void *cls __attribute__ ((unused)), state->hashmap = tcp_connections; memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); - len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + + len = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + sizeof (struct ip6_hdr) + pkt_len; buf = alloca (len); @@ -1055,13 +1051,13 @@ receive_tcp_service (void *cls __attribute__ ((unused)), { case 4: prepare_ipv4_packet (len, pkt_len, pkt, 0x06, /* TCP */ - &serv->v4.ip4address, - tunnel, state, (struct ip_pkt *) buf); + &serv->v4.ip4address, tunnel, state, + (struct ip_pkt *) buf); break; case 6: prepare_ipv6_packet (len, pkt_len, pkt, 0x06, /* TCP */ - &serv->v6.ip6address, - tunnel, state, (struct ip6_pkt *) buf); + &serv->v6.ip6address, tunnel, state, + (struct ip6_pkt *) buf); break; default: @@ -1094,9 +1090,10 @@ receive_tcp_service (void *cls __attribute__ ((unused)), } static int -receive_tcp_remote (void *cls __attribute__ ((unused)), - struct GNUNET_MESH_Tunnel *tunnel, - void **tunnel_ctx __attribute__ ((unused)), +receive_tcp_remote (void *cls + __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, + void **tunnel_ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), const struct GNUNET_MessageHeader *message, @@ -1120,7 +1117,8 @@ receive_tcp_remote (void *cls __attribute__ ((unused)), state->hashmap = tcp_connections; memcpy (&state->remote, s, sizeof (struct remote_addr)); - len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + + len = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + sizeof (struct ip6_hdr) + pkt_len; buf = alloca (len); @@ -1169,9 +1167,10 @@ receive_tcp_remote (void *cls __attribute__ ((unused)), } static int -receive_udp_remote (void *cls __attribute__ ((unused)), - struct GNUNET_MESH_Tunnel *tunnel, - void **tunnel_ctx __attribute__ ((unused)), +receive_udp_remote (void *cls + __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, + void **tunnel_ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), const struct GNUNET_MessageHeader *message, @@ -1185,8 +1184,7 @@ receive_udp_remote (void *cls __attribute__ ((unused)), size_t len; GNUNET_assert (ntohs (pkt->len) == - ntohs (message->size) - - sizeof (struct GNUNET_MessageHeader) - + ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - sizeof (GNUNET_HashCode)); /* Prepare the state. @@ -1201,7 +1199,8 @@ receive_udp_remote (void *cls __attribute__ ((unused)), state->type = REMOTE; memcpy (&state->remote, s, sizeof (struct remote_addr)); - len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + + len = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + sizeof (struct ip6_hdr) + ntohs (pkt->len); buf = alloca (len); @@ -1249,9 +1248,10 @@ receive_udp_remote (void *cls __attribute__ ((unused)), * The messages are one GNUNET_HashCode for the service, followed by a struct udp_pkt */ static int -receive_udp_service (void *cls __attribute__ ((unused)), - struct GNUNET_MESH_Tunnel *tunnel, - void **tunnel_ctx __attribute__ ((unused)), +receive_udp_service (void *cls + __attribute__ ((unused)), + struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), const struct GNUNET_MessageHeader *message, @@ -1262,8 +1262,7 @@ receive_udp_service (void *cls __attribute__ ((unused)), struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); GNUNET_assert (ntohs (pkt->len) == - ntohs (message->size) - - sizeof (struct GNUNET_MessageHeader) - + ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - sizeof (GNUNET_HashCode)); /* Get the configuration from the hashmap */ @@ -1277,8 +1276,8 @@ receive_udp_service (void *cls __attribute__ ((unused)), if (NULL == serv) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "No service found for UDP dpt %d!\n", *udp_desc); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "No service found for UDP dpt %d!\n", + *udp_desc); return GNUNET_YES; } @@ -1304,7 +1303,8 @@ receive_udp_service (void *cls __attribute__ ((unused)), state->hashmap = udp_connections; memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); - len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + + len = + sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + sizeof (struct ip6_hdr) + ntohs (pkt->len); buf = alloca (len); @@ -1314,13 +1314,13 @@ receive_udp_service (void *cls __attribute__ ((unused)), { case 4: prepare_ipv4_packet (len, ntohs (pkt->len), pkt, 0x11, /* UDP */ - &serv->v4.ip4address, - tunnel, state, (struct ip_pkt *) buf); + &serv->v4.ip4address, tunnel, state, + (struct ip_pkt *) buf); break; case 6: prepare_ipv6_packet (len, ntohs (pkt->len), pkt, 0x11, /* UDP */ - &serv->v6.ip6address, - tunnel, state, (struct ip6_pkt *) buf); + &serv->v6.ip6address, tunnel, state, + (struct ip6_pkt *) buf); break; default: @@ -1410,9 +1410,7 @@ connect_to_mesh () * @param cfg_ configuration */ static void -run (void *cls, - char *const *args __attribute__ ((unused)), - const char *cfgfile +run (void *cls, char *const *args __attribute__ ((unused)), const char *cfgfile __attribute__ ((unused)), const struct GNUNET_CONFIGURATION_Handle *cfg_) { cfg = cfg_; @@ -1454,10 +1452,7 @@ main (int argc, char *const *argv) }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "exit", - gettext_noop ("help text"), + GNUNET_PROGRAM_run (argc, argv, "exit", gettext_noop ("help text"), options, &run, NULL)) ? ret : 1; } diff --git a/src/vpn/gnunet-daemon-vpn-dns.c b/src/vpn/gnunet-daemon-vpn-dns.c index d6f842e34..9ee81011e 100644 --- a/src/vpn/gnunet-daemon-vpn-dns.c +++ b/src/vpn/gnunet-daemon-vpn-dns.c @@ -120,7 +120,8 @@ send_query (void *cls __attribute__ ((unused)), size_t size, void *buf) * Connect to the service-dns */ void -connect_to_service_dns (void *cls __attribute__ ((unused)), +connect_to_service_dns (void *cls + __attribute__ ((unused)), const struct GNUNET_SCHEDULER_TaskContext *tc) { conn_task = GNUNET_SCHEDULER_NO_TASK; @@ -167,8 +168,9 @@ dns_answer_handler (void *cls { GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO); dns_connection = NULL; - conn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &connect_to_service_dns, NULL); + conn_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + &connect_to_service_dns, NULL); return; } diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c index 65e92b8f9..71fdefc0a 100644 --- a/src/vpn/gnunet-daemon-vpn-helper.c +++ b/src/vpn/gnunet-daemon-vpn-helper.c @@ -122,13 +122,10 @@ start_helper_and_schedule (void *cls, * When the helper dies, this function will be called again with the * helper_handle as cls. */ - helper_handle = start_helper (ifname, - ipv6addr, - ipv6prefix, - ipv4addr, - ipv4mask, - "vpn-gnunet", - start_helper_and_schedule, message_token, NULL); + helper_handle = + start_helper (ifname, ipv6addr, ipv6prefix, ipv4addr, ipv4mask, + "vpn-gnunet", start_helper_and_schedule, message_token, + NULL); GNUNET_free (ipv6addr); GNUNET_free (ipv6prefix); @@ -230,16 +227,15 @@ helper_write (void *cls /* if more packets are available, reschedule */ if (answer_proc_head != NULL) GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, - helper_handle->fh_to_helper, - &helper_write, NULL); + helper_handle->fh_to_helper, &helper_write, + NULL); } /** * Receive packets from the helper-process */ void -message_token (void *cls __attribute__ ((unused)), - void *client +message_token (void *cls __attribute__ ((unused)), void *client __attribute__ ((unused)), const struct GNUNET_MessageHeader *message) { @@ -274,17 +270,17 @@ message_token (void *cls __attribute__ ((unused)), size_t size = sizeof (struct GNUNET_MESH_Tunnel *) + - sizeof (struct GNUNET_MessageHeader) + - sizeof (GNUNET_HashCode) + ntohs (pkt6->ip6_hdr.paylgth); + sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + + ntohs (pkt6->ip6_hdr.paylgth); struct GNUNET_MESH_Tunnel **cls = GNUNET_malloc (size); struct GNUNET_MessageHeader *hdr = (struct GNUNET_MessageHeader *) (cls + 1); GNUNET_HashCode *hc = (GNUNET_HashCode *) (hdr + 1); - hdr->size = htons (sizeof (struct GNUNET_MessageHeader) + - sizeof (GNUNET_HashCode) + - ntohs (pkt6->ip6_hdr.paylgth)); + hdr->size = + htons (sizeof (struct GNUNET_MessageHeader) + + sizeof (GNUNET_HashCode) + ntohs (pkt6->ip6_hdr.paylgth)); GNUNET_MESH_ApplicationType app_type; @@ -295,21 +291,19 @@ message_token (void *cls __attribute__ ((unused)), /* This is a mapping to a gnunet-service */ memcpy (hc, &me->desc.service_descriptor, sizeof (GNUNET_HashCode)); - if (0x11 == pkt6->ip6_hdr.nxthdr - && (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)) - && (port_in_ports (me->desc.ports, pkt6_udp->udp_hdr.dpt) - || testBit (me->additional_ports, - ntohs (pkt6_udp->udp_hdr.dpt)))) + if (0x11 == pkt6->ip6_hdr.nxthdr && + (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)) && + (port_in_ports (me->desc.ports, pkt6_udp->udp_hdr.dpt) || + testBit (me->additional_ports, ntohs (pkt6_udp->udp_hdr.dpt)))) { hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP); memcpy (hc + 1, &pkt6_udp->udp_hdr, ntohs (pkt6_udp->udp_hdr.len)); } - else if (0x06 == pkt6->ip6_hdr.nxthdr - && (me->desc. - service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)) && - (port_in_ports (me->desc.ports, pkt6_tcp->tcp_hdr.dpt))) + else if (0x06 == pkt6->ip6_hdr.nxthdr && + (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)) + && (port_in_ports (me->desc.ports, pkt6_tcp->tcp_hdr.dpt))) { hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP); @@ -323,10 +317,10 @@ message_token (void *cls __attribute__ ((unused)), GNUNET_TIME_UNIT_FOREVER_REL, 1, (struct - GNUNET_PeerIdentity - *) &me->desc.peer, - send_pkt_to_peer, - NULL, cls); + GNUNET_PeerIdentity *) + &me->desc.peer, + send_pkt_to_peer, NULL, + cls); me->tunnel = *cls; } else if (NULL != cls) @@ -364,11 +358,12 @@ message_token (void *cls __attribute__ ((unused)), } if (me->tunnel == NULL && NULL != cls) { - *cls = GNUNET_MESH_peer_request_connect_by_type (mesh_handle, - GNUNET_TIME_UNIT_FOREVER_REL, - app_type, - send_pkt_to_peer, - NULL, cls); + *cls = + GNUNET_MESH_peer_request_connect_by_type (mesh_handle, + GNUNET_TIME_UNIT_FOREVER_REL, + app_type, + send_pkt_to_peer, + NULL, cls); me->tunnel = *cls; if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type) udp_tunnel = *cls; @@ -400,8 +395,8 @@ message_token (void *cls __attribute__ ((unused)), /* ICMPv6 */ pkt6_icmp = (struct ip6_icmp *) pkt6; /* If this packet is an icmp-echo-request and a mapping exists, answer */ - if (pkt6_icmp->icmp_hdr.type == 0x80 - && (key = address6_mapping_exists (pkt6->ip6_hdr.dadr)) != NULL) + if (pkt6_icmp->icmp_hdr.type == 0x80 && + (key = address6_mapping_exists (pkt6->ip6_hdr.dadr)) != NULL) { GNUNET_free (key); pkt6_icmp = GNUNET_malloc (ntohs (pkt6->shdr.size)); @@ -442,8 +437,7 @@ message_token (void *cls __attribute__ ((unused)), GNUNET_assert (head != NULL); if (dns_connection != NULL) - GNUNET_CLIENT_notify_transmit_ready (dns_connection, - len, + GNUNET_CLIENT_notify_transmit_ready (dns_connection, len, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); } @@ -470,9 +464,8 @@ message_token (void *cls __attribute__ ((unused)), size_t size = sizeof (struct GNUNET_MESH_Tunnel *) + - sizeof (struct GNUNET_MessageHeader) + - sizeof (GNUNET_HashCode) + ntohs (pkt->ip_hdr.tot_lngth) - - 4 * pkt->ip_hdr.hdr_lngth; + sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + + ntohs (pkt->ip_hdr.tot_lngth) - 4 * pkt->ip_hdr.hdr_lngth; struct GNUNET_MESH_Tunnel **cls = GNUNET_malloc (size); struct GNUNET_MessageHeader *hdr = @@ -493,20 +486,19 @@ message_token (void *cls __attribute__ ((unused)), /* This is a mapping to a gnunet-service */ memcpy (hc, &me->desc.service_descriptor, sizeof (GNUNET_HashCode)); - if (0x11 == pkt->ip_hdr.proto - && (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)) - && (port_in_ports (me->desc.ports, pkt_udp->udp_hdr.dpt) - || testBit (me->additional_ports, - ntohs (pkt_udp->udp_hdr.dpt)))) + if (0x11 == pkt->ip_hdr.proto && + (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)) && + (port_in_ports (me->desc.ports, pkt_udp->udp_hdr.dpt) || + testBit (me->additional_ports, ntohs (pkt_udp->udp_hdr.dpt)))) { hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP); memcpy (hc + 1, &pkt_udp->udp_hdr, ntohs (pkt_udp->udp_hdr.len)); } - else if (0x06 == pkt->ip_hdr.proto - && (me->desc.service_type & - htonl (GNUNET_DNS_SERVICE_TYPE_TCP)) && + else if (0x06 == pkt->ip_hdr.proto && + (me->desc. + service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)) && (port_in_ports (me->desc.ports, pkt_tcp->tcp_hdr.dpt))) { hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP); @@ -523,10 +515,10 @@ message_token (void *cls __attribute__ ((unused)), GNUNET_TIME_UNIT_FOREVER_REL, 1, (struct - GNUNET_PeerIdentity - *) &me->desc.peer, - send_pkt_to_peer, - NULL, cls); + GNUNET_PeerIdentity *) + &me->desc.peer, + send_pkt_to_peer, NULL, + cls); me->tunnel = *cls; } else if (NULL != cls) @@ -563,11 +555,12 @@ message_token (void *cls __attribute__ ((unused)), } if (me->tunnel == NULL && NULL != cls) { - *cls = GNUNET_MESH_peer_request_connect_by_type (mesh_handle, - GNUNET_TIME_UNIT_FOREVER_REL, - app_type, - send_pkt_to_peer, - NULL, cls); + *cls = + GNUNET_MESH_peer_request_connect_by_type (mesh_handle, + GNUNET_TIME_UNIT_FOREVER_REL, + app_type, + send_pkt_to_peer, + NULL, cls); me->tunnel = *cls; } else if (NULL != cls) diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 3673b72c6..301ba90be 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c @@ -332,8 +332,7 @@ port_in_ports (uint64_t ports, uint16_t port) } void -send_pkt_to_peer (void *cls, - const struct GNUNET_PeerIdentity *peer, +send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_ATS_Information *atsi __attribute__ ((unused))) { @@ -429,8 +428,8 @@ new_ip6addr_remote (unsigned char *buf, unsigned char *addr, char addrlen) unsigned long long ipv6prefix; GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", - "IPV6ADDR", &ipv6addr)); + GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV6ADDR", + &ipv6addr)); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "vpn", "IPV6PREFIX", @@ -458,11 +457,11 @@ new_ip4addr_remote (unsigned char *buf, unsigned char *addr, char addrlen) char *ipv4mask; GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", - "IPV4ADDR", &ipv4addr)); + GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4ADDR", + &ipv4addr)); GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", - "IPV4MASK", &ipv4mask)); + GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "IPV4MASK", + &ipv4mask)); uint32_t mask; inet_pton (AF_INET, ipv4addr, buf); @@ -568,9 +567,9 @@ process_answer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CONTAINER_multihashmap_put (hashmap, &key, value, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); - value->heap_node = GNUNET_CONTAINER_heap_insert (heap, value, - GNUNET_TIME_absolute_get - ().abs_value); + value->heap_node = + GNUNET_CONTAINER_heap_insert (heap, value, + GNUNET_TIME_absolute_get ().abs_value); if (GNUNET_CONTAINER_heap_get_size (heap) > max_mappings) GNUNET_SCHEDULER_add_now (collect_mappings, NULL); } @@ -696,9 +695,9 @@ process_answer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_CONTAINER_multihashmap_put (hashmap, &key, value, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); - value->heap_node = GNUNET_CONTAINER_heap_insert (heap, value, - GNUNET_TIME_absolute_get - ().abs_value); + value->heap_node = + GNUNET_CONTAINER_heap_insert (heap, value, + GNUNET_TIME_absolute_get ().abs_value); if (GNUNET_CONTAINER_heap_get_size (heap) > max_mappings) GNUNET_SCHEDULER_add_now (collect_mappings, NULL); } @@ -722,8 +721,8 @@ process_answer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) unsigned char *c = ((unsigned char *) pkt) + ntohs (pkt->addroffset); new_ip4addr_remote (c, pkt->addr, pkt->addrsize); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New mapping to %d.%d.%d.%d\n", - c[0], c[1], c[2], c[3]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New mapping to %d.%d.%d.%d\n", c[0], + c[1], c[2], c[3]); unsigned char *k = (unsigned char *) &key; /* @@ -755,9 +754,9 @@ process_answer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_CONTAINER_multihashmap_put (hashmap, &key, value, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); - value->heap_node = GNUNET_CONTAINER_heap_insert (heap, value, - GNUNET_TIME_absolute_get - ().abs_value); + value->heap_node = + GNUNET_CONTAINER_heap_insert (heap, value, + GNUNET_TIME_absolute_get ().abs_value); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Mapping is saved in the hashmap with key %08x.\n", *((uint32_t *) (&key))); @@ -860,7 +859,8 @@ add_additional_port (struct map_entry *me, uint16_t port) static int receive_udp_back (void *cls __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, - void **tunnel_ctx __attribute__ ((unused)), + void **tunnel_ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), const struct GNUNET_MessageHeader *message, @@ -931,8 +931,8 @@ receive_udp_back (void *cls GNUNET_assert (me != NULL); if (ntohs (message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP_BACK) { - GNUNET_assert (me->desc. - service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)); + GNUNET_assert (me-> + desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)); if (!port_in_ports (me->desc.ports, pkt6->udp_hdr.spt) && !testBit (me->additional_ports, ntohs (pkt6->udp_hdr.spt))) { @@ -1109,8 +1109,8 @@ receive_tcp_back (void *cls GNUNET_assert (me != NULL); if (ntohs (message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP_BACK) - GNUNET_assert (me->desc. - service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)); + GNUNET_assert (me-> + desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)); pkt6->tcp_hdr.crc = 0; uint32_t sum = 0; @@ -1228,10 +1228,8 @@ receive_tcp_back (void *cls * @param cfg_ configuration */ static void -run (void *cls, - char *const *args __attribute__ ((unused)), - const char *cfgfilep __attribute__ ((unused)), - const struct GNUNET_CONFIGURATION_Handle *cfg_) +run (void *cls, char *const *args __attribute__ ((unused)), const char *cfgfilep + __attribute__ ((unused)), const struct GNUNET_CONFIGURATION_Handle *cfg_) { static const struct GNUNET_MESH_MessageHandler handlers[] = { {receive_udp_back, GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP_BACK, 0}, @@ -1274,10 +1272,7 @@ main (int argc, char *const *argv) }; return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, - argv, - "vpn", - gettext_noop ("help text"), + GNUNET_PROGRAM_run (argc, argv, "vpn", gettext_noop ("help text"), options, &run, NULL)) ? ret : 1; } diff --git a/src/vpn/gnunet-dns-parser.c b/src/vpn/gnunet-dns-parser.c index 70551af52..df0e63ed7 100644 --- a/src/vpn/gnunet-dns-parser.c +++ b/src/vpn/gnunet-dns-parser.c @@ -51,8 +51,8 @@ parse_dns_name (char *d, const unsigned char *src, unsigned short idx) */ static unsigned short parse_dns_record (unsigned char *data, /*{{{ */ - struct dns_record **dst, - unsigned short count, unsigned short idx) + struct dns_record **dst, unsigned short count, + unsigned short idx) { int i; unsigned short _idx; diff --git a/src/vpn/gnunet-helper-vpn-api.c b/src/vpn/gnunet-helper-vpn-api.c index 16bfcbd2e..379e75765 100644 --- a/src/vpn/gnunet-helper-vpn-api.c +++ b/src/vpn/gnunet-helper-vpn-api.c @@ -74,8 +74,9 @@ helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tsdkctx) stop_helper (handle); /* Restart the helper */ - shs_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - handle->restart_task, handle); + shs_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + handle->restart_task, handle); return; } @@ -86,8 +87,9 @@ helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tsdkctx) stop_helper (handle); /* Restart the helper */ - shs_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - handle->restart_task, handle); + shs_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + handle->restart_task, handle); return; } @@ -104,12 +106,9 @@ cleanup_helper (struct GNUNET_VPN_HELPER_Handle *handle) } struct GNUNET_VPN_HELPER_Handle * -start_helper (const char *ifname, - const char *ipv6addr, - const char *ipv6prefix, - const char *ipv4addr, - const char *ipv4mask, const char *process_name, - GNUNET_SCHEDULER_Task restart_task, +start_helper (const char *ifname, const char *ipv6addr, const char *ipv6prefix, + const char *ipv4addr, const char *ipv4mask, + const char *process_name, GNUNET_SCHEDULER_Task restart_task, GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls) { struct GNUNET_VPN_HELPER_Handle *handle = diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c index 698c46f1d..ed97770cf 100644 --- a/src/vpn/gnunet-helper-vpn.c +++ b/src/vpn/gnunet-helper-vpn.c @@ -81,8 +81,8 @@ init_tun (char *dev) if (-1 == (fd = open ("/dev/net/tun", O_RDWR))) { - fprintf (stderr, - "Error opening `%s': %s\n", "/dev/net/tun", strerror (errno)); + fprintf (stderr, "Error opening `%s': %s\n", "/dev/net/tun", + strerror (errno)); return -1; } @@ -100,9 +100,8 @@ init_tun (char *dev) if (-1 == ioctl (fd, TUNSETIFF, (void *) &ifr)) { - fprintf (stderr, - "Error with ioctl on `%s': %s\n", - "/dev/net/tun", strerror (errno)); + fprintf (stderr, "Error with ioctl on `%s': %s\n", "/dev/net/tun", + strerror (errno)); close (fd); return -1; } @@ -132,8 +131,8 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) memset (&sa6, 0, sizeof (struct sockaddr_in6)); if (1 != inet_pton (AF_INET6, address, sa6.sin6_addr.s6_addr)) { - fprintf (stderr, - "Failed to parse address `%s': %s\n", address, strerror (errno)); + fprintf (stderr, "Failed to parse address `%s': %s\n", address, + strerror (errno)); exit (1); } @@ -165,8 +164,8 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) */ if (-1 == ioctl (fd, SIOCSIFADDR, &ifr6)) { - fprintf (stderr, - "ioctl failed at line %d: %s\n", __LINE__, strerror (errno)); + fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__, + strerror (errno)); exit (1); } @@ -175,8 +174,8 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) */ if (-1 == ioctl (fd, SIOCGIFFLAGS, &ifr)) { - fprintf (stderr, - "ioctl failed at line %d: %s\n", __LINE__, strerror (errno)); + fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__, + strerror (errno)); exit (1); } @@ -186,8 +185,8 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) ifr.ifr_flags |= IFF_UP | IFF_RUNNING; if (-1 == ioctl (fd, SIOCSIFFLAGS, &ifr)) { - fprintf (stderr, - "ioctl failed at line %d: %s\n", __LINE__, strerror (errno)); + fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__, + strerror (errno)); exit (1); } @@ -224,8 +223,8 @@ set_address4 (const char *dev, const char *address, const char *mask) */ if (1 != inet_pton (AF_INET, address, &addr->sin_addr.s_addr)) { - fprintf (stderr, - "Failed to parse address `%s': %s\n", address, strerror (errno)); + fprintf (stderr, "Failed to parse address `%s': %s\n", address, + strerror (errno)); exit (1); } @@ -253,8 +252,8 @@ set_address4 (const char *dev, const char *address, const char *mask) addr = (struct sockaddr_in *) &(ifr.ifr_netmask); if (1 != inet_pton (AF_INET, mask, &addr->sin_addr.s_addr)) { - fprintf (stderr, - "Failed to parse address `%s': %s\n", mask, strerror (errno)); + fprintf (stderr, "Failed to parse address `%s': %s\n", mask, + strerror (errno)); exit (1); } @@ -263,8 +262,8 @@ set_address4 (const char *dev, const char *address, const char *mask) */ if (-1 == ioctl (fd, SIOCSIFNETMASK, &ifr)) { - fprintf (stderr, - "ioctl failed at line %d: %s\n", __LINE__, strerror (errno)); + fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__, + strerror (errno)); exit (1); } @@ -273,8 +272,8 @@ set_address4 (const char *dev, const char *address, const char *mask) */ if (-1 == ioctl (fd, SIOCGIFFLAGS, &ifr)) { - fprintf (stderr, - "ioctl failed at line %d: %s\n", __LINE__, strerror (errno)); + fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__, + strerror (errno)); exit (1); } @@ -284,8 +283,8 @@ set_address4 (const char *dev, const char *address, const char *mask) ifr.ifr_flags |= IFF_UP | IFF_RUNNING; if (-1 == ioctl (fd, SIOCSIFFLAGS, &ifr)) { - fprintf (stderr, - "ioctl failed at line %d: %s\n", __LINE__, strerror (errno)); + fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__, + strerror (errno)); exit (1); } @@ -545,8 +544,8 @@ main (int argc, char **argv) if (0 != setresuid (uid, uid, uid)) fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno)); if (SIG_ERR == signal (SIGPIPE, SIG_IGN)) - fprintf (stderr, - "Failed to protect against SIGPIPE: %s\n", strerror (errno)); + fprintf (stderr, "Failed to protect against SIGPIPE: %s\n", + strerror (errno)); run (fd_tun); close (fd_tun); return 0; diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index 9959e9564..a267cab0d 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -146,11 +146,10 @@ hijack (void *cls GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", dnsoutport); snprintf (port_s, 6, "%d", dnsoutport); - if (NULL != (proc = GNUNET_OS_start_process (NULL, - NULL, - "gnunet-helper-hijack-dns", - "gnunet-hijack-dns", - port_s, virt_dns, NULL))) + if (NULL != + (proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-hijack-dns", + "gnunet-hijack-dns", port_s, virt_dns, NULL))) GNUNET_OS_process_close (proc); GNUNET_free (virt_dns); } @@ -175,11 +174,11 @@ unhijack (unsigned short port) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "unHijacking, port is %d\n", port); snprintf (port_s, 6, "%d", port); - if (NULL != (proc = GNUNET_OS_start_process (NULL, - NULL, - "gnunet-helper-hijack-dns", - "gnunet-hijack-dns", - "-d", port_s, virt_dns, NULL))) + if (NULL != + (proc = + GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-hijack-dns", + "gnunet-hijack-dns", "-d", port_s, virt_dns, + NULL))) GNUNET_OS_process_close (proc); GNUNET_free (virt_dns); } @@ -204,8 +203,7 @@ send_answer (void *cls, size_t size, void *buf) /* When more data is to be sent, reschedule */ if (head != NULL) - GNUNET_SERVER_notify_transmit_ready (cls, - ntohs (head->pkt.hdr.size), + GNUNET_SERVER_notify_transmit_ready (cls, ntohs (head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, cls); @@ -371,19 +369,20 @@ send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct tunnel_cls *cls_ = (struct tunnel_cls *) cls; - cls_->tunnel = GNUNET_MESH_peer_request_connect_by_type (mesh_handle, - GNUNET_TIME_UNIT_HOURS, - GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, - mesh_connect, - NULL, cls_); + cls_->tunnel = + GNUNET_MESH_peer_request_connect_by_type (mesh_handle, + GNUNET_TIME_UNIT_HOURS, + GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, + mesh_connect, NULL, cls_); remote_pending[cls_->dns.s.id] = cls_; } static int -receive_mesh_query (void *cls __attribute__ ((unused)), - struct GNUNET_MESH_Tunnel *tunnel, - void **ctx __attribute__ ((unused)), +receive_mesh_query (void *cls + __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, + void **ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), const struct GNUNET_MessageHeader *message, @@ -404,8 +403,7 @@ receive_mesh_query (void *cls __attribute__ ((unused)), query_states[dns->s.id].tunnel = tunnel; query_states[dns->s.id].valid = GNUNET_YES; - GNUNET_NETWORK_socket_sendto (dnsout, - dns, + GNUNET_NETWORK_socket_sendto (dnsout, dns, ntohs (message->size) - sizeof (struct GNUNET_MessageHeader), (struct sockaddr *) &dest, sizeof dest); @@ -414,9 +412,10 @@ receive_mesh_query (void *cls __attribute__ ((unused)), } static int -receive_mesh_answer (void *cls __attribute__ ((unused)), - struct GNUNET_MESH_Tunnel *tunnel, - void **ctx __attribute__ ((unused)), +receive_mesh_answer (void *cls + __attribute__ ((unused)), + struct GNUNET_MESH_Tunnel *tunnel, void **ctx + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *sender, const struct GNUNET_MessageHeader *message, const struct GNUNET_TRANSPORT_ATS_Information *atsi @@ -426,8 +425,8 @@ receive_mesh_answer (void *cls __attribute__ ((unused)), struct dns_pkt *dns = (struct dns_pkt *) (message + 1); /* They sent us a packet we were not waiting for */ - if (remote_pending[dns->s.id] == NULL - || remote_pending[dns->s.id]->tunnel != tunnel) + if (remote_pending[dns->s.id] == NULL || + remote_pending[dns->s.id]->tunnel != tunnel) return GNUNET_OK; GNUNET_free (remote_pending[dns->s.id]); @@ -526,8 +525,7 @@ receive_mesh_answer (void *cls __attribute__ ((unused)), GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); - GNUNET_SERVER_notify_transmit_ready (query_states[dns->s.id].client, - len, + GNUNET_SERVER_notify_transmit_ready (query_states[dns->s.id].client, len, GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, query_states[dns->s.id].client); @@ -561,8 +559,8 @@ send_rev_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) size_t len = sizeof (struct answer_packet) - 1 + sizeof (struct dns_static) + 74 /* this is the length of a reverse ipv6-lookup */ + sizeof (struct dns_query_line) + 2 /* To hold the pointer (as defined in RFC1035) to the name */ - + sizeof (struct dns_record_line) - 1 - - 2 /* We do not know the lenght of the answer yet */ ; + + sizeof (struct dns_record_line) - 1 - + 2 /* We do not know the lenght of the answer yet */ ; struct answer_packet_list *answer = GNUNET_malloc (len + 2 * sizeof (struct answer_packet_list *)); @@ -619,8 +617,7 @@ send_rev_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); - GNUNET_SERVER_notify_transmit_ready (query_states[id].client, - len, + GNUNET_SERVER_notify_transmit_ready (query_states[id].client, len, GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, query_states[id].client); } @@ -629,9 +626,9 @@ send_rev_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * Receive a block from the dht. */ static void -receive_dht (void *cls, - struct GNUNET_TIME_Absolute exp __attribute__ ((unused)), - const GNUNET_HashCode * key __attribute__ ((unused)), +receive_dht (void *cls, struct GNUNET_TIME_Absolute exp + __attribute__ ((unused)), const GNUNET_HashCode * key + __attribute__ ((unused)), const struct GNUNET_PeerIdentity *const *get_path __attribute__ ((unused)), const struct GNUNET_PeerIdentity *const *put_path @@ -654,8 +651,7 @@ receive_dht (void *cls, const struct GNUNET_DNS_Record *rec = data; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Got block of size %d, peer: %08x, desc: %08x\n", - size, + "Got block of size %d, peer: %08x, desc: %08x\n", size, *((unsigned int *) &rec->peer), *((unsigned int *) &rec->service_descriptor)); @@ -676,8 +672,8 @@ receive_dht (void *cls, memcpy (&answer->pkt.service_descr.service_descriptor, &rec->service_descriptor, sizeof (GNUNET_HashCode)); - memcpy (&answer->pkt.service_descr.service_type, - &rec->service_type, sizeof (answer->pkt.service_descr.service_type)); + memcpy (&answer->pkt.service_descr.service_type, &rec->service_type, + sizeof (answer->pkt.service_descr.service_type)); memcpy (&answer->pkt.service_descr.ports, &rec->ports, sizeof (answer->pkt.service_descr.ports)); @@ -730,8 +726,7 @@ receive_dht (void *cls, GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); - GNUNET_SERVER_notify_transmit_ready (query_states[id].client, - len, + GNUNET_SERVER_notify_transmit_ready (query_states[id].client, len, GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, query_states[id].client); @@ -742,8 +737,8 @@ receive_dht (void *cls, * This receives a GNUNET_MESSAGE_TYPE_REHIJACK and rehijacks the DNS */ static void -rehijack (void *cls __attribute__ ((unused)), - struct GNUNET_SERVER_Client *client, +rehijack (void *cls + __attribute__ ((unused)), struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message __attribute__ ((unused))) { unhijack (dnsoutport); @@ -756,8 +751,8 @@ rehijack (void *cls __attribute__ ((unused)), * This receives the dns-payload from the daemon-vpn and sends it on over the udp-socket */ static void -receive_query (void *cls __attribute__ ((unused)), - struct GNUNET_SERVER_Client *client, +receive_query (void *cls + __attribute__ ((unused)), struct GNUNET_SERVER_Client *client, const struct GNUNET_MessageHeader *message) { struct query_packet *pkt = (struct query_packet *) message; @@ -788,21 +783,18 @@ receive_query (void *cls __attribute__ ((unused)), GNUNET_CRYPTO_hash (pdns->queries[0]->name, pdns->queries[0]->namelen, &key); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Getting with key %08x, len is %d\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting with key %08x, len is %d\n", *((unsigned int *) &key), pdns->queries[0]->namelen); struct receive_dht_cls *cls = GNUNET_malloc (sizeof (struct receive_dht_cls)); cls->id = dns->s.id; - cls->handle = GNUNET_DHT_get_start (dht, - GNUNET_TIME_UNIT_MINUTES, - GNUNET_BLOCK_TYPE_DNS, - &key, - DEFAULT_GET_REPLICATION, - GNUNET_DHT_RO_NONE, - NULL, 0, NULL, 0, receive_dht, cls); + cls->handle = + GNUNET_DHT_get_start (dht, GNUNET_TIME_UNIT_MINUTES, + GNUNET_BLOCK_TYPE_DNS, &key, + DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, + 0, NULL, 0, receive_dht, cls); goto outfree; } @@ -881,8 +873,8 @@ receive_query (void *cls __attribute__ ((unused)), if (1 != inet_pton (AF_INET, virt_dns, &virt_dns_bytes)) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Error parsing 'VIRTDNS': %s; %m!\n", virt_dns); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error parsing 'VIRTDNS': %s; %m!\n", + virt_dns); exit (1); } @@ -923,8 +915,7 @@ receive_query (void *cls __attribute__ ((unused)), dest.sin_port = htons (53); dest.sin_addr.s_addr = pkt->orig_to; - GNUNET_NETWORK_socket_sendto (dnsout, - dns, + GNUNET_NETWORK_socket_sendto (dnsout, dns, ntohs (pkt->hdr.size) - sizeof (struct query_packet) + 1, (struct sockaddr *) &dest, sizeof dest); @@ -963,8 +954,9 @@ open_port () /* Read the port we bound to */ socklen_t addrlen = sizeof (struct sockaddr_in); - err = getsockname (GNUNET_NETWORK_get_fd (dnsout), - (struct sockaddr *) &addr, &addrlen); + err = + getsockname (GNUNET_NETWORK_get_fd (dnsout), (struct sockaddr *) &addr, + &addrlen); dnsoutport = htons (addr.sin_port); @@ -1010,9 +1002,7 @@ read_response (void *cls unsigned char buf[len]; struct dns_pkt *dns = (struct dns_pkt *) buf; - r = GNUNET_NETWORK_socket_recvfrom (dnsout, - buf, - sizeof (buf), + r = GNUNET_NETWORK_socket_recvfrom (dnsout, buf, sizeof (buf), (struct sockaddr *) &addr, &addrlen); if (r < 0) @@ -1093,16 +1083,15 @@ read_response (void *cls GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); - GNUNET_SERVER_notify_transmit_ready (query_states - [dns->s.id].client, len, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SERVER_notify_transmit_ready (query_states[dns->s.id].client, + len, GNUNET_TIME_UNIT_FOREVER_REL, &send_answer, query_states[dns->s.id].client); } } } - GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, - dnsout, &read_response, NULL); + GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, dnsout, + &read_response, NULL); } @@ -1113,7 +1102,8 @@ read_response (void *cls * @param tc unused */ static void -cleanup_task (void *cls __attribute__ ((unused)), +cleanup_task (void *cls + __attribute__ ((unused)), const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); @@ -1236,23 +1226,18 @@ publish_name (const char *name, uint64_t ports, uint32_t service_type, (GNUNET_TIME_UNIT_HOURS, 2)); /* Sign the block */ - if (GNUNET_OK != GNUNET_CRYPTO_rsa_sign (my_private_key, - &data.purpose, &data.signature)) + if (GNUNET_OK != + GNUNET_CRYPTO_rsa_sign (my_private_key, &data.purpose, &data.signature)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not sign DNS_Record\n"); return; } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Putting with key %08x, size = %d\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting with key %08x, size = %d\n", *((unsigned int *) &data.service_descriptor), size); - GNUNET_DHT_put (dht, - &data.service_descriptor, - DEFAULT_PUT_REPLICATION, - GNUNET_DHT_RO_NONE, - GNUNET_BLOCK_TYPE_DNS, - size, + GNUNET_DHT_put (dht, &data.service_descriptor, DEFAULT_PUT_REPLICATION, + GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_DNS, size, (char *) &data, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS), GNUNET_TIME_UNIT_MINUTES, NULL, NULL); @@ -1276,14 +1261,14 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section) char *udp_redirects, *tcp_redirects, *alternative_names, *alternative_name, *keyfile; - GNUNET_CONFIGURATION_get_value_string (cfg, section, - "UDP_REDIRECTS", &udp_redirects); + GNUNET_CONFIGURATION_get_value_string (cfg, section, "UDP_REDIRECTS", + &udp_redirects); GNUNET_CONFIGURATION_get_value_string (cfg, section, "TCP_REDIRECTS", &tcp_redirects); - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", - "HOSTKEY", - &keyfile)) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", + &keyfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not read keyfile-value\n"); if (keyfile != NULL) @@ -1310,8 +1295,7 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section) publish_name (section, ports, service_type, my_private_key); - GNUNET_CONFIGURATION_get_value_string (cfg, section, - "ALTERNATIVE_NAMES", + GNUNET_CONFIGURATION_get_value_string (cfg, section, "ALTERNATIVE_NAMES", &alternative_names); for (alternative_name = strtok (alternative_names, " "); alternative_name != NULL; alternative_name = strtok (NULL, " ")) @@ -1335,7 +1319,8 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section) * Publish a DNS-record in the DHT. */ static void -publish_names (void *cls __attribute__ ((unused)), +publish_names (void *cls + __attribute__ ((unused)), const struct GNUNET_SCHEDULER_TaskContext *tc) { if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) @@ -1352,8 +1337,7 @@ publish_names (void *cls __attribute__ ((unused)), * @param cfg_ configuration to use */ static void -run (void *cls, - struct GNUNET_SERVER_Handle *server, +run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *cfg_) { static const struct GNUNET_SERVER_MessageHandler handlers[] = { @@ -1401,8 +1385,8 @@ run (void *cls, GNUNET_SCHEDULER_add_now (publish_names, NULL); GNUNET_SERVER_add_handlers (server, handlers); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &cleanup_task, cls); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, + cls); } /** @@ -1416,8 +1400,6 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "dns", - GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, argv, "dns", GNUNET_SERVICE_OPTION_NONE, + &run, NULL)) ? 0 : 1; } -- 2.25.1