summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ats-test/test_transport_ats_multiple_peers.c3
-rw-r--r--src/ats/ats.h53
-rw-r--r--src/ats/ats_api.c160
-rw-r--r--src/ats/ats_api_peer_change_preference.c51
-rw-r--r--src/ats/ats_api_performance.c225
-rw-r--r--src/ats/ats_api_scheduling.c302
-rw-r--r--src/ats/gnunet-service-ats.c49
-rw-r--r--src/ats/gnunet-service-ats_addresses.c236
-rw-r--r--src/ats/gnunet-service-ats_addresses.h20
-rw-r--r--src/ats/gnunet-service-ats_math.h9
-rw-r--r--src/ats/gnunet-service-ats_performance.c109
-rw-r--r--src/ats/gnunet-service-ats_performance.h20
-rw-r--r--src/ats/gnunet-service-ats_reservations.c56
-rw-r--r--src/ats/gnunet-service-ats_reservations.h7
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c177
-rw-r--r--src/ats/gnunet-service-ats_scheduling.h27
-rw-r--r--src/ats/test_ats_api_bandwidth_consumption.c131
-rw-r--r--src/ats/test_ats_api_scheduling.c105
-rw-r--r--src/ats/test_ats_api_update_address.c3
-rw-r--r--src/block/block.c25
-rw-r--r--src/block/plugin_block_dht.c24
-rw-r--r--src/block/plugin_block_dns.c3
-rw-r--r--src/block/plugin_block_fs.c48
-rw-r--r--src/block/plugin_block_test.c14
-rw-r--r--src/chat/gnunet-service-chat.c27
-rw-r--r--src/core/core_api.c29
-rw-r--r--src/core/core_api_iterate_peers.c6
-rw-r--r--src/core/gnunet-core-list-connections.c2
-rw-r--r--src/core/gnunet-service-core.c8
-rw-r--r--src/core/gnunet-service-core.h2
-rw-r--r--src/core/gnunet-service-core_clients.c281
-rw-r--r--src/core/gnunet-service-core_clients.h39
-rw-r--r--src/core/gnunet-service-core_kx.c378
-rw-r--r--src/core/gnunet-service-core_kx.h25
-rw-r--r--src/core/gnunet-service-core_neighbours.c58
-rw-r--r--src/core/gnunet-service-core_neighbours.h6
-rw-r--r--src/core/gnunet-service-core_sessions.c242
-rw-r--r--src/core/gnunet-service-core_sessions.h25
-rw-r--r--src/core/gnunet-service-core_typemap.c60
-rw-r--r--src/core/gnunet-service-core_typemap.h20
-rw-r--r--src/core/test_core_api.c23
-rw-r--r--src/core/test_core_api_reliability.c19
-rw-r--r--src/core/test_core_api_send_to_self.c4
-rw-r--r--src/core/test_core_api_start_only.c15
-rw-r--r--src/core/test_core_quota_compliance.c76
-rw-r--r--src/datacache/datacache.c14
-rw-r--r--src/datacache/plugin_datacache_sqlite.c85
-rw-r--r--src/datastore/plugin_datastore_sqlite.c30
-rw-r--r--src/datastore/test_datastore_api.c6
-rw-r--r--src/dht/dht_api.c52
-rw-r--r--src/dht/gnunet-dht-get.c12
-rw-r--r--src/dht/gnunet-dht-put.c6
-rw-r--r--src/dht/gnunet-service-dht.c44
-rw-r--r--src/dht/gnunet-service-dht_clients.c491
-rw-r--r--src/dht/gnunet-service-dht_clients.h17
-rw-r--r--src/dht/gnunet-service-dht_datacache.c121
-rw-r--r--src/dht/gnunet-service-dht_datacache.h28
-rw-r--r--src/dht/gnunet-service-dht_hello.c36
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c982
-rw-r--r--src/dht/gnunet-service-dht_neighbours.h52
-rw-r--r--src/dht/gnunet-service-dht_nse.c10
-rw-r--r--src/dht/gnunet-service-dht_routing.c144
-rw-r--r--src/dht/gnunet-service-dht_routing.h27
-rw-r--r--src/dht/test_dht_2dtorus.c208
-rw-r--r--src/dht/test_dht_api.c16
-rw-r--r--src/dht/test_dht_multipeer.c210
-rw-r--r--src/dht/test_dht_twopeer.c30
-rw-r--r--src/dht/test_dht_twopeer_get_put.c22
-rw-r--r--src/dht/test_dht_twopeer_path_tracking.c24
-rw-r--r--src/dht/test_dht_twopeer_put_get.c21
-rw-r--r--src/dv/gnunet-service-dv.c40
-rw-r--r--src/dv/plugin_transport_dv.c4
-rw-r--r--src/dv/test_transport_api_dv.c12
-rw-r--r--src/fragmentation/fragmentation.c2
-rw-r--r--src/fragmentation/test_fragmentation.c8
-rw-r--r--src/fs/fs_file_information.c112
-rw-r--r--src/fs/fs_uri.c22
-rw-r--r--src/fs/gnunet-fs.c27
-rw-r--r--src/fs/gnunet-service-fs.c42
-rw-r--r--src/fs/gnunet-service-fs_cp.c85
-rw-r--r--src/fs/gnunet-service-fs_cp.h7
-rw-r--r--src/fs/gnunet-service-fs_indexing.c9
-rw-r--r--src/fs/gnunet-service-fs_lc.c3
-rw-r--r--src/fs/gnunet-service-fs_pe.c90
-rw-r--r--src/fs/gnunet-service-fs_pr.c91
-rw-r--r--src/fs/gnunet-service-fs_pr.h4
-rw-r--r--src/fs/gnunet-service-fs_put.c6
-rw-r--r--src/hello/hello.c4
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c4
-rw-r--r--src/hostlist/hostlist-client.c4
-rw-r--r--src/hostlist/hostlist-server.c2
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c3
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c6
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_reconnect.c3
-rw-r--r--src/include/gnunet_ats_service.h185
-rw-r--r--src/include/gnunet_block_lib.h4
-rw-r--r--src/include/gnunet_common.h8
-rw-r--r--src/include/gnunet_core_service.h14
-rw-r--r--src/include/gnunet_dht_service.h11
-rw-r--r--src/include/gnunet_mesh_service.h8
-rw-r--r--src/include/gnunet_plugin_lib.h14
-rw-r--r--src/include/gnunet_server_lib.h3
-rw-r--r--src/include/gnunet_strings_lib.h4
-rw-r--r--src/include/gnunet_transport_service.h10
-rw-r--r--src/mesh/gnunet-service-mesh.c905
-rw-r--r--src/mesh/mesh_api.c40
-rw-r--r--src/mesh/mesh_protocol.h2
-rw-r--r--src/mesh/mesh_tunnel_tree.c334
-rw-r--r--src/mesh/mesh_tunnel_tree.h49
-rw-r--r--src/mesh/test_mesh_api.c3
-rw-r--r--src/mesh/test_mesh_local_2.c7
-rw-r--r--src/mesh/test_mesh_small.c335
-rw-r--r--src/mesh/test_mesh_small_unicast_far.c111
-rw-r--r--src/mesh/test_mesh_tree_api.c142
-rw-r--r--src/nat/nat.c6
-rw-r--r--src/nat/test_nat_test.c3
-rw-r--r--src/nse/gnunet-nse-profiler.c12
-rw-r--r--src/nse/gnunet-service-nse.c17
-rw-r--r--src/statistics/statistics_api.c702
-rw-r--r--src/testing/test_testing_connect.c6
-rw-r--r--src/testing/test_testing_reconnect.c12
-rw-r--r--src/testing/test_testing_topology.c11
-rw-r--r--src/testing/testing.c7
-rw-r--r--src/testing/testing_group.c25
-rw-r--r--src/testing/testing_peergroup.c7
-rw-r--r--src/topology/gnunet-daemon-topology.c13
-rw-r--r--src/transport/gnunet-service-transport.c146
-rw-r--r--src/transport/gnunet-service-transport_blacklist.c4
-rw-r--r--src/transport/gnunet-service-transport_clients.c46
-rw-r--r--src/transport/gnunet-service-transport_hello.c3
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c886
-rw-r--r--src/transport/gnunet-service-transport_neighbours.h68
-rw-r--r--src/transport/gnunet-service-transport_validation.c53
-rw-r--r--src/transport/gnunet-transport-connect-running-peers.c24
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c4
-rw-r--r--src/transport/gnunet-transport.c242
-rw-r--r--src/transport/gnunet_wlan_sender.c254
-rw-r--r--src/transport/plugin_transport_http.c263
-rw-r--r--src/transport/plugin_transport_http.h20
-rw-r--r--src/transport/plugin_transport_http_client.c181
-rw-r--r--src/transport/plugin_transport_http_server.c327
-rw-r--r--src/transport/plugin_transport_sat_constants.h20
-rw-r--r--src/transport/plugin_transport_tcp.c31
-rw-r--r--src/transport/plugin_transport_udp.c477
-rw-r--r--src/transport/plugin_transport_udp_new.c222
-rw-r--r--src/transport/plugin_transport_unix.c5
-rw-r--r--src/transport/plugin_transport_wlan.c413
-rw-r--r--src/transport/test_quota_compliance.c161
-rw-r--r--src/transport/test_transport_api.c82
-rw-r--r--src/transport/test_transport_api_disconnect.c98
-rw-r--r--src/transport/test_transport_api_limited_sockets.c28
-rw-r--r--src/transport/test_transport_api_reliability.c88
-rw-r--r--src/transport/test_transport_api_timeout.c43
-rw-r--r--src/transport/test_transport_api_unreliability.c45
-rw-r--r--src/transport/test_transport_api_unreliability_constant.c41
-rw-r--r--src/transport/test_transport_startonly.c14
-rw-r--r--src/transport/test_transport_testing.c68
-rw-r--r--src/transport/transport-testing.c134
-rw-r--r--src/transport/transport-testing.h36
-rw-r--r--src/transport/transport_api.c4
-rw-r--r--src/transport/transport_api_address_iterate.c5
-rw-r--r--src/util/bandwidth.c141
-rw-r--r--src/util/bio.c253
-rw-r--r--src/util/client.c804
-rw-r--r--src/util/common_allocation.c56
-rw-r--r--src/util/common_logging.c400
-rw-r--r--src/util/configuration.c768
-rw-r--r--src/util/connection.c1015
-rw-r--r--src/util/container_bloomfilter.c260
-rw-r--r--src/util/container_heap.c201
-rw-r--r--src/util/container_meta_data.c792
-rw-r--r--src/util/container_multihashmap.c235
-rw-r--r--src/util/container_slist.c72
-rw-r--r--src/util/crypto_aes.c77
-rw-r--r--src/util/crypto_crc.c12
-rw-r--r--src/util/crypto_hash.c214
-rw-r--r--src/util/crypto_hkdf.c118
-rw-r--r--src/util/crypto_kdf.c14
-rw-r--r--src/util/crypto_ksk.c513
-rw-r--r--src/util/crypto_random.c199
-rw-r--r--src/util/crypto_rsa.c753
-rw-r--r--src/util/disk.c1437
-rw-r--r--src/util/getopt.c1018
-rw-r--r--src/util/getopt_helpers.c171
-rw-r--r--src/util/gnunet-config-diff.c8
-rw-r--r--src/util/gnunet-resolver.c6
-rw-r--r--src/util/gnunet-service-resolver.c411
-rw-r--r--src/util/load.c46
-rw-r--r--src/util/network.c1072
-rw-r--r--src/util/os_installation.c274
-rw-r--r--src/util/os_network.c365
-rw-r--r--src/util/os_priority.c1110
-rw-r--r--src/util/peer.c102
-rw-r--r--src/util/perf_crypto_hash.c20
-rw-r--r--src/util/plugin.c143
-rw-r--r--src/util/program.c108
-rw-r--r--src/util/pseudonym.c277
-rw-r--r--src/util/resolver_api.c598
-rw-r--r--src/util/scheduler.c825
-rw-r--r--src/util/server.c769
-rw-r--r--src/util/server_mst.c264
-rw-r--r--src/util/server_nc.c205
-rw-r--r--src/util/server_tc.c76
-rw-r--r--src/util/service.c1406
-rw-r--r--src/util/signal.c16
-rw-r--r--src/util/strings.c404
-rw-r--r--src/util/test_bio.c55
-rw-r--r--src/util/test_client.c56
-rw-r--r--src/util/test_common_allocation.c24
-rw-r--r--src/util/test_common_logging.c53
-rw-r--r--src/util/test_common_logging_dummy.c4
-rw-r--r--src/util/test_common_logging_runtime_loglevels.c364
-rw-r--r--src/util/test_configuration.c477
-rw-r--r--src/util/test_connection.c64
-rw-r--r--src/util/test_connection_addressing.c69
-rw-r--r--src/util/test_connection_receive_cancel.c22
-rw-r--r--src/util/test_connection_timeout.c43
-rw-r--r--src/util/test_connection_timeout_no_connect.c16
-rw-r--r--src/util/test_connection_transmit_cancel.c15
-rw-r--r--src/util/test_container_bloomfilter.c206
-rw-r--r--src/util/test_container_heap.c14
-rw-r--r--src/util/test_container_meta_data.c256
-rw-r--r--src/util/test_container_multihashmap.c29
-rw-r--r--src/util/test_container_slist.c93
-rw-r--r--src/util/test_crypto_aes.c120
-rw-r--r--src/util/test_crypto_aes_weak.c127
-rw-r--r--src/util/test_crypto_hash.c13
-rw-r--r--src/util/test_crypto_hkdf.c94
-rw-r--r--src/util/test_crypto_ksk.c192
-rw-r--r--src/util/test_crypto_random.c18
-rw-r--r--src/util/test_crypto_rsa.c210
-rw-r--r--src/util/test_disk.c101
-rw-r--r--src/util/test_getopt.c68
-rw-r--r--src/util/test_os_network.c8
-rw-r--r--src/util/test_os_priority.c12
-rw-r--r--src/util/test_os_start_process.c78
-rw-r--r--src/util/test_peer.c46
-rw-r--r--src/util/test_plugin.c6
-rw-r--r--src/util/test_program.c18
-rw-r--r--src/util/test_pseudonym.c46
-rw-r--r--src/util/test_resolver_api.c267
-rw-r--r--src/util/test_scheduler.c16
-rw-r--r--src/util/test_scheduler_delay.c20
-rw-r--r--src/util/test_server.c45
-rw-r--r--src/util/test_server_disconnect.c21
-rw-r--r--src/util/test_server_with_client.c58
-rw-r--r--src/util/test_server_with_client_unix.c52
-rw-r--r--src/util/test_service.c77
-rw-r--r--src/util/test_strings.c24
-rw-r--r--src/util/test_time.c52
-rw-r--r--src/util/time.c62
-rw-r--r--src/util/winproc.c227
-rw-r--r--src/vpn/gnunet-daemon-exit.c178
-rw-r--r--src/vpn/gnunet-daemon-vpn-dns.c41
-rw-r--r--src/vpn/gnunet-daemon-vpn-helper.c315
-rw-r--r--src/vpn/gnunet-daemon-vpn.c111
-rw-r--r--src/vpn/gnunet-dns-parser.c182
-rw-r--r--src/vpn/gnunet-service-dns-p.h3
-rw-r--r--src/vpn/gnunet-service-dns.c676
259 files changed, 18265 insertions, 19233 deletions
diff --git a/src/ats-test/test_transport_ats_multiple_peers.c b/src/ats-test/test_transport_ats_multiple_peers.c
index c79454411..4d32dc462 100644
--- a/src/ats-test/test_transport_ats_multiple_peers.c
+++ b/src/ats-test/test_transport_ats_multiple_peers.c
@@ -605,8 +605,7 @@ send_task_f (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
send_task = GNUNET_SCHEDULER_add_now (&send_task_f, NULL);
}
diff --git a/src/ats/ats.h b/src/ats/ats.h
index 3ae6fdb65..5b9fa8696 100644
--- a/src/ats/ats.h
+++ b/src/ats/ats.h
@@ -31,13 +31,12 @@
enum StartFlag
{
-
+
START_FLAG_SCHEDULING = 0,
START_FLAG_PERFORMANCE_WITH_PIC = 1,
START_FLAG_PERFORMANCE_NO_PIC = 2
-
};
@@ -55,7 +54,7 @@ struct ClientStartMessage
struct RequestAddressMessage
{
struct GNUNET_MessageHeader header;
-
+
uint32_t reserved GNUNET_PACKED;
struct GNUNET_PeerIdentity peer;
@@ -77,10 +76,10 @@ struct AddressUpdateMessage
uint32_t session_id GNUNET_PACKED;
/* followed by:
- - struct GNUNET_ATS_Information [ats_count];
- - char address[address_length]
- - char plugin_name[plugin_name_length] (including '\0'-termination).
- */
+ * - struct GNUNET_ATS_Information [ats_count];
+ * - char address[address_length]
+ * - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
};
@@ -99,9 +98,9 @@ struct AddressUseMessage
uint32_t session_id GNUNET_PACKED;
/* followed by:
- - char address[address_length]
- - char plugin_name[plugin_name_length] (including '\0'-termination).
- */
+ * - char address[address_length]
+ * - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
};
@@ -121,9 +120,9 @@ struct AddressDestroyedMessage
uint32_t session_id GNUNET_PACKED;
/* followed by:
- - char address[address_length]
- - char plugin_name[plugin_name_length] (including '\0'-termination).
- */
+ * - char address[address_length]
+ * - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
};
@@ -143,14 +142,14 @@ struct AddressSuggestionMessage
uint32_t session_id GNUNET_PACKED;
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
-
+
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
/* followed by:
- - struct GNUNET_ATS_Information [ats_count];
- - char address[address_length]
- - char plugin_name[plugin_name_length] (including '\0'-termination).
- */
+ * - struct GNUNET_ATS_Information [ats_count];
+ * - char address[address_length]
+ * - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
};
@@ -168,14 +167,14 @@ struct PeerInformationMessage
uint16_t plugin_name_length GNUNET_PACKED;
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out;
-
+
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in;
- /* followed by:
- - struct GNUNET_ATS_Information [ats_count];
- - char address[address_length]
- - char plugin_name[plugin_name_length] (including '\0'-termination).
- */
+ /* followed by:
+ * - struct GNUNET_ATS_Information [ats_count];
+ * - char address[address_length]
+ * - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
};
@@ -222,7 +221,7 @@ struct PreferenceInformation
uint32_t preference_kind GNUNET_PACKED;
float preference_value GNUNET_PACKED;
-
+
};
@@ -234,8 +233,8 @@ struct ChangePreferenceMessage
struct GNUNET_PeerIdentity peer;
- /* followed by 'num_preferences'
- struct PreferenceInformation values */
+ /* followed by 'num_preferences'
+ * struct PreferenceInformation values */
};
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c
index 61d3895d2..e25f9a8ec 100644
--- a/src/ats/ats_api.c
+++ b/src/ats/ats_api.c
@@ -138,26 +138,22 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value)
GNUNET_assert (GNUNET_SYSERR != ar->connected);
/* FIXME: ||1 because we currently NEVER get 'connected' events... */
- if ( (GNUNET_YES == ar->connected) || 1)
+ if ((GNUNET_YES == ar->connected) || 1)
{
ar->bandwidth_in = sbc->bw_in;
ar->bandwidth_out = sbc->bw_out;
GNUNET_BANDWIDTH_tracker_update_quota (&ar->available_recv_window,
ar->bandwidth_in);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Bandwidth assigned to peer %s is i:%u/o:%u bytes/s\n",
- GNUNET_i2s ((const struct GNUNET_PeerIdentity *) key),
- ntohl (ar->bandwidth_in.value__),
- ntohl (ar->bandwidth_out.value__));
+ "Bandwidth assigned to peer %s is i:%u/o:%u bytes/s\n",
+ GNUNET_i2s ((const struct GNUNET_PeerIdentity *) key),
+ ntohl (ar->bandwidth_in.value__), ntohl (ar->bandwidth_out.value__));
if (NULL != sbc->atc->alloc_cb)
sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls,
(const struct GNUNET_PeerIdentity *) key,
- ar->plugin_name, ar->plugin_addr,
- ar->plugin_addr_len,
- ar->session,
- ar->bandwidth_out,
- ar->bandwidth_in,
- NULL, 0);
+ ar->plugin_name, ar->plugin_addr, ar->plugin_addr_len,
+ ar->session, ar->bandwidth_out, ar->bandwidth_in,
+ NULL, 0);
}
else if (ntohl (ar->bandwidth_out.value__) > 0)
{
@@ -166,17 +162,16 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value)
if (NULL != sbc->atc->alloc_cb)
sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls,
(const struct GNUNET_PeerIdentity *) key,
- ar->plugin_name, ar->plugin_addr,
- ar->plugin_addr_len, ar->session, ar->bandwidth_out,
- ar->bandwidth_in, NULL, 0);
+ ar->plugin_name, ar->plugin_addr, ar->plugin_addr_len,
+ ar->session, ar->bandwidth_out, ar->bandwidth_in,
+ NULL, 0);
}
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Not communicating bandwidth assigned to peer %s: not connected and bw is: i:%u/o:%u bytes/s\n",
- GNUNET_i2s ((const struct GNUNET_PeerIdentity *) key),
- ntohl (ar->bandwidth_in.value__),
- ntohl (ar->bandwidth_out.value__));
-
+ "Not communicating bandwidth assigned to peer %s: not connected and bw is: i:%u/o:%u bytes/s\n",
+ GNUNET_i2s ((const struct GNUNET_PeerIdentity *) key),
+ ntohl (ar->bandwidth_in.value__), ntohl (ar->bandwidth_out.value__));
+
return GNUNET_YES;
}
@@ -205,9 +200,8 @@ update_bandwidth_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
bwc.bw_out = GNUNET_BANDWIDTH_value_init (atc->total_bps_out / ac);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Trivial implementation: bandwidth assigned to each peer is i:%u/o:%u bytes/s\n",
- ntohl (bwc.bw_in.value__),
- ntohl (bwc.bw_out.value__));
- GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &set_bw_connections, &bwc);
+ ntohl (bwc.bw_in.value__), ntohl (bwc.bw_out.value__));
+ GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &set_bw_connections, &bwc);
}
@@ -244,9 +238,8 @@ suggest_address (void *cls, const GNUNET_HashCode * key, void *value)
#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Suggesting address for peer `%s', starting with i:%u/o:%u bytes/s\n",
- GNUNET_h2s (key),
- asc->atc->total_bps_in/32,
- asc->atc->total_bps_out/32);
+ GNUNET_h2s (key), asc->atc->total_bps_in / 32,
+ asc->atc->total_bps_out / 32);
#endif
/* trivial strategy: pick first available address... */
@@ -285,8 +278,8 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
struct GNUNET_ATS_SuggestionContext *asc;
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Looking up suggested address for peer `%s'\n", GNUNET_i2s (peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Looking up suggested address for peer `%s'\n",
+ GNUNET_i2s (peer));
#endif
asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext));
asc->cb = cb;
@@ -441,70 +434,70 @@ update_session (void *cls, const GNUNET_HashCode * key, void *value)
if (0 != strcmp (arnew->plugin_name, arold->plugin_name))
return GNUNET_YES;
- if (! (((arnew->session == arold->session) && (arnew->session != NULL)) ||
- ((arold->session == NULL) &&
- (arold->plugin_addr_len == arnew->plugin_addr_len) &&
- (0 ==
- memcmp (arold->plugin_addr, arnew->plugin_addr,
- arnew->plugin_addr_len)))))
- return GNUNET_YES; /* no match */
+ if (!
+ (((arnew->session == arold->session) && (arnew->session != NULL)) ||
+ ((arold->session == NULL) &&
+ (arold->plugin_addr_len == arnew->plugin_addr_len) &&
+ (0 ==
+ memcmp (arold->plugin_addr, arnew->plugin_addr,
+ arnew->plugin_addr_len)))))
+ return GNUNET_YES; /* no match */
/* records match */
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Updating session for peer `%s' plugin `%s'\n", GNUNET_h2s (key),
- arold->plugin_name);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating session for peer `%s' plugin `%s'\n",
+ GNUNET_h2s (key), arold->plugin_name);
#endif
if (arnew->session != arold->session)
- {
- arold->session = arnew->session;
- }
+ {
+ arold->session = arnew->session;
+ }
if ((arnew->connected == GNUNET_YES) && (arold->connected == GNUNET_NO))
- {
- arold->connected = GNUNET_YES;
- }
-
+ {
+ arold->connected = GNUNET_YES;
+ }
+
/* Update existing value */
c_new = 0;
while (c_new < arnew->ats_count)
+ {
+ c_old = 0;
+ found = GNUNET_NO;
+ while (c_old < arold->ats_count)
{
- c_old = 0;
- found = GNUNET_NO;
- while (c_old < arold->ats_count)
+ if (arold->ats[c_old].type == arnew->ats[c_new].type)
{
- if (arold->ats[c_old].type == arnew->ats[c_new].type)
- {
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found type %i, old value=%i new value=%i\n",
- ntohl (arold->ats[c_old].type), ntohl (arold->ats[c_old].value),
- ntohl (arnew->ats[c_new].value));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found type %i, old value=%i new value=%i\n",
+ ntohl (arold->ats[c_old].type), ntohl (arold->ats[c_old].value),
+ ntohl (arnew->ats[c_new].value));
#endif
- arold->ats[c_old].value = arnew->ats[c_new].value;
- found = GNUNET_YES;
- }
- c_old++;
+ arold->ats[c_old].value = arnew->ats[c_new].value;
+ found = GNUNET_YES;
}
- /* Add new value */
- if (found == GNUNET_NO)
- {
+ c_old++;
+ }
+ /* Add new value */
+ if (found == GNUNET_NO)
+ {
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n",
- ntohl (arnew->ats[c_new].type), ntohl (arnew->ats[c_new].value));
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", arold->ats_count);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Added new type %i new value=%i\n",
+ ntohl (arnew->ats[c_new].type), ntohl (arnew->ats[c_new].value));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Old array size: %u\n", arold->ats_count);
#endif
- GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1);
- GNUNET_assert (arold->ats_count >= 2);
- arold->ats[arold->ats_count - 2].type = arnew->ats[c_new].type;
- arold->ats[arold->ats_count - 2].value = arnew->ats[c_new].value;
- arold->ats[arold->ats_count - 1].type = htonl (0);
- arold->ats[arold->ats_count - 1].value = htonl (0);
+ GNUNET_array_grow (arold->ats, arold->ats_count, arold->ats_count + 1);
+ GNUNET_assert (arold->ats_count >= 2);
+ arold->ats[arold->ats_count - 2].type = arnew->ats[c_new].type;
+ arold->ats[arold->ats_count - 2].value = arnew->ats[c_new].value;
+ arold->ats[arold->ats_count - 1].type = htonl (0);
+ arold->ats[arold->ats_count - 1].value = htonl (0);
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", arold->ats_count);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "New array size: %i\n", arold->ats_count);
#endif
- }
- c_new++;
}
-
+ c_new++;
+ }
+
update_bandwidth_assignment (usc->atc, arold);
return GNUNET_NO;
}
@@ -538,9 +531,8 @@ create_allocation_record (const char *plugin_name, struct Session *session,
MAX_WINDOW_TIME_S);
GNUNET_assert (ats_count > 0);
GNUNET_array_grow (ar->ats, ar->ats_count, ats_count);
- memcpy (ar->ats, ats,
- ats_count * sizeof (struct GNUNET_ATS_Information));
- ar->connected = GNUNET_SYSERR; /* aka: not known / no change */
+ memcpy (ar->ats, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
+ ar->connected = GNUNET_SYSERR; /* aka: not known / no change */
return ar;
}
@@ -594,11 +586,9 @@ GNUNET_ATS_peer_connect (struct GNUNET_ATS_SchedulingHandle *atc,
struct UpdateSessionContext usc;
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Connected to peer %s\n",
- GNUNET_i2s (peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", GNUNET_i2s (peer));
#endif
-
+
(void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &disconnect_peer,
atc);
ar = create_allocation_record (plugin_name, session, plugin_addr,
@@ -632,8 +622,7 @@ GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_SchedulingHandle *atc,
const struct GNUNET_PeerIdentity *peer)
{
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnected from peer %s\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnected from peer %s\n",
GNUNET_i2s (peer));
#endif
(void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
@@ -768,9 +757,8 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
struct UpdateSessionContext usc;
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Updating address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer),
- plugin_name);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s', plugin `%s'\n",
+ GNUNET_i2s (peer), plugin_name);
#endif
ar = create_allocation_record (plugin_name, session, plugin_addr,
plugin_addr_len, ats, ats_count);
@@ -783,7 +771,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
return;
}
#if DEBUG_ATS
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding new address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer),
plugin_name);
#endif
diff --git a/src/ats/ats_api_peer_change_preference.c b/src/ats/ats_api_peer_change_preference.c
index 322727e63..7290ebb7a 100644
--- a/src/ats/ats_api_peer_change_preference.c
+++ b/src/ats/ats_api_peer_change_preference.c
@@ -49,17 +49,16 @@ struct GNUNET_ATS_InformationRequestContext
GNUNET_ATS_PeerConfigurationInfoCallback info;
void *info_cls;
-
+
struct GNUNET_PeerIdentity peer;
-
+
GNUNET_SCHEDULER_TaskIdentifier task;
};
static void
-exec_pcp (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+exec_pcp (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_ATS_InformationRequestContext *irc = cls;
int32_t want_reserv;
@@ -69,16 +68,13 @@ exec_pcp (void *cls,
rdelay = GNUNET_TIME_UNIT_ZERO;
want_reserv = irc->amount;
- ar = GNUNET_CONTAINER_multihashmap_get (irc->h->peers, &irc->peer.hashPubKey);
+ ar = GNUNET_CONTAINER_multihashmap_get (irc->h->peers, &irc->peer.hashPubKey);
if (NULL == ar)
{
/* attempt to change preference on peer that is not connected */
/* FIXME: this can happen if the 'service' didn't yet tell us about
- a new connection, fake it! */
- irc->info (irc->info_cls,
- &irc->peer,
- want_reserv,
- rdelay);
+ * a new connection, fake it! */
+ irc->info (irc->info_cls, &irc->peer, want_reserv, rdelay);
GNUNET_free (irc);
return;
}
@@ -89,21 +85,18 @@ exec_pcp (void *cls,
else if (want_reserv > 0)
{
rdelay =
- GNUNET_BANDWIDTH_tracker_get_delay (&ar->available_recv_window,
- want_reserv);
+ GNUNET_BANDWIDTH_tracker_get_delay (&ar->available_recv_window,
+ want_reserv);
if (rdelay.rel_value == 0)
got_reserv = want_reserv;
else
- got_reserv = 0; /* all or nothing */
+ got_reserv = 0; /* all or nothing */
}
else
got_reserv = 0;
GNUNET_BANDWIDTH_tracker_consume (&ar->available_recv_window, got_reserv);
- irc->info (irc->info_cls,
- &irc->peer,
- got_reserv,
- rdelay);
+ irc->info (irc->info_cls, &irc->peer, got_reserv, rdelay);
GNUNET_free (irc);
}
@@ -125,10 +118,10 @@ exec_pcp (void *cls,
*/
struct GNUNET_ATS_InformationRequestContext *
GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount, uint64_t preference,
- GNUNET_ATS_PeerConfigurationInfoCallback
- info, void *info_cls)
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount, uint64_t preference,
+ GNUNET_ATS_PeerConfigurationInfoCallback
+ info, void *info_cls)
{
struct GNUNET_ATS_InformationRequestContext *irc;
@@ -157,8 +150,8 @@ GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
*/
void
GNUNET_ATS_peer_change_preference_cancel (struct
- GNUNET_ATS_InformationRequestContext
- *irc)
+ GNUNET_ATS_InformationRequestContext
+ *irc)
{
GNUNET_SCHEDULER_cancel (irc->task);
GNUNET_free (irc);
@@ -219,10 +212,10 @@ change_preference_send_continuation (void *cls, int success)
*/
struct GNUNET_ATS_InformationRequestContext *
GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount, uint64_t preference,
- GNUNET_ATS_PeerConfigurationInfoCallback
- info, void *info_cls)
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount, uint64_t preference,
+ GNUNET_ATS_PeerConfigurationInfoCallback
+ info, void *info_cls)
{
struct GNUNET_ATS_InformationRequestContext *irc;
struct PeerRecord *pr;
@@ -287,8 +280,8 @@ GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
*/
void
GNUNET_ATS_peer_change_preference_cancel (struct
- GNUNET_ATS_InformationRequestContext
- *irc)
+ GNUNET_ATS_InformationRequestContext
+ *irc)
{
struct GNUNET_ATS_SchedulingHandle *h = irc->h;
struct PeerRecord *pr = irc->pr;
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index ba124fe21..ca489e4a6 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -37,12 +37,12 @@ struct PendingMessage
/**
* Kept in a DLL.
- */
+ */
struct PendingMessage *next;
/**
* Kept in a DLL.
- */
+ */
struct PendingMessage *prev;
/**
@@ -52,7 +52,7 @@ struct PendingMessage
/**
* Is this the 'ATS_START' message?
- */
+ */
int is_init;
};
@@ -65,19 +65,19 @@ struct GNUNET_ATS_ReservationContext
/**
* Kept in a DLL.
- */
+ */
struct GNUNET_ATS_ReservationContext *next;
/**
* Kept in a DLL.
- */
+ */
struct GNUNET_ATS_ReservationContext *prev;
/**
* Target peer.
*/
struct GNUNET_PeerIdentity peer;
-
+
/**
* Desired reservation
*/
@@ -110,7 +110,7 @@ struct GNUNET_ATS_ReservationContext
*/
struct GNUNET_ATS_PerformanceHandle
{
-
+
/**
* Our configuration.
*/
@@ -120,7 +120,7 @@ struct GNUNET_ATS_PerformanceHandle
* Callback to invoke on performance changes.
*/
GNUNET_ATS_PeerInformationCallback infocb;
-
+
/**
* Closure for 'infocb'.
*/
@@ -158,9 +158,9 @@ struct GNUNET_ATS_PerformanceHandle
/**
* Task to trigger reconnect.
- */
+ */
GNUNET_SCHEDULER_TaskIdentifier task;
-
+
};
@@ -180,8 +180,7 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph);
* @param tc scheduler context
*/
static void
-reconnect_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_ATS_PerformanceHandle *ph = cls;
@@ -209,9 +208,7 @@ do_transmit (struct GNUNET_ATS_PerformanceHandle *ph);
* @return number of bytes copied into buf
*/
static size_t
-transmit_message_to_ats (void *cls,
- size_t size,
- void *buf)
+transmit_message_to_ats (void *cls, size_t size, void *buf)
{
struct GNUNET_ATS_PerformanceHandle *ph = cls;
struct PendingMessage *p;
@@ -221,15 +218,12 @@ transmit_message_to_ats (void *cls,
ph->th = NULL;
ret = 0;
cbuf = buf;
- while ( (NULL != (p = ph->pending_head)) &&
- (p->size <= size) )
+ while ((NULL != (p = ph->pending_head)) && (p->size <= size))
{
- memcpy (&cbuf[ret], &p[1], p->size);
+ memcpy (&cbuf[ret], &p[1], p->size);
ret += p->size;
size -= p->size;
- GNUNET_CONTAINER_DLL_remove (ph->pending_head,
- ph->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
GNUNET_free (p);
}
do_transmit (ph);
@@ -253,12 +247,12 @@ do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
if (NULL == (p = ph->pending_head))
return;
if (NULL == ph->client)
- return; /* currently reconnecting */
- ph->th = GNUNET_CLIENT_notify_transmit_ready (ph->client,
- p->size,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_YES,
- &transmit_message_to_ats, ph);
+ return; /* currently reconnecting */
+ ph->th =
+ GNUNET_CLIENT_notify_transmit_ready (ph->client, p->size,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_YES, &transmit_message_to_ats,
+ ph);
}
@@ -271,7 +265,7 @@ do_transmit (struct GNUNET_ATS_PerformanceHandle *ph)
*/
static int
process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_MessageHeader *msg)
{
const struct PeerInformationMessage *pi;
const struct GNUNET_ATS_Information *atsi;
@@ -285,37 +279,31 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
{
GNUNET_break (0);
return GNUNET_SYSERR;
- }
+ }
if (ntohs (msg->size) < sizeof (struct PeerInformationMessage))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- pi = (const struct PeerInformationMessage*) msg;
+ pi = (const struct PeerInformationMessage *) msg;
ats_count = ntohl (pi->ats_count);
address_length = ntohs (pi->address_length);
plugin_name_length = ntohs (pi->plugin_name_length);
- atsi = (const struct GNUNET_ATS_Information*) &pi[1];
- address = (const char*) &atsi[ats_count];
+ atsi = (const struct GNUNET_ATS_Information *) &pi[1];
+ address = (const char *) &atsi[ats_count];
plugin_name = &address[address_length];
- if ( (address_length +
- plugin_name_length +
- ats_count * sizeof (struct GNUNET_ATS_Information) +
- sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
- (ats_count > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) ||
- (plugin_name[plugin_name_length - 1] != '\0') )
+ if ((address_length + plugin_name_length +
+ ats_count * sizeof (struct GNUNET_ATS_Information) +
+ sizeof (struct PeerInformationMessage) != ntohs (msg->size)) ||
+ (ats_count >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
+ || (plugin_name[plugin_name_length - 1] != '\0'))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- ph->infocb (ph->infocb_cls,
- &pi->peer,
- plugin_name,
- address, address_length,
- pi->bandwidth_out,
- pi->bandwidth_in,
- atsi,
- ats_count);
+ ph->infocb (ph->infocb_cls, &pi->peer, plugin_name, address, address_length,
+ pi->bandwidth_out, pi->bandwidth_in, atsi, ats_count);
return GNUNET_OK;
}
@@ -329,7 +317,7 @@ process_pi_message (struct GNUNET_ATS_PerformanceHandle *ph,
*/
static int
process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_MessageHeader *msg)
{
const struct ReservationResultMessage *rr;
struct GNUNET_ATS_ReservationContext *rc;
@@ -340,28 +328,21 @@ process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
GNUNET_break (0);
return GNUNET_SYSERR;
}
- rr = (const struct ReservationResultMessage*) msg;
+ rr = (const struct ReservationResultMessage *) msg;
amount = ntohl (rr->amount);
rc = ph->reservation_head;
- if (0 != memcmp (&rr->peer,
- &rc->peer,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 != memcmp (&rr->peer, &rc->peer, sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
- GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
- ph->reservation_tail,
- rc);
- if ( (amount == 0) ||
- (rc->rcb != NULL) )
+ GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail, rc);
+ if ((amount == 0) || (rc->rcb != NULL))
{
/* tell client if not cancelled */
if (rc->rcb != NULL)
- rc->rcb (rc->rcb_cls,
- &rr->peer,
- amount,
- GNUNET_TIME_relative_ntoh (rr->res_delay));
+ rc->rcb (rc->rcb_cls, &rr->peer, amount,
+ GNUNET_TIME_relative_ntoh (rr->res_delay));
GNUNET_free (rc);
return GNUNET_OK;
}
@@ -369,7 +350,7 @@ process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
if (GNUNET_YES != rc->undo)
{
GNUNET_free (rc);
- return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
+ return GNUNET_OK; /* do not try to undo failed undos or negative amounts */
}
GNUNET_free (rc);
(void) GNUNET_ATS_reserve_bandwidth (ph, &rr->peer, -amount, NULL, NULL);
@@ -385,12 +366,11 @@ process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
* @param msg message received, NULL on timeout or fatal error
*/
static void
-process_ats_message (void *cls,
- const struct GNUNET_MessageHeader *msg)
+process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_ATS_PerformanceHandle *ph = cls;
- if (NULL == msg)
+ if (NULL == msg)
goto reconnect;
switch (ntohs (msg->type))
{
@@ -400,22 +380,22 @@ process_ats_message (void *cls,
break;
case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
if (GNUNET_OK != process_rr_message (ph, msg))
- goto reconnect;
+ goto reconnect;
break;
default:
GNUNET_break (0);
goto reconnect;
return;
}
- GNUNET_CLIENT_receive (ph->client,
- &process_ats_message, ph,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
+ GNUNET_TIME_UNIT_FOREVER_REL);
return;
- reconnect:
+reconnect:
GNUNET_CLIENT_disconnect (ph->client, GNUNET_NO);
ph->client = NULL;
- ph->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &reconnect_task, ph);
+ ph->task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
+ ph);
}
@@ -433,25 +413,22 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
GNUNET_assert (NULL == ph->client);
ph->client = GNUNET_CLIENT_connect ("ats", ph->cfg);
GNUNET_assert (NULL != ph->client);
- GNUNET_CLIENT_receive (ph->client,
- &process_ats_message, ph,
- GNUNET_TIME_UNIT_FOREVER_REL);
- if ( (NULL == (p = ph->pending_head)) ||
- (GNUNET_YES != p->is_init) )
+ GNUNET_CLIENT_receive (ph->client, &process_ats_message, ph,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
{
p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct ClientStartMessage));
+ sizeof (struct ClientStartMessage));
p->size = sizeof (struct ClientStartMessage);
p->is_init = GNUNET_YES;
init = (struct ClientStartMessage *) &p[1];
init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
init->header.size = htons (sizeof (struct ClientStartMessage));
- init->start_flag = htonl ((ph->infocb == NULL)
- ? START_FLAG_PERFORMANCE_NO_PIC
- : START_FLAG_PERFORMANCE_WITH_PIC);
- GNUNET_CONTAINER_DLL_insert (ph->pending_head,
- ph->pending_tail,
- p);
+ init->start_flag =
+ htonl ((ph->infocb ==
+ NULL) ? START_FLAG_PERFORMANCE_NO_PIC :
+ START_FLAG_PERFORMANCE_WITH_PIC);
+ GNUNET_CONTAINER_DLL_insert (ph->pending_head, ph->pending_tail, p);
}
do_transmit (ph);
}
@@ -468,8 +445,8 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
*/
struct GNUNET_ATS_PerformanceHandle *
GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ATS_PeerInformationCallback infocb,
- void *infocb_cls)
+ GNUNET_ATS_PeerInformationCallback infocb,
+ void *infocb_cls)
{
struct GNUNET_ATS_PerformanceHandle *ph;
@@ -492,22 +469,19 @@ GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
{
struct PendingMessage *p;
struct GNUNET_ATS_ReservationContext *rc;
-
+
while (NULL != (p = ph->pending_head))
{
- GNUNET_CONTAINER_DLL_remove (ph->pending_head,
- ph->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_remove (ph->pending_head, ph->pending_tail, p);
GNUNET_free (p);
}
while (NULL != (rc = ph->reservation_head))
{
- GNUNET_CONTAINER_DLL_remove (ph->reservation_head,
- ph->reservation_tail,
- rc);
+ GNUNET_CONTAINER_DLL_remove (ph->reservation_head, ph->reservation_tail,
+ rc);
GNUNET_break (NULL == rc->rcb);
GNUNET_free (rc);
- }
+ }
if (GNUNET_SCHEDULER_NO_TASK != ph->task)
{
GNUNET_SCHEDULER_cancel (ph->task);
@@ -538,10 +512,9 @@ GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
*/
struct GNUNET_ATS_ReservationContext *
GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount,
- GNUNET_ATS_ReservationCallback rcb,
- void *rcb_cls)
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount,
+ GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
{
struct GNUNET_ATS_ReservationContext *rc;
struct PendingMessage *p;
@@ -552,24 +525,21 @@ GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
rc->peer = *peer;
rc->rcb = rcb;
rc->rcb_cls = rcb_cls;
- if ( (rcb != NULL) && (amount > 0) )
+ if ((rcb != NULL) && (amount > 0))
rc->undo = GNUNET_YES;
- GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head,
- ph->reservation_tail,
- rc);
-
- p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct ReservationRequestMessage));
+ GNUNET_CONTAINER_DLL_insert_tail (ph->reservation_head, ph->reservation_tail,
+ rc);
+
+ p = GNUNET_malloc (sizeof (struct PendingMessage) +
+ sizeof (struct ReservationRequestMessage));
p->size = sizeof (struct ReservationRequestMessage);
p->is_init = GNUNET_NO;
- m = (struct ReservationRequestMessage*) &p[1];
+ m = (struct ReservationRequestMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST);
m->header.size = htons (sizeof (struct ReservationRequestMessage));
m->amount = htonl (amount);
m->peer = *peer;
- GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
- ph->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
do_transmit (ph);
return rc;
}
@@ -581,8 +551,7 @@ GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
* @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
*/
void
-GNUNET_ATS_reserve_bandwidth_cancel (struct
- GNUNET_ATS_ReservationContext *rc)
+GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
{
rc->rcb = NULL;
}
@@ -591,15 +560,14 @@ GNUNET_ATS_reserve_bandwidth_cancel (struct
/**
* Change preferences for the given peer. Preference changes are forgotten if peers
* disconnect.
- *
+ *
* @param ph performance handle
* @param peer identifies the peer
* @param ... 0-terminated specification of the desired changes
*/
void
GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
- const struct GNUNET_PeerIdentity *peer,
- ...)
+ const struct GNUNET_PeerIdentity *peer, ...)
{
struct PendingMessage *p;
struct ChangePreferenceMessage *m;
@@ -611,60 +579,63 @@ GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
count = 0;
va_start (ap, peer);
- while (GNUNET_ATS_PREFERENCE_END != (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
+ while (GNUNET_ATS_PREFERENCE_END !=
+ (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
{
switch (kind)
{
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
count++;
(void) va_arg (ap, double);
+
break;
case GNUNET_ATS_PREFERENCE_LATENCY:
count++;
(void) va_arg (ap, double);
+
break;
default:
- GNUNET_assert (0);
+ GNUNET_assert (0);
}
}
va_end (ap);
- msize = count * sizeof (struct PreferenceInformation) +
- sizeof (struct ChangePreferenceMessage);
- p = GNUNET_malloc (sizeof (struct PendingMessage) +
- msize);
+ msize =
+ count * sizeof (struct PreferenceInformation) +
+ sizeof (struct ChangePreferenceMessage);
+ p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
p->size = msize;
p->is_init = GNUNET_NO;
- m = (struct ChangePreferenceMessage*) &p[1];
+ m = (struct ChangePreferenceMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE);
m->header.size = htons (msize);
m->num_preferences = htonl (count);
m->peer = *peer;
- pi = (struct PreferenceInformation*) &m[1];
+ pi = (struct PreferenceInformation *) &m[1];
count = 0;
va_start (ap, peer);
- while (GNUNET_ATS_PREFERENCE_END != (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
+ while (GNUNET_ATS_PREFERENCE_END !=
+ (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
{
pi[count].preference_kind = htonl (kind);
switch (kind)
{
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
pi[count].preference_value = (float) va_arg (ap, double);
+
count++;
break;
case GNUNET_ATS_PREFERENCE_LATENCY:
pi[count].preference_value = (float) va_arg (ap, double);
+
count++;
break;
default:
- GNUNET_assert (0);
+ GNUNET_assert (0);
}
}
va_end (ap);
- GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
- ph->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
do_transmit (ph);
}
/* end of ats_api_performance.c */
-
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index b342d9657..2eeb99dad 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -37,12 +37,12 @@ struct PendingMessage
/**
* Kept in a DLL.
- */
+ */
struct PendingMessage *next;
/**
* Kept in a DLL.
- */
+ */
struct PendingMessage *prev;
/**
@@ -52,7 +52,7 @@ struct PendingMessage
/**
* Is this the 'ATS_START' message?
- */
+ */
int is_init;
};
@@ -84,7 +84,7 @@ struct SessionRecord
*/
struct GNUNET_ATS_SchedulingHandle
{
-
+
/**
* Our configuration.
*/
@@ -94,7 +94,7 @@ struct GNUNET_ATS_SchedulingHandle
* Callback to invoke on suggestions.
*/
GNUNET_ATS_AddressSuggestionCallback suggest_cb;
-
+
/**
* Closure for 'suggest_cb'.
*/
@@ -130,9 +130,9 @@ struct GNUNET_ATS_SchedulingHandle
/**
* Task to trigger reconnect.
- */
+ */
GNUNET_SCHEDULER_TaskIdentifier task;
-
+
/**
* Size of the session array.
*/
@@ -161,8 +161,7 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh);
* @param tc scheduler context
*/
static void
-reconnect_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_ATS_SchedulingHandle *sh = cls;
@@ -182,8 +181,9 @@ force_reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
sh->reconnect = GNUNET_NO;
GNUNET_CLIENT_disconnect (sh->client, GNUNET_NO);
sh->client = NULL;
- sh->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &reconnect_task, sh);
+ sh->task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
+ sh);
}
@@ -205,8 +205,7 @@ do_transmit (struct GNUNET_ATS_SchedulingHandle *sh);
* @param msg message received, NULL on timeout or fatal error
*/
static void
-process_ats_message (void *cls,
- const struct GNUNET_MessageHeader *msg);
+process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg);
/**
@@ -218,9 +217,7 @@ process_ats_message (void *cls,
* @return number of bytes copied into buf
*/
static size_t
-transmit_message_to_ats (void *cls,
- size_t size,
- void *buf)
+transmit_message_to_ats (void *cls, size_t size, void *buf)
{
struct GNUNET_ATS_SchedulingHandle *sh = cls;
struct PendingMessage *p;
@@ -228,26 +225,22 @@ transmit_message_to_ats (void *cls,
char *cbuf;
sh->th = NULL;
- if ( (size == 0) || (buf == NULL))
+ if ((size == 0) || (buf == NULL))
{
force_reconnect (sh);
return 0;
}
ret = 0;
cbuf = buf;
- while ( (NULL != (p = sh->pending_head)) &&
- (p->size <= size) )
+ while ((NULL != (p = sh->pending_head)) && (p->size <= size))
{
- memcpy (&cbuf[ret], &p[1], p->size);
+ memcpy (&cbuf[ret], &p[1], p->size);
ret += p->size;
size -= p->size;
- GNUNET_CONTAINER_DLL_remove (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_remove (sh->pending_head, sh->pending_tail, p);
if (GNUNET_YES == p->is_init)
- GNUNET_CLIENT_receive (sh->client,
- &process_ats_message, sh,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
+ GNUNET_TIME_UNIT_FOREVER_REL);
GNUNET_free (p);
}
do_transmit (sh);
@@ -271,12 +264,12 @@ do_transmit (struct GNUNET_ATS_SchedulingHandle *sh)
if (NULL == (p = sh->pending_head))
return;
if (NULL == sh->client)
- return; /* currently reconnecting */
- sh->th = GNUNET_CLIENT_notify_transmit_ready (sh->client,
- p->size,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_NO,
- &transmit_message_to_ats, sh);
+ return; /* currently reconnecting */
+ sh->th =
+ GNUNET_CLIENT_notify_transmit_ready (sh->client, p->size,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_NO, &transmit_message_to_ats,
+ sh);
}
@@ -288,10 +281,9 @@ do_transmit (struct GNUNET_ATS_SchedulingHandle *sh)
* @param peer peer the session belongs to
* @return the session object (or NULL)
*/
-static struct Session*
-find_session (struct GNUNET_ATS_SchedulingHandle *sh,
- uint32_t session_id,
- const struct GNUNET_PeerIdentity *peer)
+static struct Session *
+find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
+ const struct GNUNET_PeerIdentity *peer)
{
if (session_id >= sh->session_array_size)
{
@@ -300,9 +292,9 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh,
}
if (session_id == 0)
return NULL;
- if (0 != memcmp (peer,
- &sh->session_array[session_id].peer,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 !=
+ memcmp (peer, &sh->session_array[session_id].peer,
+ sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
sh->reconnect = GNUNET_YES;
@@ -321,36 +313,33 @@ find_session (struct GNUNET_ATS_SchedulingHandle *sh,
* @param peer peer the session belongs to
* @return the session id
*/
-static uint32_t
-get_session_id (struct GNUNET_ATS_SchedulingHandle *sh,
- struct Session *session,
- const struct GNUNET_PeerIdentity *peer)
+static uint32_t
+get_session_id (struct GNUNET_ATS_SchedulingHandle *sh, struct Session *session,
+ const struct GNUNET_PeerIdentity *peer)
{
unsigned int i;
unsigned int f;
-
+
if (NULL == session)
return 0;
f = 0;
- for (i=1;i<sh->session_array_size;i++)
+ for (i = 1; i < sh->session_array_size; i++)
{
if (session == sh->session_array[i].session)
{
- GNUNET_assert (0 == memcmp (peer,
- &sh->session_array[i].peer,
- sizeof (struct GNUNET_PeerIdentity)));
+ GNUNET_assert (0 ==
+ memcmp (peer, &sh->session_array[i].peer,
+ sizeof (struct GNUNET_PeerIdentity)));
return i;
}
- if ( (f == 0) &&
- (sh->session_array[i].slot_used == GNUNET_NO) )
+ if ((f == 0) && (sh->session_array[i].slot_used == GNUNET_NO))
f = i;
}
if (f == 0)
- {
+ {
f = sh->session_array_size;
- GNUNET_array_grow (sh->session_array,
- sh->session_array_size,
- sh->session_array_size * 2);
+ GNUNET_array_grow (sh->session_array, sh->session_array_size,
+ sh->session_array_size * 2);
}
GNUNET_assert (f > 0);
sh->session_array[f].session = session;
@@ -369,17 +358,16 @@ get_session_id (struct GNUNET_ATS_SchedulingHandle *sh,
* @param peer peer the session belongs to
*/
static void
-remove_session (struct GNUNET_ATS_SchedulingHandle *sh,
- uint32_t session_id,
- const struct GNUNET_PeerIdentity *peer)
+remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
+ const struct GNUNET_PeerIdentity *peer)
{
if (0 == session_id)
return;
GNUNET_assert (session_id < sh->session_array_size);
GNUNET_assert (GNUNET_YES == sh->session_array[session_id].slot_used);
- GNUNET_assert (0 == memcmp (peer,
- &sh->session_array[session_id].peer,
- sizeof (struct GNUNET_PeerIdentity)));
+ GNUNET_assert (0 ==
+ memcmp (peer, &sh->session_array[session_id].peer,
+ sizeof (struct GNUNET_PeerIdentity)));
sh->session_array[session_id].session = NULL;
}
@@ -393,9 +381,8 @@ remove_session (struct GNUNET_ATS_SchedulingHandle *sh,
* @param peer peer the session belongs to
*/
static void
-release_session (struct GNUNET_ATS_SchedulingHandle *sh,
- uint32_t session_id,
- const struct GNUNET_PeerIdentity *peer)
+release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
+ const struct GNUNET_PeerIdentity *peer)
{
if (session_id >= sh->session_array_size)
{
@@ -403,28 +390,25 @@ release_session (struct GNUNET_ATS_SchedulingHandle *sh,
sh->reconnect = GNUNET_YES;
return;
}
- if (0 != memcmp (peer,
- &sh->session_array[session_id].peer,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 !=
+ memcmp (peer, &sh->session_array[session_id].peer,
+ sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break (0);
sh->reconnect = GNUNET_YES;
return;
}
sh->session_array[session_id].slot_used = GNUNET_NO;
- memset (&sh->session_array[session_id].peer,
- 0,
- sizeof (struct GNUNET_PeerIdentity));
+ memset (&sh->session_array[session_id].peer, 0,
+ sizeof (struct GNUNET_PeerIdentity));
}
static void
process_release_message (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct SessionReleaseMessage *srm)
+ const struct SessionReleaseMessage *srm)
{
- release_session (sh,
- ntohl (srm->session_id),
- &srm->peer);
+ release_session (sh, ntohl (srm->session_id), &srm->peer);
}
@@ -436,8 +420,7 @@ process_release_message (struct GNUNET_ATS_SchedulingHandle *sh,
* @param msg message received, NULL on timeout or fatal error
*/
static void
-process_ats_message (void *cls,
- const struct GNUNET_MessageHeader *msg)
+process_ats_message (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_ATS_SchedulingHandle *sh = cls;
const struct AddressSuggestionMessage *m;
@@ -448,60 +431,52 @@ process_ats_message (void *cls,
uint16_t plugin_name_length;
uint32_t ats_count;
- if (NULL == msg)
+ if (NULL == msg)
{
force_reconnect (sh);
return;
}
- if ( (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE) &&
- (ntohs (msg->size) == sizeof (struct SessionReleaseMessage)) )
+ if ((ntohs (msg->type) == GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE) &&
+ (ntohs (msg->size) == sizeof (struct SessionReleaseMessage)))
{
- process_release_message (sh,
- (const struct SessionReleaseMessage*) msg);
- GNUNET_CLIENT_receive (sh->client,
- &process_ats_message, sh,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ process_release_message (sh, (const struct SessionReleaseMessage *) msg);
+ GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
+ GNUNET_TIME_UNIT_FOREVER_REL);
if (GNUNET_YES == sh->reconnect)
force_reconnect (sh);
return;
}
- if ( (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION) ||
- (ntohs (msg->size) <= sizeof (struct AddressSuggestionMessage)) )
+ if ((ntohs (msg->type) != GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION) ||
+ (ntohs (msg->size) <= sizeof (struct AddressSuggestionMessage)))
{
GNUNET_break (0);
force_reconnect (sh);
return;
}
- m = (const struct AddressSuggestionMessage*) msg;
+ m = (const struct AddressSuggestionMessage *) msg;
ats_count = ntohl (m->ats_count);
address_length = ntohs (m->address_length);
- atsi = (const struct GNUNET_ATS_Information*) &m[1];
- address = (const char*) &atsi[ats_count];
+ atsi = (const struct GNUNET_ATS_Information *) &m[1];
+ address = (const char *) &atsi[ats_count];
plugin_name = &address[address_length];
plugin_name_length = ntohs (m->plugin_name_length);
- if ( (address_length +
- plugin_name_length +
- ats_count * sizeof (struct GNUNET_ATS_Information) +
- sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) ||
- (ats_count > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) ||
- (plugin_name[plugin_name_length - 1] != '\0') )
+ if ((address_length + plugin_name_length +
+ ats_count * sizeof (struct GNUNET_ATS_Information) +
+ sizeof (struct AddressSuggestionMessage) != ntohs (msg->size)) ||
+ (ats_count >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
+ || (plugin_name[plugin_name_length - 1] != '\0'))
{
GNUNET_break (0);
force_reconnect (sh);
return;
}
- sh->suggest_cb (sh->suggest_cb_cls,
- &m->peer,
- plugin_name,
- address, address_length,
- find_session (sh, ntohl (m->session_id), &m->peer),
- m->bandwidth_out,
- m->bandwidth_in,
- atsi,
- ats_count);
- GNUNET_CLIENT_receive (sh->client,
- &process_ats_message, sh,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ sh->suggest_cb (sh->suggest_cb_cls, &m->peer, plugin_name, address,
+ address_length, find_session (sh, ntohl (m->session_id),
+ &m->peer), m->bandwidth_out,
+ m->bandwidth_in, atsi, ats_count);
+ GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
+ GNUNET_TIME_UNIT_FOREVER_REL);
if (GNUNET_YES == sh->reconnect)
force_reconnect (sh);
}
@@ -521,20 +496,17 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
GNUNET_assert (NULL == sh->client);
sh->client = GNUNET_CLIENT_connect ("ats", sh->cfg);
GNUNET_assert (NULL != sh->client);
- if ( (NULL == (p = sh->pending_head)) ||
- (GNUNET_YES != p->is_init) )
+ if ((NULL == (p = sh->pending_head)) || (GNUNET_YES != p->is_init))
{
p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct ClientStartMessage));
+ sizeof (struct ClientStartMessage));
p->size = sizeof (struct ClientStartMessage);
p->is_init = GNUNET_YES;
init = (struct ClientStartMessage *) &p[1];
init->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_START);
init->header.size = htons (sizeof (struct ClientStartMessage));
init->start_flag = htonl (START_FLAG_SCHEDULING);
- GNUNET_CONTAINER_DLL_insert (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert (sh->pending_head, sh->pending_tail, p);
}
do_transmit (sh);
}
@@ -550,8 +522,8 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
*/
struct GNUNET_ATS_SchedulingHandle *
GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ATS_AddressSuggestionCallback suggest_cb,
- void *suggest_cb_cls)
+ GNUNET_ATS_AddressSuggestionCallback suggest_cb,
+ void *suggest_cb_cls)
{
struct GNUNET_ATS_SchedulingHandle *sh;
@@ -559,9 +531,7 @@ GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
sh->cfg = cfg;
sh->suggest_cb = suggest_cb;
sh->suggest_cb_cls = suggest_cb_cls;
- GNUNET_array_grow (sh->session_array,
- sh->session_array_size,
- 4);
+ GNUNET_array_grow (sh->session_array, sh->session_array_size, 4);
reconnect (sh);
return sh;
}
@@ -579,9 +549,7 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
while (NULL != (p = sh->pending_head))
{
- GNUNET_CONTAINER_DLL_remove (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_remove (sh->pending_head, sh->pending_tail, p);
GNUNET_free (p);
}
if (NULL != sh->client)
@@ -594,9 +562,7 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
GNUNET_SCHEDULER_cancel (sh->task);
sh->task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_array_grow (sh->session_array,
- sh->session_array_size,
- 0);
+ GNUNET_array_grow (sh->session_array, sh->session_array_size, 0);
GNUNET_free (sh);
}
@@ -616,17 +582,15 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
struct RequestAddressMessage *m;
p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct RequestAddressMessage));
+ sizeof (struct RequestAddressMessage));
p->size = sizeof (struct RequestAddressMessage);
p->is_init = GNUNET_NO;
- m = (struct RequestAddressMessage*) &p[1];
+ m = (struct RequestAddressMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS);
m->header.size = htons (sizeof (struct RequestAddressMessage));
m->reserved = htonl (0);
m->peer = *peer;
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
do_transmit (sh);
}
@@ -651,9 +615,8 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
void
GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- struct Session *session,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
{
@@ -664,21 +627,23 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
size_t namelen;
size_t msize;
- namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1;
- msize = sizeof (struct AddressUpdateMessage) + plugin_addr_len +
- ats_count * sizeof (struct GNUNET_ATS_Information) + namelen;
- if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (ats_count >= GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) )
+ namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1;
+ msize =
+ sizeof (struct AddressUpdateMessage) + plugin_addr_len +
+ ats_count * sizeof (struct GNUNET_ATS_Information) + namelen;
+ if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (ats_count >=
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)))
{
GNUNET_break (0);
return;
}
- p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
+ p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
p->size = msize;
p->is_init = GNUNET_NO;
- m = (struct AddressUpdateMessage*) &p[1];
+ m = (struct AddressUpdateMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE);
m->header.size = htons (msize);
m->ats_count = htonl (ats_count);
@@ -686,14 +651,12 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
m->address_length = htons (plugin_addr_len);
m->plugin_name_length = htons (namelen);
m->session_id = htonl (get_session_id (sh, session, peer));
- am = (struct GNUNET_ATS_Information*) &m[1];
+ am = (struct GNUNET_ATS_Information *) &m[1];
memcpy (am, ats, ats_count * sizeof (struct GNUNET_ATS_Information));
pm = (char *) &am[ats_count];
memcpy (pm, plugin_addr, plugin_addr_len);
memcpy (&pm[plugin_addr_len], plugin_name, namelen);
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
do_transmit (sh);
}
@@ -712,12 +675,10 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
*/
void
GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct Session *session,
- int in_use)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
+ int in_use)
{
struct PendingMessage *p;
struct AddressUseMessage *m;
@@ -727,30 +688,28 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1;
msize = sizeof (struct AddressUseMessage) + plugin_addr_len + namelen;
- if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
+ if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
{
GNUNET_break (0);
return;
}
- p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
+ p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
p->size = msize;
p->is_init = GNUNET_NO;
- m = (struct AddressUseMessage*) &p[1];
+ m = (struct AddressUseMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE);
m->header.size = htons (msize);
m->peer = *peer;
- m->in_use = htons(in_use);
+ m->in_use = htons (in_use);
m->address_length = htons (plugin_addr_len);
m->plugin_name_length = htons (namelen);
m->session_id = htonl (get_session_id (sh, session, peer));
pm = (char *) &m[1];
memcpy (pm, plugin_addr, plugin_addr_len);
memcpy (&pm[plugin_addr_len], plugin_name, namelen);
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
do_transmit (sh);
}
@@ -768,10 +727,8 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
void
GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct Session *session)
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session)
{
struct PendingMessage *p;
struct AddressDestroyedMessage *m;
@@ -780,20 +737,19 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
size_t msize;
uint32_t session_id;
- namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1;
- msize = sizeof (struct AddressDestroyedMessage) + plugin_addr_len +
- namelen;
- if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
+ namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1;
+ msize = sizeof (struct AddressDestroyedMessage) + plugin_addr_len + namelen;
+ if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE))
{
GNUNET_break (0);
return;
}
- p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
+ p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
p->size = msize;
p->is_init = GNUNET_NO;
- m = (struct AddressDestroyedMessage*) &p[1];
+ m = (struct AddressDestroyedMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED);
m->header.size = htons (msize);
m->reserved = htonl (0);
@@ -804,9 +760,7 @@ GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
pm = (char *) &m[1];
memcpy (pm, plugin_addr, plugin_addr_len);
memcpy (&pm[plugin_addr_len], plugin_name, namelen);
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head,
- sh->pending_tail,
- p);
+ GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
do_transmit (sh);
remove_session (sh, session_id, peer);
}
diff --git a/src/ats/gnunet-service-ats.c b/src/ats/gnunet-service-ats.c
index 563550ece..ec374aef8 100644
--- a/src/ats/gnunet-service-ats.c
+++ b/src/ats/gnunet-service-ats.c
@@ -48,14 +48,13 @@ struct GNUNET_STATISTICS_Handle *GSA_stats;
*/
static void
handle_ats_start (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
- const struct ClientStartMessage * msg = (const struct ClientStartMessage *) message;
+ const struct ClientStartMessage *msg =
+ (const struct ClientStartMessage *) message;
enum StartFlag flag;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' message\n",
- "ATS_START");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ATS_START");
flag = ntohl (msg->start_flag);
switch (flag)
{
@@ -77,7 +76,7 @@ handle_ats_start (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -131,20 +130,22 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
- { &handle_ats_start, NULL,
- GNUNET_MESSAGE_TYPE_ATS_START, sizeof (struct ClientStartMessage)},
- { &GAS_handle_request_address, NULL,
- GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS, sizeof (struct RequestAddressMessage)},
- { &GAS_handle_address_update, NULL,
- GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0},
- { &GAS_handle_address_in_use, NULL,
- GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE, 0},
- { &GAS_handle_address_destroyed, NULL,
- GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0},
- { &GAS_handle_reservation_request, NULL,
- GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, sizeof (struct ReservationRequestMessage)},
- { &GAS_handle_preference_change, NULL,
- GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0},
+ {&handle_ats_start, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_START, sizeof (struct ClientStartMessage)},
+ {&GAS_handle_request_address, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS,
+ sizeof (struct RequestAddressMessage)},
+ {&GAS_handle_address_update, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0},
+ {&GAS_handle_address_in_use, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE, 0},
+ {&GAS_handle_address_destroyed, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0},
+ {&GAS_handle_reservation_request, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST,
+ sizeof (struct ReservationRequestMessage)},
+ {&GAS_handle_preference_change, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0},
{NULL, NULL, 0, 0}
};
GSA_stats = GNUNET_STATISTICS_create ("ats", cfg);
@@ -152,9 +153,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
GAS_performance_init (server);
GAS_scheduling_init (server);
GAS_addresses_init (cfg);
- GNUNET_SERVER_disconnect_notify (server,
- &client_disconnect_handler,
- NULL);
+ GNUNET_SERVER_disconnect_notify (server, &client_disconnect_handler, NULL);
GNUNET_SERVER_add_handlers (server, handlers);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
NULL);
@@ -172,8 +171,8 @@ int
main (int argc, char *const *argv)
{
return (GNUNET_OK ==
- GNUNET_SERVICE_run (argc, argv, "ats",
- GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
+ GNUNET_SERVICE_run (argc, argv, "ats", GNUNET_SERVICE_OPTION_NONE,
+ &run, NULL)) ? 0 : 1;
}
/* end of gnunet-service-ats.c */
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 99dc0e17a..22304aa6d 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -42,11 +42,11 @@ struct ATS_Address
uint32_t ats_count;
- const void * addr;
+ const void *addr;
- char * plugin;
+ char *plugin;
- struct GNUNET_ATS_Information * ats;
+ struct GNUNET_ATS_Information *ats;
struct GNUNET_TIME_Relative atsp_latency;
@@ -74,7 +74,7 @@ struct ATS_Address
};
-static struct GNUNET_CONTAINER_MultiHashMap * addresses;
+static struct GNUNET_CONTAINER_MultiHashMap *addresses;
static unsigned long long total_quota_in;
@@ -92,10 +92,8 @@ static unsigned int active_addr_count;
* @param value the 'struct ATS_Address'
* @return GNUNET_OK (continue to iterate)
*/
-static int
-update_bw_it (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+update_bw_it (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ATS_Address *aa = value;
@@ -104,24 +102,18 @@ update_bw_it (void *cls,
GNUNET_assert (active_addr_count > 0);
aa->assigned_bw_in.value__ = htonl (total_quota_in / active_addr_count);
aa->assigned_bw_out.value__ = htonl (total_quota_out / active_addr_count);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "New bandwidth for peer %s is %u/%u\n",
- GNUNET_i2s (&aa->peer),
- ntohl (aa->assigned_bw_in.value__),
- ntohl (aa->assigned_bw_out.value__));
- GAS_scheduling_transmit_address_suggestion (&aa->peer,
- aa->plugin,
- aa->addr, aa->addr_len,
- aa->session_id,
- aa->ats, aa->ats_count,
- aa->assigned_bw_out, aa->assigned_bw_in);
- GAS_reservations_set_bandwidth (&aa->peer,
- aa->assigned_bw_in);
- GAS_performance_notify_clients (&aa->peer,
- aa->plugin,
- aa->addr, aa->addr_len,
- aa->ats, aa->ats_count,
- aa->assigned_bw_out, aa->assigned_bw_in);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New bandwidth for peer %s is %u/%u\n",
+ GNUNET_i2s (&aa->peer), ntohl (aa->assigned_bw_in.value__),
+ ntohl (aa->assigned_bw_out.value__));
+ GAS_scheduling_transmit_address_suggestion (&aa->peer, aa->plugin, aa->addr,
+ aa->addr_len, aa->session_id,
+ aa->ats, aa->ats_count,
+ aa->assigned_bw_out,
+ aa->assigned_bw_in);
+ GAS_reservations_set_bandwidth (&aa->peer, aa->assigned_bw_in);
+ GAS_performance_notify_clients (&aa->peer, aa->plugin, aa->addr, aa->addr_len,
+ aa->ats, aa->ats_count, aa->assigned_bw_out,
+ aa->assigned_bw_in);
return GNUNET_OK;
}
@@ -134,18 +126,12 @@ static void
recalculate_assigned_bw ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Recalculating bandwidth for all active connections\n");
- GNUNET_STATISTICS_update (GSA_stats,
- "# bandwidth recalculations performed",
- 1,
- GNUNET_NO);
- GNUNET_STATISTICS_set (GSA_stats,
- "# active addresses",
- active_addr_count,
- GNUNET_NO);
- GNUNET_CONTAINER_multihashmap_iterate (addresses,
- &update_bw_it,
- NULL);
+ "Recalculating bandwidth for all active connections\n");
+ GNUNET_STATISTICS_update (GSA_stats, "# bandwidth recalculations performed",
+ 1, GNUNET_NO);
+ GNUNET_STATISTICS_set (GSA_stats, "# active addresses", active_addr_count,
+ GNUNET_NO);
+ GNUNET_CONTAINER_multihashmap_iterate (addresses, &update_bw_it, NULL);
}
@@ -161,10 +147,10 @@ destroy_address (struct ATS_Address *addr)
int ret;
ret = GNUNET_NO;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove(addresses,
- &addr->peer.hashPubKey,
- addr));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (addresses,
+ &addr->peer.hashPubKey,
+ addr));
if (GNUNET_YES == addr->active)
{
active_addr_count--;
@@ -180,24 +166,22 @@ destroy_address (struct ATS_Address *addr)
struct CompareAddressContext
{
- const struct ATS_Address * search;
- struct ATS_Address * result;
+ const struct ATS_Address *search;
+ struct ATS_Address *result;
};
-static int
-compare_address_it (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+compare_address_it (void *cls, const GNUNET_HashCode * key, void *value)
{
- struct CompareAddressContext * cac = cls;
- struct ATS_Address * aa = value;
-
- if ( ( (aa->addr_len != cac->search->addr_len) ||
- (0 != strcmp(aa->plugin, cac->search->plugin)) ||
- (0 != memcmp (aa->addr, cac->search->addr, aa->addr_len)) ) &&
- ( (aa->session_id != cac->search->session_id) ||
- (cac->search->session_id == 0) ))
+ struct CompareAddressContext *cac = cls;
+ struct ATS_Address *aa = value;
+
+ if (((aa->addr_len != cac->search->addr_len) ||
+ (0 != strcmp (aa->plugin, cac->search->plugin)) ||
+ (0 != memcmp (aa->addr, cac->search->addr, aa->addr_len))) &&
+ ((aa->session_id != cac->search->session_id) ||
+ (cac->search->session_id == 0)))
return GNUNET_YES;
cac->result = aa;
return GNUNET_NO;
@@ -205,7 +189,7 @@ compare_address_it (void *cls,
/**
- * Find an existing equivalent address record.
+ * Find an existing equivalent address record.
* Compares by peer identity and network address OR by session ID
* (one of the two must match).
*
@@ -215,34 +199,31 @@ compare_address_it (void *cls,
*/
struct ATS_Address *
find_address (const struct GNUNET_PeerIdentity *peer,
- const struct ATS_Address * addr)
+ const struct ATS_Address *addr)
{
struct CompareAddressContext cac;
cac.result = NULL;
cac.search = addr;
- GNUNET_CONTAINER_multihashmap_get_multiple(addresses,
- &peer->hashPubKey,
- compare_address_it,
- &cac);
+ GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
+ compare_address_it, &cac);
return cac.result;
}
void
GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count)
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, uint32_t session_id,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
- struct ATS_Address * aa;
- struct ATS_Address * old;
+ struct ATS_Address *aa;
+ struct ATS_Address *old;
uint32_t i;
aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len);
- aa->ats = GNUNET_malloc(atsi_count * sizeof (struct GNUNET_ATS_Information));
+ aa->ats = GNUNET_malloc (atsi_count * sizeof (struct GNUNET_ATS_Information));
aa->peer = *peer;
aa->addr_len = plugin_addr_len;
aa->ats_count = atsi_count;
@@ -256,19 +237,17 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
{
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (addresses,
- &peer->hashPubKey,
- aa,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Added new address for peer `%s' %X\n",
- GNUNET_i2s (peer), aa);
+ &peer->hashPubKey, aa,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' %X\n",
+ GNUNET_i2s (peer), aa);
old = aa;
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Updated existing address for peer `%s' %X \n",
- GNUNET_i2s (peer), old);
+ "Updated existing address for peer `%s' %X \n",
+ GNUNET_i2s (peer), old);
GNUNET_free_non_null (old->ats);
old->session_id = session_id;
old->ats = NULL;
@@ -278,7 +257,7 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
GNUNET_free (aa->plugin);
GNUNET_free (aa);
}
- for (i=0;i<atsi_count;i++)
+ for (i = 0; i < atsi_count; i++)
switch (ntohl (atsi[i].type))
{
case GNUNET_ATS_UTILIZATION_UP:
@@ -304,8 +283,7 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Received unsupported ATS type %u\n",
- ntohl (atsi[i].type));
+ "Received unsupported ATS type %u\n", ntohl (atsi[i].type));
GNUNET_break (0);
break;
}
@@ -314,9 +292,8 @@ GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
void
GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- uint32_t session_id)
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, uint32_t session_id)
{
struct ATS_Address aa;
struct ATS_Address *res;
@@ -324,20 +301,18 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
aa.peer = *peer;
aa.addr_len = plugin_addr_len;
aa.addr = plugin_addr;
- aa.plugin = (char*) plugin_name;
+ aa.plugin = (char *) plugin_name;
aa.session_id = session_id;
res = find_address (peer, &aa);
if (res == NULL)
{
/* we don't even know this one, can this happen? */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to delete unknown address for peer `%s'\n",
- GNUNET_i2s (peer));
- return;
+ "Asked to delete unknown address for peer `%s'\n",
+ GNUNET_i2s (peer));
+ return;
}
- if ( (aa.session_id == session_id) &&
- (session_id != 0) &&
- (res->addr_len > 0) )
+ if ((aa.session_id == session_id) && (session_id != 0) && (res->addr_len > 0))
{
/* just session died */
res->session_id = 0;
@@ -350,10 +325,9 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
return;
}
/* destroy address entirely (either was only session or was
- not even with a session) */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Deleting address for peer `%s': `%s'\n",
- GNUNET_i2s (peer), plugin_name);
+ * not even with a session) */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting address for peer `%s': `%s'\n",
+ GNUNET_i2s (peer), plugin_name);
if (GNUNET_YES == destroy_address (res))
recalculate_assigned_bw ();
}
@@ -362,29 +336,27 @@ GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
/**
* Find a "good" address to use for a peer. If we already have an existing
* address, we stick to it. Otherwise, we pick by lowest distance and then
- * by lowest latency.
- *
+ * by lowest latency.
+ *
* @param cls the 'struct ATS_Address**' where we store the result
* @param key unused
* @param value another 'struct ATS_Address*' to consider using
* @return GNUNET_OK (continue to iterate)
*/
-static int
-find_address_it (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+find_address_it (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ATS_Address **ap = cls;
- struct ATS_Address * aa = (struct ATS_Address *) value;
- struct ATS_Address * ab = *ap;
+ struct ATS_Address *aa = (struct ATS_Address *) value;
+ struct ATS_Address *ab = *ap;
if (NULL == ab)
{
*ap = aa;
return GNUNET_OK;
}
- if ( (ntohl (ab->assigned_bw_in.value__) == 0) &&
- (ntohl (aa->assigned_bw_in.value__) > 0) )
+ if ((ntohl (ab->assigned_bw_in.value__) == 0) &&
+ (ntohl (aa->assigned_bw_in.value__) > 0))
{
/* stick to existing connection */
*ap = aa;
@@ -410,19 +382,16 @@ find_address_it (void *cls,
void
GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
{
- struct ATS_Address * aa;
+ struct ATS_Address *aa;
aa = NULL;
- GNUNET_CONTAINER_multihashmap_get_multiple (addresses,
- &peer->hashPubKey,
- &find_address_it,
- &aa);
+ GNUNET_CONTAINER_multihashmap_get_multiple (addresses, &peer->hashPubKey,
+ &find_address_it, &aa);
if (aa == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cannot suggest address for peer `%s'\n",
- GNUNET_i2s (peer));
- return;
+ "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
+ return;
}
if (aa->active == GNUNET_NO)
{
@@ -433,11 +402,11 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
else
{
/* just to be sure... */
- GAS_scheduling_transmit_address_suggestion (peer, aa->plugin,
- aa->addr, aa->addr_len,
- aa->session_id,
- aa->ats, aa->ats_count,
- aa->assigned_bw_out, aa->assigned_bw_in);
+ GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr,
+ aa->addr_len, aa->session_id,
+ aa->ats, aa->ats_count,
+ aa->assigned_bw_out,
+ aa->assigned_bw_in);
}
}
@@ -446,8 +415,8 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer)
// not with 'addresses' in the future...
void
GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
- enum GNUNET_ATS_PreferenceKind kind,
- float score)
+ enum GNUNET_ATS_PreferenceKind kind,
+ float score)
{
// do nothing for now...
}
@@ -462,16 +431,14 @@ void
GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "core",
- "TOTAL_QUOTA_IN",
- &total_quota_in));
+ GNUNET_CONFIGURATION_get_value_number (cfg, "core",
+ "TOTAL_QUOTA_IN",
+ &total_quota_in));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (cfg,
- "core",
- "TOTAL_QUOTA_OUT",
- &total_quota_out));
- addresses = GNUNET_CONTAINER_multihashmap_create(128);
+ GNUNET_CONFIGURATION_get_value_number (cfg, "core",
+ "TOTAL_QUOTA_OUT",
+ &total_quota_out));
+ addresses = GNUNET_CONTAINER_multihashmap_create (128);
}
@@ -483,12 +450,10 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
* @param value the 'struct ATS_Address' to free
* @return GNUNET_OK (continue to iterate)
*/
-static int
-free_address_it (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+free_address_it (void *cls, const GNUNET_HashCode * key, void *value)
{
- struct ATS_Address * aa = value;
+ struct ATS_Address *aa = value;
destroy_address (aa);
return GNUNET_OK;
@@ -499,8 +464,7 @@ void
GAS_addresses_destroy_all ()
{
if (addresses != NULL)
- GNUNET_CONTAINER_multihashmap_iterate(addresses,
- &free_address_it, NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (addresses, &free_address_it, NULL);
GNUNET_assert (active_addr_count == 0);
}
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index 1d218ba57..7fde42d96 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -28,7 +28,7 @@
#define GNUNET_SERVICE_ATS_ADDRESSES_H
#include "gnunet_util_lib.h"
-#include "gnunet_ats_service.h"
+#include "gnunet_ats_service.h"
#include "ats.h"
/**
@@ -48,18 +48,16 @@ GAS_addresses_done (void);
void
GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count);
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, uint32_t session_id,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count);
void
GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- uint32_t session_id);
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, uint32_t session_id);
void
@@ -78,8 +76,8 @@ GAS_addresses_request_address (const struct GNUNET_PeerIdentity *peer);
// not with 'addresses' in the future...
void
GAS_addresses_change_preference (const struct GNUNET_PeerIdentity *peer,
- enum GNUNET_ATS_PreferenceKind kind,
- float score);
+ enum GNUNET_ATS_PreferenceKind kind,
+ float score);
/* FIXME: add performance request API */
diff --git a/src/ats/gnunet-service-ats_math.h b/src/ats/gnunet-service-ats_math.h
index 1324c30d0..0ec85f3f0 100644
--- a/src/ats/gnunet-service-ats_math.h
+++ b/src/ats/gnunet-service-ats_math.h
@@ -67,11 +67,10 @@
struct ATS_mechanism;
struct ATS_peer;
-typedef void (*GNUNET_ATS_AddressNotification) (struct ATS_peer **
- peers, int *c_p,
- struct ATS_mechanism
- ** mechanisms,
- int *c_m);
+typedef void (*GNUNET_ATS_AddressNotification) (struct ATS_peer ** peers,
+ int *c_p,
+ struct ATS_mechanism **
+ mechanisms, int *c_m);
typedef void (*GNUNET_ATS_ResultCallback) (void);
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index 0fa08ac4b..4b8d23720 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -40,13 +40,13 @@ struct PerformanceClient
/**
* Next in doubly-linked list.
*/
- struct PerformanceClient * next;
+ struct PerformanceClient *next;
/**
* Previous in doubly-linked list.
*/
- struct PerformanceClient * prev;
-
+ struct PerformanceClient *prev;
+
/**
* Actual handle to the client.
*/
@@ -69,7 +69,7 @@ static struct PerformanceClient *pc_head;
* Tail of linked list of all clients to this service.
*/
static struct PerformanceClient *pc_tail;
-
+
/**
* Context for sending messages to performance clients.
*/
@@ -82,10 +82,10 @@ static struct GNUNET_SERVER_NotificationContext *nc;
* @param client server handle
* @return internal handle
*/
-static struct PerformanceClient *
+static struct PerformanceClient *
find_client (struct GNUNET_SERVER_Client *client)
{
- struct PerformanceClient * pc;
+ struct PerformanceClient *pc;
for (pc = pc_head; pc != NULL; pc = pc->next)
if (pc->client == client)
@@ -101,9 +101,9 @@ find_client (struct GNUNET_SERVER_Client *client)
*/
void
GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
- enum StartFlag flag)
+ enum StartFlag flag)
{
- struct PerformanceClient * pc;
+ struct PerformanceClient *pc;
GNUNET_break (NULL == find_client (client));
pc = GNUNET_malloc (sizeof (struct PerformanceClient));
@@ -111,7 +111,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
pc->flag = flag;
GNUNET_SERVER_notification_context_add (nc, client);
GNUNET_SERVER_client_keep (client);
- GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, pc);
+ GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
}
@@ -124,7 +124,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
void
GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
{
- struct PerformanceClient * pc;
+ struct PerformanceClient *pc;
pc = find_client (client);
if (NULL == pc)
@@ -150,25 +150,30 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client)
*/
void
GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
{
struct PerformanceClient *pc;
struct PeerInformationMessage *msg;
size_t plugin_name_length = strlen (plugin_name) + 1;
- size_t msize = sizeof (struct PeerInformationMessage) + atsi_count * sizeof (struct GNUNET_ATS_Information)
- + plugin_addr_len + plugin_name_length;
+ size_t msize =
+ sizeof (struct PeerInformationMessage) +
+ atsi_count * sizeof (struct GNUNET_ATS_Information) + plugin_addr_len +
+ plugin_name_length;
char buf[msize];
struct GNUNET_ATS_Information *atsp;
char *addrp;
GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
- GNUNET_assert (atsi_count < GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information));
- msg = (struct PeerInformationMessage*) buf;
+ GNUNET_assert (atsi_count <
+ GNUNET_SERVER_MAX_MESSAGE_SIZE /
+ sizeof (struct GNUNET_ATS_Information));
+ msg = (struct PeerInformationMessage *) buf;
msg->header.size = htons (msize);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION);
msg->ats_count = htonl (atsi_count);
@@ -177,22 +182,19 @@ GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
msg->plugin_name_length = htons (plugin_name_length);
msg->bandwidth_out = bandwidth_out;
msg->bandwidth_in = bandwidth_in;
- atsp = (struct GNUNET_ATS_Information* ) &msg[1];
+ atsp = (struct GNUNET_ATS_Information *) &msg[1];
memcpy (atsp, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
- addrp = (char*) &atsp[atsi_count];
+ addrp = (char *) &atsp[atsi_count];
memcpy (addrp, plugin_addr, plugin_addr_len);
strcpy (&addrp[plugin_addr_len], plugin_name);
for (pc = pc_head; pc != NULL; pc = pc->next)
if (pc->flag == START_FLAG_PERFORMANCE_WITH_PIC)
{
- GNUNET_SERVER_notification_context_unicast (nc,
- pc->client,
- &msg->header,
- GNUNET_YES);
+ GNUNET_SERVER_notification_context_unicast (nc, pc->client, &msg->header,
+ GNUNET_YES);
GNUNET_STATISTICS_update (GSA_stats,
- "# performance updates given to clients",
- 1,
- GNUNET_NO);
+ "# performance updates given to clients", 1,
+ GNUNET_NO);
}
}
@@ -206,9 +208,10 @@ GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
*/
void
GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
- const struct ReservationRequestMessage * msg = (const struct ReservationRequestMessage *) message;
+ const struct ReservationRequestMessage *msg =
+ (const struct ReservationRequestMessage *) message;
struct ReservationResultMessage result;
int32_t amount;
struct GNUNET_TIME_Relative res_delay;
@@ -220,12 +223,10 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' message\n",
- "RESERVATION_REQUEST");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
+ "RESERVATION_REQUEST");
amount = (int32_t) ntohl (msg->amount);
- res_delay = GAS_reservations_reserve (&msg->peer,
- amount);
+ res_delay = GAS_reservations_reserve (&msg->peer, amount);
if (res_delay.rel_value > 0)
amount = 0;
result.header.size = htons (sizeof (struct ReservationResultMessage));
@@ -233,14 +234,10 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
result.amount = htonl (amount);
result.peer = msg->peer;
result.res_delay = GNUNET_TIME_relative_hton (res_delay);
- GNUNET_STATISTICS_update (GSA_stats,
- "# reservation requests processed",
- 1,
- GNUNET_NO);
- GNUNET_SERVER_notification_context_unicast (nc,
- client,
- &result.header,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSA_stats, "# reservation requests processed", 1,
+ GNUNET_NO);
+ GNUNET_SERVER_notification_context_unicast (nc, client, &result.header,
+ GNUNET_NO);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -254,15 +251,16 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
*/
void
GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
- const struct ChangePreferenceMessage * msg;
+ const struct ChangePreferenceMessage *msg;
const struct PreferenceInformation *pi;
uint16_t msize;
uint32_t nump;
uint32_t i;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "PREFERENCE_CHANGE");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
+ "PREFERENCE_CHANGE");
msize = ntohs (message->size);
if (msize < sizeof (struct ChangePreferenceMessage))
{
@@ -272,21 +270,22 @@ GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
}
msg = (const struct ChangePreferenceMessage *) message;
nump = ntohl (msg->num_preferences);
- if (msize != sizeof (struct ChangePreferenceMessage) + nump * sizeof (struct PreferenceInformation))
+ if (msize !=
+ sizeof (struct ChangePreferenceMessage) +
+ nump * sizeof (struct PreferenceInformation))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_STATISTICS_update (GSA_stats,
- "# preference change requests processed",
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSA_stats, "# preference change requests processed",
+ 1, GNUNET_NO);
pi = (const struct PreferenceInformation *) &msg[1];
- for (i=0;i<nump;i++)
+ for (i = 0; i < nump; i++)
GAS_addresses_change_preference (&msg->peer,
- (enum GNUNET_ATS_PreferenceKind) ntohl (pi[i].preference_kind),
- pi[i].preference_value);
+ (enum GNUNET_ATS_PreferenceKind)
+ ntohl (pi[i].preference_kind),
+ pi[i].preference_value);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
diff --git a/src/ats/gnunet-service-ats_performance.h b/src/ats/gnunet-service-ats_performance.h
index 5988bff44..44d02452b 100644
--- a/src/ats/gnunet-service-ats_performance.h
+++ b/src/ats/gnunet-service-ats_performance.h
@@ -39,7 +39,7 @@
*/
void
GAS_performance_add_client (struct GNUNET_SERVER_Client *client,
- enum StartFlag flag);
+ enum StartFlag flag);
/**
@@ -67,12 +67,14 @@ GAS_performance_remove_client (struct GNUNET_SERVER_Client *client);
*/
void
GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
+ const char *plugin_name,
+ const void *plugin_addr, size_t plugin_addr_len,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in);
/**
@@ -84,7 +86,7 @@ GAS_performance_notify_clients (const struct GNUNET_PeerIdentity *peer,
*/
void
GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+ const struct GNUNET_MessageHeader *message);
/**
@@ -96,7 +98,7 @@ GAS_handle_reservation_request (void *cls, struct GNUNET_SERVER_Client *client,
*/
void
GAS_handle_preference_change (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+ const struct GNUNET_MessageHeader *message);
/**
diff --git a/src/ats/gnunet-service-ats_reservations.c b/src/ats/gnunet-service-ats_reservations.c
index 492751254..f40e54516 100644
--- a/src/ats/gnunet-service-ats_reservations.c
+++ b/src/ats/gnunet-service-ats_reservations.c
@@ -27,7 +27,7 @@
#include "gnunet-service-ats_reservations.h"
/**
- * Number of seconds that available bandwidth carries over
+ * Number of seconds that available bandwidth carries over
* (can accumulate).
*/
#define MAX_BANDWIDTH_CARRY_S 5
@@ -52,32 +52,27 @@ static struct GNUNET_CONTAINER_MultiHashMap *trackers;
*/
struct GNUNET_TIME_Relative
GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
- int32_t amount)
+ int32_t amount)
{
struct GNUNET_BANDWIDTH_Tracker *tracker;
struct GNUNET_TIME_Relative ret;
- tracker = GNUNET_CONTAINER_multihashmap_get (trackers,
- &peer->hashPubKey);
+ tracker = GNUNET_CONTAINER_multihashmap_get (trackers, &peer->hashPubKey);
if (NULL == tracker)
- return GNUNET_TIME_UNIT_ZERO; /* not connected, satisfy now */
+ return GNUNET_TIME_UNIT_ZERO; /* not connected, satisfy now */
if (amount >= 0)
{
- ret = GNUNET_BANDWIDTH_tracker_get_delay (tracker,
- amount);
+ ret = GNUNET_BANDWIDTH_tracker_get_delay (tracker, amount);
if (ret.rel_value > 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delay to satisfy reservation for %d bytes is %llu ms\n",
- (int) amount,
- (unsigned long long) ret.rel_value);
+ "Delay to satisfy reservation for %d bytes is %llu ms\n",
+ (int) amount, (unsigned long long) ret.rel_value);
return ret;
}
}
(void) GNUNET_BANDWIDTH_tracker_consume (tracker, amount);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Reserved %d bytes\n",
- (int) amount);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reserved %d bytes\n", (int) amount);
return GNUNET_TIME_UNIT_ZERO;
}
@@ -85,42 +80,37 @@ GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
/**
* Set the amount of bandwidth the other peer could currently transmit
* to us (as far as we know) to the given value.
- *
+ *
* @param peer identity of the peer
* @param bandwidth_in currently available bandwidth from that peer to
* this peer (estimate)
*/
void
GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
{
struct GNUNET_BANDWIDTH_Tracker *tracker;
- tracker = GNUNET_CONTAINER_multihashmap_get (trackers,
- &peer->hashPubKey);
+ tracker = GNUNET_CONTAINER_multihashmap_get (trackers, &peer->hashPubKey);
if (0 == ntohl (bandwidth_in.value__))
{
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (trackers,
- &peer->hashPubKey,
- tracker));
+ GNUNET_CONTAINER_multihashmap_remove (trackers,
+ &peer->hashPubKey,
+ tracker));
GNUNET_free (tracker);
return;
}
if (NULL == tracker)
{
tracker = GNUNET_malloc (sizeof (struct GNUNET_BANDWIDTH_Tracker));
- GNUNET_BANDWIDTH_tracker_init (tracker,
- bandwidth_in,
- MAX_BANDWIDTH_CARRY_S);
- GNUNET_CONTAINER_multihashmap_put (trackers,
- &peer->hashPubKey,
- tracker,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_BANDWIDTH_tracker_init (tracker, bandwidth_in,
+ MAX_BANDWIDTH_CARRY_S);
+ GNUNET_CONTAINER_multihashmap_put (trackers, &peer->hashPubKey, tracker,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
return;
}
- GNUNET_BANDWIDTH_tracker_update_quota (tracker,
- bandwidth_in);
+ GNUNET_BANDWIDTH_tracker_update_quota (tracker, bandwidth_in);
}
@@ -130,7 +120,7 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer,
void
GAS_reservations_init ()
{
- trackers = GNUNET_CONTAINER_multihashmap_create(128);
+ trackers = GNUNET_CONTAINER_multihashmap_create (128);
}
@@ -142,10 +132,8 @@ GAS_reservations_init ()
* @param value the 'struct GNUNET_BANDWIDTH_Tracker' to free
* @return GNUNET_OK (continue to iterate)
*/
-static int
-free_tracker (void *cls,
- const GNUNET_HashCode * key,
- void *value)
+static int
+free_tracker (void *cls, const GNUNET_HashCode * key, void *value)
{
struct GNUNET_BANDWIDTH_Tracker *tracker = value;
diff --git a/src/ats/gnunet-service-ats_reservations.h b/src/ats/gnunet-service-ats_reservations.h
index 5112f8213..5ddec9bd6 100644
--- a/src/ats/gnunet-service-ats_reservations.h
+++ b/src/ats/gnunet-service-ats_reservations.h
@@ -32,14 +32,15 @@
/**
* Set the amount of bandwidth the other peer could currently transmit
* to us (as far as we know) to the given value.
- *
+ *
* @param peer identity of the peer
* @param bandwidth_in currently available bandwidth from that peer to
* this peer (estimate)
*/
void
GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in);
/**
@@ -55,7 +56,7 @@ GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer,
*/
struct GNUNET_TIME_Relative
GAS_reservations_reserve (const struct GNUNET_PeerIdentity *peer,
- int32_t amount);
+ int32_t amount);
/**
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index bb95182c8..4af44e29b 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/ats/gnunet-service-ats_scheduling.c
@@ -46,7 +46,7 @@ static struct GNUNET_SERVER_Client *my_client;
* Register a new scheduling client.
*
* @param client handle of the new client
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client)
@@ -54,7 +54,7 @@ GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client)
if (my_client != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "This ATS already has a scheduling client, refusing new scheduling client for now.\n");
+ "This ATS already has a scheduling client, refusing new scheduling client for now.\n");
return GNUNET_SYSERR;
}
my_client = client;
@@ -96,32 +96,37 @@ GAS_scheduling_remove_client (struct GNUNET_SERVER_Client *client)
* @param bandwidth_in assigned inbound bandwidth
*/
void
-GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
+GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity
+ *peer, const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Information
+ *atsi, uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in)
{
struct AddressSuggestionMessage *msg;
size_t plugin_name_length = strlen (plugin_name) + 1;
- size_t msize = sizeof (struct AddressSuggestionMessage) + atsi_count * sizeof (struct GNUNET_ATS_Information)
- + plugin_addr_len + plugin_name_length;
+ size_t msize =
+ sizeof (struct AddressSuggestionMessage) +
+ atsi_count * sizeof (struct GNUNET_ATS_Information) + plugin_addr_len +
+ plugin_name_length;
char buf[msize];
struct GNUNET_ATS_Information *atsp;
char *addrp;
if (my_client == NULL)
return;
- GNUNET_STATISTICS_update (GSA_stats,
- "# address suggestions made",
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSA_stats, "# address suggestions made", 1,
+ GNUNET_NO);
GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
- GNUNET_assert (atsi_count < GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information));
- msg = (struct AddressSuggestionMessage*) buf;
+ GNUNET_assert (atsi_count <
+ GNUNET_SERVER_MAX_MESSAGE_SIZE /
+ sizeof (struct GNUNET_ATS_Information));
+ msg = (struct AddressSuggestionMessage *) buf;
msg->header.size = htons (msize);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
msg->ats_count = htonl (atsi_count);
@@ -131,15 +136,13 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe
msg->session_id = htonl (session_id);
msg->bandwidth_out = bandwidth_out;
msg->bandwidth_in = bandwidth_in;
- atsp = (struct GNUNET_ATS_Information* ) &msg[1];
+ atsp = (struct GNUNET_ATS_Information *) &msg[1];
memcpy (atsp, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
- addrp = (char*) &atsp[atsi_count];
+ addrp = (char *) &atsp[atsi_count];
memcpy (addrp, plugin_addr, plugin_addr_len);
strcpy (&addrp[plugin_addr_len], plugin_name);
- GNUNET_SERVER_notification_context_unicast (nc,
- my_client,
- &msg->header,
- GNUNET_YES);
+ GNUNET_SERVER_notification_context_unicast (nc, my_client, &msg->header,
+ GNUNET_YES);
}
@@ -152,16 +155,15 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe
*/
void
GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-
+ const struct GNUNET_MessageHeader *message)
{
- const struct RequestAddressMessage * msg = (const struct RequestAddressMessage *) message;
+ const struct RequestAddressMessage *msg =
+ (const struct RequestAddressMessage *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "REQUEST_ADDRESS");
- GNUNET_STATISTICS_update (GSA_stats,
- "# address requests received",
- 1,
- GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
+ "REQUEST_ADDRESS");
+ GNUNET_STATISTICS_update (GSA_stats, "# address requests received", 1,
+ GNUNET_NO);
GNUNET_break (0 == ntohl (msg->reserved));
GAS_addresses_request_address (&msg->peer);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -177,9 +179,9 @@ GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
*/
void
GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
- const struct AddressUpdateMessage * m;
+ const struct AddressUpdateMessage *m;
const struct GNUNET_ATS_Information *atsi;
const char *address;
const char *plugin_name;
@@ -188,9 +190,8 @@ GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
uint32_t ats_count;
uint16_t size;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' message\n",
- "ADDRESS_UPDATE");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
+ "ADDRESS_UPDATE");
size = ntohs (message->size);
if (size < sizeof (struct AddressUpdateMessage))
{
@@ -198,38 +199,31 @@ GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- m = (const struct AddressUpdateMessage*) message;
+ m = (const struct AddressUpdateMessage *) message;
ats_count = ntohl (m->ats_count);
address_length = ntohs (m->address_length);
- plugin_name_length = ntohs (m->plugin_name_length);
- atsi = (const struct GNUNET_ATS_Information*) &m[1];
- address = (const char*) &atsi[ats_count];
+ plugin_name_length = ntohs (m->plugin_name_length);
+ atsi = (const struct GNUNET_ATS_Information *) &m[1];
+ address = (const char *) &atsi[ats_count];
if (plugin_name_length != 0)
plugin_name = &address[address_length];
else
plugin_name = "";
- if ( (address_length +
- plugin_name_length +
- ats_count * sizeof (struct GNUNET_ATS_Information) +
- sizeof (struct AddressUpdateMessage) != ntohs (message->size)) ||
- (ats_count > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)) ||
- (plugin_name[plugin_name_length - 1] != '\0') )
+ if ((address_length + plugin_name_length +
+ ats_count * sizeof (struct GNUNET_ATS_Information) +
+ sizeof (struct AddressUpdateMessage) != ntohs (message->size)) ||
+ (ats_count >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information))
+ || (plugin_name[plugin_name_length - 1] != '\0'))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_STATISTICS_update (GSA_stats,
- "# address updates received",
- 1,
- GNUNET_NO);
- GAS_addresses_update (&m->peer,
- plugin_name,
- address,
- address_length,
- ntohl (m->session_id),
- atsi,
- ats_count);
+ GNUNET_STATISTICS_update (GSA_stats, "# address updates received", 1,
+ GNUNET_NO);
+ GAS_addresses_update (&m->peer, plugin_name, address, address_length,
+ ntohl (m->session_id), atsi, ats_count);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -245,7 +239,7 @@ void
GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- const struct AddressUseMessage * m;
+ const struct AddressUseMessage *m;
const char *address;
const char *plugin_name;
uint16_t address_length;
@@ -253,8 +247,7 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
uint16_t size;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' message\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
"ADDRESS_IN_USE");
size = ntohs (message->size);
if (size < sizeof (struct AddressUseMessage))
@@ -263,21 +256,20 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- m = (const struct AddressUseMessage*) message;
+ m = (const struct AddressUseMessage *) message;
address_length = ntohs (m->address_length);
plugin_name_length = ntohs (m->plugin_name_length);
- address = (const char*) &m[1];
+ address = (const char *) &m[1];
if (plugin_name_length != 0)
plugin_name = &address[address_length];
else
plugin_name = "";
- if ( (address_length +
- plugin_name_length +
- sizeof (struct AddressUseMessage) != ntohs (message->size)) ||
- (plugin_name[plugin_name_length - 1] != '\0') )
+ if ((address_length + plugin_name_length +
+ sizeof (struct AddressUseMessage) != ntohs (message->size)) ||
+ (plugin_name[plugin_name_length - 1] != '\0'))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -306,10 +298,9 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
*/
void
GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-
+ const struct GNUNET_MessageHeader *message)
{
- const struct AddressDestroyedMessage * m;
+ const struct AddressDestroyedMessage *m;
struct SessionReleaseMessage srm;
const char *address;
const char *plugin_name;
@@ -317,60 +308,50 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
uint16_t plugin_name_length;
uint16_t size;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' message of size %u %u\n",
- "ADDRESS_DESTROYED", ntohs (message->size), sizeof (struct AddressDestroyedMessage));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message of size %u %u\n",
+ "ADDRESS_DESTROYED", ntohs (message->size),
+ sizeof (struct AddressDestroyedMessage));
size = ntohs (message->size);
- if ( (size < sizeof (struct AddressDestroyedMessage)) ||
- (client != my_client) )
+ if ((size < sizeof (struct AddressDestroyedMessage)) || (client != my_client))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- m = (const struct AddressDestroyedMessage*) message;
+ m = (const struct AddressDestroyedMessage *) message;
GNUNET_break (0 == ntohl (m->reserved));
address_length = ntohs (m->address_length);
- plugin_name_length = ntohs (m->plugin_name_length);
- address = (const char*) &m[1];
+ plugin_name_length = ntohs (m->plugin_name_length);
+ address = (const char *) &m[1];
if (plugin_name_length != 0)
plugin_name = &address[address_length];
else
plugin_name = "";
- if ( (address_length +
- plugin_name_length +
- sizeof (struct AddressDestroyedMessage) != ntohs (message->size)))
+ if ((address_length + plugin_name_length +
+ sizeof (struct AddressDestroyedMessage) != ntohs (message->size)))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
- }
- if ( (plugin_name_length != 0) &&
- (plugin_name[plugin_name_length - 1] != '\0') )
+ }
+ if ((plugin_name_length != 0) &&
+ (plugin_name[plugin_name_length - 1] != '\0'))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_STATISTICS_update (GSA_stats,
- "# addresses destroyed",
- 1,
- GNUNET_NO);
- GAS_addresses_destroy (&m->peer,
- plugin_name,
- address,
- address_length,
- ntohl (m->session_id));
+ GNUNET_STATISTICS_update (GSA_stats, "# addresses destroyed", 1, GNUNET_NO);
+ GAS_addresses_destroy (&m->peer, plugin_name, address, address_length,
+ ntohl (m->session_id));
if (0 != ntohl (m->session_id))
{
srm.header.type = ntohs (GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE);
srm.header.size = ntohs (sizeof (struct SessionReleaseMessage));
srm.session_id = m->session_id;
srm.peer = m->peer;
- GNUNET_SERVER_notification_context_unicast (nc,
- client,
- &srm.header,
- GNUNET_NO);
+ GNUNET_SERVER_notification_context_unicast (nc, client, &srm.header,
+ GNUNET_NO);
}
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -382,7 +363,7 @@ GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
* @param server handle to our server
*/
void
-GAS_scheduling_init (struct GNUNET_SERVER_Handle *server)
+GAS_scheduling_init (struct GNUNET_SERVER_Handle *server)
{
nc = GNUNET_SERVER_notification_context_create (server, 128);
}
diff --git a/src/ats/gnunet-service-ats_scheduling.h b/src/ats/gnunet-service-ats_scheduling.h
index 7eeaba8b3..44ac705e3 100644
--- a/src/ats/gnunet-service-ats_scheduling.h
+++ b/src/ats/gnunet-service-ats_scheduling.h
@@ -34,7 +34,7 @@
* Register a new scheduling client.
*
* @param client handle of the new client
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
GAS_scheduling_add_client (struct GNUNET_SERVER_Client *client);
@@ -65,14 +65,17 @@ GAS_scheduling_remove_client (struct GNUNET_SERVER_Client *client);
* @param bandwidth_in assigned inbound bandwidth
*/
void
-GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
+GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity
+ *peer, const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Information
+ *atsi, uint32_t atsi_count,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in);
/**
@@ -84,7 +87,7 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe
*/
void
GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+ const struct GNUNET_MessageHeader *message);
@@ -97,7 +100,7 @@ GAS_handle_request_address (void *cls, struct GNUNET_SERVER_Client *client,
*/
void
GAS_handle_address_update (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+ const struct GNUNET_MessageHeader *message);
/**
@@ -120,7 +123,7 @@ GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
*/
void
GAS_handle_address_destroyed (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+ const struct GNUNET_MessageHeader *message);
/**
diff --git a/src/ats/test_ats_api_bandwidth_consumption.c b/src/ats/test_ats_api_bandwidth_consumption.c
index d2a7b53dc..1eb57fcc8 100644
--- a/src/ats/test_ats_api_bandwidth_consumption.c
+++ b/src/ats/test_ats_api_bandwidth_consumption.c
@@ -44,9 +44,9 @@ static struct GNUNET_ATS_PerformanceHandle *atp;
struct GNUNET_ATS_ReservationContext *sh;
-static struct GNUNET_OS_Process * arm_proc;
+static struct GNUNET_OS_Process *arm_proc;
-static struct PeerContext * p;
+static struct PeerContext *p;
static uint32_t bw_in;
@@ -56,23 +56,23 @@ static int ret;
struct Address
{
- char * plugin;
+ char *plugin;
size_t plugin_len;
- void * addr;
+ void *addr;
size_t addr_len;
- struct GNUNET_ATS_Information * ats;
+ struct GNUNET_ATS_Information *ats;
int ats_count;
- void *session;
+ void *session;
};
struct PeerContext
{
struct GNUNET_PeerIdentity id;
- struct Address * addr;
+ struct Address *addr;
};
@@ -94,12 +94,12 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (consume_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(consume_task);
+ GNUNET_SCHEDULER_cancel (consume_task);
consume_task = GNUNET_SCHEDULER_NO_TASK;
}
if (sh != NULL)
- GNUNET_ATS_reserve_bandwidth_cancel(sh);
+ GNUNET_ATS_reserve_bandwidth_cancel (sh);
if (ats != NULL)
GNUNET_ATS_scheduling_done (ats);
@@ -120,13 +120,13 @@ end ()
{
if (die_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(die_task);
+ GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
if (consume_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(consume_task);
+ GNUNET_SCHEDULER_cancel (consume_task);
consume_task = GNUNET_SCHEDULER_NO_TASK;
}
@@ -142,41 +142,25 @@ end ()
stop_arm ();
}
-void performance_cb (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_in,
- const struct
- GNUNET_ATS_Information
- * ats,
- uint32_t ats_count)
+void
+performance_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
}
-void reservation_cb (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- int32_t amount,
- struct
- GNUNET_TIME_Relative
- res_delay)
+void
+reservation_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
+ int32_t amount, struct GNUNET_TIME_Relative res_delay)
{
sh = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS reserved bandwidth of %i to peer `%s' in %llu ms\n",
- amount,
- GNUNET_i2s (peer),
- res_delay.rel_value);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "ATS reserved bandwidth of %i to peer `%s' in %llu ms\n", amount,
+ GNUNET_i2s (peer), res_delay.rel_value);
}
static void
@@ -184,51 +168,43 @@ consume_bandwidth (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
consume_task = GNUNET_SCHEDULER_NO_TASK;
int32_t to_reserve = 500;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to reserver bandwidth of %i to peer `%s' in %llu ms\n",
- to_reserve,
- GNUNET_i2s (&p->id));
- sh = GNUNET_ATS_reserve_bandwidth (atp, &p->id, to_reserve, &reservation_cb, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to reserver bandwidth of %i to peer `%s' in %llu ms\n",
+ to_reserve, GNUNET_i2s (&p->id));
+
+ sh = GNUNET_ATS_reserve_bandwidth (atp, &p->id, to_reserve, &reservation_cb,
+ NULL);
}
static void
-address_suggest_cb (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct Session * session,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_in,
- const struct
- GNUNET_ATS_Information
- * ats,
+address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
-
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggested address for peer `%s'\n", GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggested address for peer `%s'\n",
+ GNUNET_i2s (peer));
bw_in = ntohl (bandwidth_in.value__);
bw_out = ntohl (bandwidth_out.value__);
- consume_task = GNUNET_SCHEDULER_add_now(&consume_bandwidth, NULL);
+ consume_task = GNUNET_SCHEDULER_add_now (&consume_bandwidth, NULL);
}
void
start_arm (const char *cfgname)
{
- 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_ARM
- "-L", "DEBUG",
+ "-L", "DEBUG",
#endif
- "-c", cfgname, NULL);
+ "-c", cfgname, NULL);
}
static void
@@ -238,7 +214,7 @@ check (void *cls, char *const *args, const char *cfgfile,
ret = GNUNET_SYSERR;
struct Address *addr;
- die_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
start_arm (cfgfile);
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
@@ -257,25 +233,28 @@ check (void *cls, char *const *args, const char *cfgfile,
{
ret = GNUNET_SYSERR;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init ATS performance\n");
- end_badly(NULL, NULL);
+ end_badly (NULL, NULL);
GNUNET_free (p);
GNUNET_free (addr);
return;
}
/* set up peer */
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p->id.hashPubKey);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
+ &p->id.hashPubKey);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
+ GNUNET_i2s (&p->id));
p->addr = addr;
addr->plugin = "test";
addr->session = NULL;
addr->addr = NULL;
addr->addr_len = 0;
- GNUNET_ATS_address_update(ats, &p->id, addr->plugin, addr->addr, addr->addr_len, addr->session, NULL, 0);
+ GNUNET_ATS_address_update (ats, &p->id, addr->plugin, addr->addr,
+ addr->addr_len, addr->session, NULL, 0);
- GNUNET_ATS_suggest_address(ats, &p->id);
+ GNUNET_ATS_suggest_address (ats, &p->id);
}
int
@@ -297,8 +276,8 @@ main (int argc, char *argv[])
};
GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_ats_api_bandwidth_consumption", "nohelp", options, &check,
- NULL);
+ "test_ats_api_bandwidth_consumption", "nohelp", options,
+ &check, NULL);
return ret;
diff --git a/src/ats/test_ats_api_scheduling.c b/src/ats/test_ats_api_scheduling.c
index 201855283..a2ee7f060 100644
--- a/src/ats/test_ats_api_scheduling.c
+++ b/src/ats/test_ats_api_scheduling.c
@@ -44,7 +44,7 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static struct GNUNET_ATS_SchedulingHandle *ats;
-struct GNUNET_OS_Process * arm_proc;
+struct GNUNET_OS_Process *arm_proc;
@@ -52,23 +52,23 @@ static int ret;
struct Address
{
- char * plugin;
+ char *plugin;
size_t plugin_len;
- void * addr;
+ void *addr;
size_t addr_len;
- struct GNUNET_ATS_Information * ats;
+ struct GNUNET_ATS_Information *ats;
int ats_count;
- void *session;
+ void *session;
};
struct PeerContext
{
struct GNUNET_PeerIdentity id;
- struct Address * addr;
+ struct Address *addr;
};
struct Address addr[2];
@@ -105,7 +105,7 @@ end ()
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
if (die_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel(die_task);
+ GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
@@ -118,29 +118,19 @@ end ()
static void
-address_suggest_cb (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct Session * session,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_in,
- const struct
- GNUNET_ATS_Information
- * ats,
+address_suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ const struct GNUNET_ATS_Information *ats,
uint32_t ats_count)
-
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n", GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS suggests address `%s'\n",
+ GNUNET_i2s (peer));
- GNUNET_assert (0 == memcmp (peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity)));
+ GNUNET_assert (0 ==
+ memcmp (peer, &p[0].id, sizeof (struct GNUNET_PeerIdentity)));
GNUNET_assert (0 == strcmp (plugin_name, addr[0].plugin));
GNUNET_assert (plugin_addr_len == addr[0].addr_len);
GNUNET_assert (0 == memcmp (plugin_addr, addr[0].plugin, plugin_addr_len));
@@ -148,27 +138,28 @@ address_suggest_cb (void *cls,
/* TODO ats merge
- GNUNET_assert (ats_count == 2);
- GNUNET_assert (atsi[0].type == htons (1));
- GNUNET_assert (atsi[0].type == htons (2));
- GNUNET_assert (atsi[1].type == htons (2));
- GNUNET_assert (atsi[1].type == htons (2));
- */
+ * GNUNET_assert (ats_count == 2);
+ * GNUNET_assert (atsi[0].type == htons (1));
+ * GNUNET_assert (atsi[0].type == htons (2));
+ * GNUNET_assert (atsi[1].type == htons (2));
+ * GNUNET_assert (atsi[1].type == htons (2));
+ */
ret = 0;
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
}
void
start_arm (const char *cfgname)
{
- 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_ARM
- "-L", "DEBUG",
+ "-L", "DEBUG",
#endif
- "-c", cfgname, NULL);
+ "-c", cfgname, NULL);
}
static void
@@ -177,7 +168,7 @@ check (void *cls, char *const *args, const char *cfgfile,
{
ret = GNUNET_SYSERR;
- die_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &end_badly, NULL);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
start_arm (cfgfile);
ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
@@ -190,27 +181,33 @@ check (void *cls, char *const *args, const char *cfgfile,
}
/* set up peer */
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[0].id.hashPubKey);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s (&p[0].id));
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
+ &p[0].id.hashPubKey);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
+ GNUNET_i2s (&p[0].id));
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[1].id.hashPubKey);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", GNUNET_i2s (&p[1].id));
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
+ &p[1].id.hashPubKey);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
+ GNUNET_i2s (&p[1].id));
addr[0].plugin = "test";
addr[0].session = NULL;
- addr[0].addr = strdup("test");
+ addr[0].addr = strdup ("test");
addr[0].addr_len = 4;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing address creation\n");
- GNUNET_ATS_address_update(ats, &p[0].id, addr[0].plugin, addr[0].addr, addr[0].addr_len, addr[0].session, NULL, 0);
+ GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr,
+ addr[0].addr_len, addr[0].session, NULL, 0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info creation\n");
atsi[0].type = htonl (GNUNET_ATS_UTILIZATION_UP);
atsi[0].value = htonl (1024);
- GNUNET_ATS_address_update(ats, &p[0].id, addr[0].plugin, addr[0].addr, addr[0].addr_len, addr[0].session, atsi, 1);
+ GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr,
+ addr[0].addr_len, addr[0].session, atsi, 1);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing ATS info update\n");
@@ -220,14 +217,18 @@ check (void *cls, char *const *args, const char *cfgfile,
atsi[1].type = htonl (GNUNET_ATS_UTILIZATION_DOWN);
atsi[1].value = htonl (1024);
- GNUNET_ATS_address_update(ats, &p[0].id, addr[0].plugin, addr[0].addr, addr[0].addr_len, addr[0].session, atsi, 2);
+ GNUNET_ATS_address_update (ats, &p[0].id, addr[0].plugin, addr[0].addr,
+ addr[0].addr_len, addr[0].session, atsi, 2);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing manual address deletion \n");
- GNUNET_ATS_address_update(ats, &p[1].id, addr[0].plugin, addr[0].addr, addr[0].addr_len, addr[0].session, NULL, 0);
- GNUNET_ATS_address_destroyed (ats, &p[1].id, addr[0].plugin, addr[0].addr, addr[0].addr_len, addr[0].session );
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting peer `%s'\n", GNUNET_i2s (&p[0].id));
- GNUNET_ATS_suggest_address(ats, &p[0].id);
+ GNUNET_ATS_address_update (ats, &p[1].id, addr[0].plugin, addr[0].addr,
+ addr[0].addr_len, addr[0].session, NULL, 0);
+ GNUNET_ATS_address_destroyed (ats, &p[1].id, addr[0].plugin, addr[0].addr,
+ addr[0].addr_len, addr[0].session);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting peer `%s'\n",
+ GNUNET_i2s (&p[0].id));
+ GNUNET_ATS_suggest_address (ats, &p[0].id);
}
int
diff --git a/src/ats/test_ats_api_update_address.c b/src/ats/test_ats_api_update_address.c
index 78011d492..f23747962 100644
--- a/src/ats/test_ats_api_update_address.c
+++ b/src/ats/test_ats_api_update_address.c
@@ -121,8 +121,7 @@ suggest_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
const char *plugin_name, const void *plugin_addr,
size_t plugin_addr_len, struct Session *session,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
struct ExpectedValues *ex = cls;
diff --git a/src/block/block.c b/src/block/block.c
index 582c13eb3..7c447f072 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -96,17 +96,14 @@ GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, uint32_t mingle_number,
* @param lib_ret the plugin API
*/
static void
-add_plugin (void *cls,
- const char *library_name,
- void *lib_ret)
+add_plugin (void *cls, const char *library_name, void *lib_ret)
{
struct GNUNET_BLOCK_Context *ctx = cls;
struct GNUNET_BLOCK_PluginFunctions *api = lib_ret;
struct Plugin *plugin;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Loading block plugin `%s'\n"),
- library_name);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading block plugin `%s'\n"),
+ library_name);
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->api = api;
plugin->library_name = GNUNET_strdup (library_name);
@@ -128,10 +125,7 @@ GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context));
ctx->cfg = cfg;
- GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_",
- NULL,
- &add_plugin,
- ctx);
+ GNUNET_PLUGIN_load_all ("libgnunet_plugin_block_", NULL, &add_plugin, ctx);
return ctx;
}
@@ -147,7 +141,7 @@ GNUNET_BLOCK_context_destroy (struct GNUNET_BLOCK_Context *ctx)
unsigned int i;
struct Plugin *plugin;
- for (i = 0; i<ctx->num_plugins;i++)
+ for (i = 0; i < ctx->num_plugins; i++)
{
plugin = ctx->plugins[i];
GNUNET_break (NULL ==
@@ -174,7 +168,7 @@ find_plugin (struct GNUNET_BLOCK_Context *ctx, enum GNUNET_BLOCK_Type type)
unsigned int i;
unsigned int j;
- for (i=0;i<ctx->num_plugins;i++)
+ for (i = 0; i < ctx->num_plugins; i++)
{
plugin = ctx->plugins[i];
j = 0;
@@ -291,8 +285,8 @@ compute_bloomfilter_size (unsigned int entry_count)
*/
struct GNUNET_CONTAINER_BloomFilter *
GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator,
- const GNUNET_HashCode *seen_results,
- unsigned int seen_results_count)
+ const GNUNET_HashCode * seen_results,
+ unsigned int seen_results_count)
{
struct GNUNET_CONTAINER_BloomFilter *bf;
GNUNET_HashCode mhash;
@@ -300,7 +294,8 @@ GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator,
size_t nsize;
nsize = compute_bloomfilter_size (seen_results_count);
- bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize, GNUNET_CONSTANTS_BLOOMFILTER_K);
+ bf = GNUNET_CONTAINER_bloomfilter_init (NULL, nsize,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
for (i = 0; i < seen_results_count; i++)
{
GNUNET_BLOCK_mingle_hash (&seen_results[i], bf_mutator, &mhash);
diff --git a/src/block/plugin_block_dht.c b/src/block/plugin_block_dht.c
index c58615b72..f574e6d06 100644
--- a/src/block/plugin_block_dht.c
+++ b/src/block/plugin_block_dht.c
@@ -77,19 +77,21 @@ block_plugin_dht_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
if (NULL != bf)
+ {
+ GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash);
+ if (NULL != *bf)
+ {
+ if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
+ return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
+ }
+ else
{
- GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash);
- if (NULL != *bf)
- {
- if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- }
- else
- {
- *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, GNUNET_CONSTANTS_BLOOMFILTER_K);
- }
- GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
+ *bf =
+ GNUNET_CONTAINER_bloomfilter_init (NULL, 8,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
}
+ GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
+ }
return GNUNET_BLOCK_EVALUATION_OK_MORE;
}
diff --git a/src/block/plugin_block_dns.c b/src/block/plugin_block_dns.c
index 8e8aa3047..b33b3798a 100644
--- a/src/block/plugin_block_dns.c
+++ b/src/block/plugin_block_dns.c
@@ -86,7 +86,8 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
}
if (GNUNET_TIME_relative_get_zero ().rel_value ==
- GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (rec->expiration_time)).rel_value)
+ GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
+ (rec->expiration_time)).rel_value)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DNS-Block is invalid: Timeout\n");
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
diff --git a/src/block/plugin_block_fs.c b/src/block/plugin_block_fs.c
index 5a0e90a92..c1b4ad7c8 100644
--- a/src/block/plugin_block_fs.c
+++ b/src/block/plugin_block_fs.c
@@ -91,20 +91,20 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
if (reply_block == NULL)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
if (NULL != bf)
+ {
+ GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
+ GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
+ if (NULL != *bf)
+ {
+ if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
+ return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
+ }
+ else
{
- GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
- GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
- if (NULL != *bf)
- {
- if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- }
- else
- {
- *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
- }
- GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
+ *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
}
+ GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
+ }
return GNUNET_BLOCK_EVALUATION_OK_MORE;
case GNUNET_BLOCK_TYPE_FS_SBLOCK:
if (xquery_size != sizeof (GNUNET_HashCode))
@@ -132,20 +132,20 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
if (NULL != bf)
+ {
+ GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
+ GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
+ if (NULL != *bf)
+ {
+ if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
+ return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
+ }
+ else
{
- GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
- GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
- if (NULL != *bf)
- {
- if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- }
- else
- {
- *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
- }
- GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
+ *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
}
+ GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
+ }
return GNUNET_BLOCK_EVALUATION_OK_MORE;
default:
return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index 0c769b837..08d3096dc 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -75,14 +75,14 @@ block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
if (NULL != *bf)
- {
- if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- }
+ {
+ if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
+ return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
+ }
else
- {
- *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
- }
+ {
+ *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
+ }
GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
}
return GNUNET_BLOCK_EVALUATION_OK_MORE;
diff --git a/src/chat/gnunet-service-chat.c b/src/chat/gnunet-service-chat.c
index a3637e454..fb127b2f0 100644
--- a/src/chat/gnunet-service-chat.c
+++ b/src/chat/gnunet-service-chat.c
@@ -989,9 +989,8 @@ static int
handle_p2p_join_notification (void *cls,
const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
const struct P2PJoinNotificationMessage *p2p_jnmsg;
char *room_name;
@@ -1107,9 +1106,8 @@ static int
handle_p2p_leave_notification (void *cls,
const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
const struct P2PLeaveNotificationMessage *p2p_lnmsg;
GNUNET_HashCode id;
@@ -1190,9 +1188,8 @@ static int
handle_p2p_message_notification (void *cls,
const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
const struct P2PReceiveNotificationMessage *p2p_rnmsg;
struct P2PReceiveNotificationMessage *my_p2p_rnmsg;
@@ -1343,7 +1340,7 @@ static int
handle_p2p_sync_request (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct ChatClient *entry;
struct GNUNET_CORE_TransmitHandle *th;
@@ -1386,9 +1383,8 @@ static int
handle_p2p_confirmation_receipt (void *cls,
const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
const struct P2PConfirmationReceiptMessage *p2p_crmsg;
struct P2PConfirmationReceiptMessage *my_p2p_crmsg;
@@ -1530,7 +1526,7 @@ transmit_sync_request_to_peer (void *cls, size_t size, void *buf)
static void
peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct ConnectedPeer *cp;
struct GNUNET_CORE_TransmitHandle *th;
@@ -1716,8 +1712,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
core =
GNUNET_CORE_connect (cfg, QUEUE_SIZE, NULL, &core_init,
&peer_connect_handler, &peer_disconnect_handler,
- NULL, GNUNET_NO, NULL, GNUNET_NO,
- p2p_handlers);
+ 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);
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 57c2932a2..f3f4cea54 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -781,7 +781,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
const struct GNUNET_MessageHeader *em;
const struct SendMessageReady *smr;
const struct GNUNET_CORE_MessageHandler *mh;
- const struct GNUNET_ATS_Information* ats;
+ const struct GNUNET_ATS_Information *ats;
GNUNET_CORE_StartupCallback init;
struct PeerRecord *pr;
struct GNUNET_CORE_TransmitHandle *th;
@@ -864,8 +864,8 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
cnm = (const struct ConnectNotifyMessage *) msg;
ats_count = ntohl (cnm->ats_count);
if (msize !=
- sizeof (struct ConnectNotifyMessage) +
- ats_count * sizeof (struct GNUNET_ATS_Information))
+ sizeof (struct ConnectNotifyMessage) +
+ ats_count * sizeof (struct GNUNET_ATS_Information))
{
GNUNET_break (0);
reconnect_later (h);
@@ -896,11 +896,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
GNUNET_CONTAINER_multihashmap_put (h->peers,
&cnm->peer.hashPubKey, pr,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
- ats = (const struct GNUNET_ATS_Information*) &cnm[1];
+ ats = (const struct GNUNET_ATS_Information *) &cnm[1];
if (NULL != h->connects)
- h->connects (h->cls, &cnm->peer,
- ats,
- ats_count);
+ h->connects (h->cls, &cnm->peer, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT:
if (msize != sizeof (struct DisconnectNotifyMessage))
@@ -949,8 +947,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
sizeof (struct NotifyTrafficMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information) +
sizeof (struct GNUNET_MessageHeader)) ||
- (GNUNET_ATS_ARRAY_TERMINATOR !=
- ntohl ((&ntm->ats)[ats_count].type)))
+ (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
{
GNUNET_break (0);
reconnect_later (h);
@@ -986,23 +983,22 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
continue;
if ((mh->expected_size != ntohs (em->size)) && (mh->expected_size != 0))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected message size for message of type %u\n",
- mh->type);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected message size for message of type %u\n",
+ mh->type);
GNUNET_break_op (0);
continue;
}
if (GNUNET_OK !=
h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats,
- ats_count))
+ ats_count))
{
/* error in processing, do not process other messages! */
break;
}
}
if (NULL != h->inbound_notify)
- h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats,
- ats_count);
+ h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND:
if (msize < sizeof (struct NotifyTrafficMessage))
@@ -1023,8 +1019,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
sizeof (struct NotifyTrafficMessage) +
ats_count * sizeof (struct GNUNET_ATS_Information) +
sizeof (struct GNUNET_MessageHeader)) ||
- (GNUNET_ATS_ARRAY_TERMINATOR !=
- ntohl ((&ntm->ats)[ats_count].type)))
+ (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
{
GNUNET_break (0);
reconnect_later (h);
diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c
index 7bf40a678..7b28842fd 100644
--- a/src/core/core_api_iterate_peers.c
+++ b/src/core/core_api_iterate_peers.c
@@ -101,7 +101,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg)
ats_count = ntohl (connect_message->ats_count);
if (msize !=
sizeof (struct ConnectNotifyMessage) +
- ats_count * sizeof (struct GNUNET_ATS_Information))
+ ats_count * sizeof (struct GNUNET_ATS_Information))
{
GNUNET_break (0);
if (request_context->peer_cb != NULL)
@@ -113,8 +113,8 @@ 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,
- (const struct GNUNET_ATS_Information *) &connect_message[1],
- ats_count);
+ (const struct GNUNET_ATS_Information *)
+ &connect_message[1], ats_count);
GNUNET_CLIENT_receive (request_context->client, &receive_info,
request_context, GNUNET_TIME_UNIT_FOREVER_REL);
}
diff --git a/src/core/gnunet-core-list-connections.c b/src/core/gnunet-core-list-connections.c
index 9665110a3..79490bcc5 100644
--- a/src/core/gnunet-core-list-connections.c
+++ b/src/core/gnunet-core-list-connections.c
@@ -124,7 +124,7 @@ process_resolved_address (void *cls, const char *address)
static void
connected_peer_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct PrintContext *pc;
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 5bec671ec..2eb71c257 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -57,8 +57,7 @@ static void
cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service shutting down.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service shutting down.\n");
#endif
GSC_CLIENTS_done ();
GSC_NEIGHBOURS_done ();
@@ -85,13 +84,12 @@ static void
run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- GSC_cfg = c;
+ GSC_cfg = c;
GSC_stats = GNUNET_STATISTICS_create ("core", GSC_cfg);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task,
NULL);
GSC_TYPEMAP_init ();
- if ( (GNUNET_OK != GSC_KX_init ()) ||
- (GNUNET_OK != GSC_NEIGHBOURS_init ()) )
+ if ((GNUNET_OK != GSC_KX_init ()) || (GNUNET_OK != GSC_NEIGHBOURS_init ()))
{
GNUNET_SCHEDULER_shutdown ();
return;
diff --git a/src/core/gnunet-service-core.h b/src/core/gnunet-service-core.h
index d4e43a457..e48ad8bad 100644
--- a/src/core/gnunet-service-core.h
+++ b/src/core/gnunet-service-core.h
@@ -37,7 +37,7 @@ struct GSC_Client;
/**
* Record kept for each request for transmission issued by a
- * client that is still pending. (This struct is used by
+ * client that is still pending. (This struct is used by
* both the 'CLIENTS' and 'SESSIONS' subsystems.)
*/
struct GSC_ClientActiveRequest
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c
index 22201514a..3201b71f0 100644
--- a/src/core/gnunet-service-core_clients.c
+++ b/src/core/gnunet-service-core_clients.c
@@ -146,9 +146,8 @@ find_client (struct GNUNET_SERVER_Client *client)
* client's queue is getting too large?
*/
static void
-send_to_client (struct GSC_Client *client,
- const struct GNUNET_MessageHeader *msg,
- int can_drop)
+send_to_client (struct GSC_Client *client,
+ const struct GNUNET_MessageHeader *msg, int can_drop)
{
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -171,8 +170,8 @@ send_to_client (struct GSC_Client *client,
*/
void
GSC_CLIENTS_send_to_client (struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *msg,
- int can_drop)
+ const struct GNUNET_MessageHeader *msg,
+ int can_drop)
{
struct GSC_Client *c;
@@ -194,14 +193,13 @@ GSC_CLIENTS_send_to_client (struct GNUNET_SERVER_Client *client,
* @return GNUNET_YES if 'c' is interested, GNUNET_NO if not.
*/
static int
-type_match (uint16_t type,
- struct GSC_Client *c)
+type_match (uint16_t type, struct GSC_Client *c)
{
unsigned int i;
if (c->tcnt == 0)
- return GNUNET_YES; /* peer without handlers matches ALL */
- for (i=0;i<c->tcnt;i++)
+ return GNUNET_YES; /* peer without handlers matches ALL */
+ for (i = 0; i < c->tcnt; i++)
if (type == c->types[i])
return GNUNET_YES;
return GNUNET_NO;
@@ -219,30 +217,27 @@ type_match (uint16_t type,
*/
static void
send_to_all_clients (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_MessageHeader *msg,
- int can_drop,
- int options,
- uint16_t type)
+ const struct GNUNET_MessageHeader *msg, int can_drop,
+ int options, uint16_t type)
{
struct GSC_Client *c;
for (c = client_head; c != NULL; c = c->next)
{
- if ( (0 == (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) &&
- (GNUNET_YES == type_match (type, c)) )
- continue; /* not the full message, but we'd like the full one! */
- if ( (0 == (c->options & options)) &&
- (GNUNET_YES != type_match (type, c)) )
- continue; /* neither options nor type match permit the message */
+ if ((0 == (options & GNUNET_CORE_OPTION_SEND_FULL_INBOUND)) &&
+ (GNUNET_YES == type_match (type, c)))
+ continue; /* not the full message, but we'd like the full one! */
+ if ((0 == (c->options & options)) && (GNUNET_YES != type_match (type, c)))
+ continue; /* neither options nor type match permit the message */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending message to client interested in messages of type %u.\n",
- (unsigned int) type);
+ "Sending message to client interested in messages of type %u.\n",
+ (unsigned int) type);
#endif
#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
- &sender->hashPubKey));
+ GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
+ &sender->hashPubKey));
#endif
send_to_client (c, msg, can_drop);
}
@@ -295,22 +290,20 @@ handle_client_init (void *cls, struct GNUNET_SERVER_Client *client,
#if DEBUG_CONNECTS
c->connectmap = GNUNET_CONTAINER_multihashmap_create (16);
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_put (c->connectmap,
- &GSC_my_identity.hashPubKey,
- NULL,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multihashmap_put (c->connectmap,
+ &GSC_my_identity.hashPubKey,
+ NULL,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
#endif
wtypes = (uint16_t *) & c[1];
for (i = 0; i < c->tcnt; i++)
wtypes[i] = ntohs (types[i]);
GSC_TYPEMAP_add (wtypes, c->tcnt);
- GNUNET_CONTAINER_DLL_insert (client_head,
- client_tail,
- c);
+ GNUNET_CONTAINER_DLL_insert (client_head, client_tail, c);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client connecting to core service is interested in %u message types\n",
+ "Client connecting to core service is interested in %u message types\n",
(unsigned int) c->tcnt);
#endif
/* send init reply message */
@@ -352,8 +345,8 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
c->requests = GNUNET_CONTAINER_multihashmap_create (16);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client asked for transmission to `%s'\n",
- GNUNET_i2s (&req->peer));
+ "Client asked for transmission to `%s'\n",
+ GNUNET_i2s (&req->peer));
#endif
car = GNUNET_CONTAINER_multihashmap_get (c->requests, &req->peer.hashPubKey);
if (car == NULL)
@@ -378,7 +371,8 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
car->smr_id = req->smr_id;
car->was_solicited = GNUNET_NO;
if (0 ==
- memcmp (&req->peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ memcmp (&req->peer, &GSC_my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
GSC_CLIENTS_solicit_request (car);
else
GSC_SESSIONS_queue_request (car);
@@ -394,7 +388,7 @@ struct TokenizerContext
/**
* Active request handle for the message.
- */
+ */
struct GSC_ClientActiveRequest *car;
/**
@@ -440,42 +434,39 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- tc.car = GNUNET_CONTAINER_multihashmap_get (c->requests, &sm->peer.hashPubKey);
+ tc.car =
+ GNUNET_CONTAINER_multihashmap_get (c->requests, &sm->peer.hashPubKey);
if (NULL == tc.car)
{
/* Must have been that we first approved the request, then got disconnected
- (which triggered removal of the 'car') and now the client gives us a message
- just *before* the client learns about the disconnect. Theoretically, we
- might also now be *again* connected. So this can happen (but should be
- rare). If it does happen, the message is discarded. */
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# messages discarded (session disconnected)"),
- 1,
- GNUNET_NO);
+ * (which triggered removal of the 'car') and now the client gives us a message
+ * just *before* the client learns about the disconnect. Theoretically, we
+ * might also now be *again* connected. So this can happen (but should be
+ * rare). If it does happen, the message is discarded. */
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop
+ ("# messages discarded (session disconnected)"),
+ 1, GNUNET_NO);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (c->requests,
- &sm->peer.hashPubKey,
- tc.car));
+ GNUNET_CONTAINER_multihashmap_remove (c->requests,
+ &sm->peer.hashPubKey,
+ tc.car));
tc.cork = ntohl (sm->cork);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client asked for transmission of %u bytes to `%s' %s\n",
- msize,
- GNUNET_i2s (&sm->peer),
- tc.cork ? "now" : "");
+ "Client asked for transmission of %u bytes to `%s' %s\n", msize,
+ GNUNET_i2s (&sm->peer), tc.cork ? "now" : "");
#endif
- GNUNET_SERVER_mst_receive (client_mst,
- &tc,
- (const char*) &sm[1], msize,
- GNUNET_YES,
- GNUNET_NO);
+ GNUNET_SERVER_mst_receive (client_mst, &tc, (const char *) &sm[1], msize,
+ GNUNET_YES, GNUNET_NO);
if (0 !=
- memcmp (&tc.car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ memcmp (&tc.car->target, &GSC_my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
GSC_SESSIONS_dequeue_request (tc.car);
- GNUNET_free (tc.car);
+ GNUNET_free (tc.car);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -492,37 +483,35 @@ handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
*/
static void
client_tokenizer_callback (void *cls, void *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
struct TokenizerContext *tc = client;
struct GSC_ClientActiveRequest *car = tc->car;
if (0 ==
- memcmp (&car->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ memcmp (&car->target, &GSC_my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
{
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delivering message of type %u to myself\n",
- ntohs (message->type));
+ "Delivering message of type %u to myself\n",
+ ntohs (message->type));
#endif
- GSC_CLIENTS_deliver_message (&GSC_my_identity,
- NULL, 0,
- message,
- ntohs (message->size),
- GNUNET_CORE_OPTION_SEND_FULL_INBOUND | GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
- GSC_CLIENTS_deliver_message (&GSC_my_identity,
- NULL, 0,
- message,
- sizeof (struct GNUNET_MessageHeader),
- GNUNET_CORE_OPTION_SEND_HDR_INBOUND | GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
+ GSC_CLIENTS_deliver_message (&GSC_my_identity, NULL, 0, message,
+ ntohs (message->size),
+ GNUNET_CORE_OPTION_SEND_FULL_INBOUND |
+ GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
+ GSC_CLIENTS_deliver_message (&GSC_my_identity, NULL, 0, message,
+ sizeof (struct GNUNET_MessageHeader),
+ GNUNET_CORE_OPTION_SEND_HDR_INBOUND |
+ GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
}
else
{
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delivering message of type %u to %s\n",
- ntohs (message->type),
- GNUNET_i2s (&car->target));
+ "Delivering message of type %u to %s\n", ntohs (message->type),
+ GNUNET_i2s (&car->target));
#endif
GSC_SESSIONS_transmit (car, message, tc->cork);
}
@@ -544,9 +533,10 @@ destroy_active_client_request (void *cls, const GNUNET_HashCode * key,
struct GSC_ClientActiveRequest *car = value;
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (car->client_handle->requests,
- &car->target.hashPubKey,
- car));
+ GNUNET_CONTAINER_multihashmap_remove (car->
+ client_handle->requests,
+ &car->target.hashPubKey,
+ car));
GSC_SESSIONS_dequeue_request (car);
GNUNET_free (car);
return GNUNET_YES;
@@ -560,8 +550,7 @@ destroy_active_client_request (void *cls, const GNUNET_HashCode * key,
* @param client identification of the client
*/
static void
-handle_client_disconnect (void *cls,
- struct GNUNET_SERVER_Client *client)
+handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
{
struct GSC_Client *c;
@@ -573,10 +562,8 @@ handle_client_disconnect (void *cls,
#endif
c = find_client (client);
if (c == NULL)
- return; /* client never sent INIT */
- GNUNET_CONTAINER_DLL_remove (client_head,
- client_tail,
- c);
+ return; /* client never sent INIT */
+ GNUNET_CONTAINER_DLL_remove (client_head, client_tail, c);
if (c->requests != NULL)
{
GNUNET_CONTAINER_multihashmap_iterate (c->requests,
@@ -613,8 +600,9 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
smr.peer = car->target;
#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
- &car->target.hashPubKey));
+ GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
+ &car->
+ target.hashPubKey));
#endif
send_to_client (c, &smr.header, GNUNET_NO);
}
@@ -632,9 +620,10 @@ void
GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car)
{
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (car->client_handle->requests,
- &car->target.hashPubKey,
- car));
+ GNUNET_CONTAINER_multihashmap_remove (car->
+ client_handle->requests,
+ &car->target.hashPubKey,
+ car));
GNUNET_free (car);
}
@@ -654,11 +643,12 @@ GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car)
*/
void
GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
- const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count,
- const struct GSC_TypeMap *tmap_old,
- const struct GSC_TypeMap *tmap_new)
+ const struct GNUNET_PeerIdentity
+ *neighbour,
+ const struct GNUNET_ATS_Information
+ *atsi, unsigned int atsi_count,
+ const struct GSC_TypeMap *tmap_old,
+ const struct GSC_TypeMap *tmap_new)
{
struct ConnectNotifyMessage *cnm;
size_t size;
@@ -673,43 +663,41 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
if (old_match == new_match)
{
GNUNET_assert (old_match ==
- GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
- &neighbour->hashPubKey));
- return; /* no change */
+ GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
+ &neighbour->hashPubKey));
+ return; /* no change */
}
if (old_match == GNUNET_NO)
{
- /* send connect */
+ /* send connect */
#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_NO ==
- GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
- &neighbour->hashPubKey));
+ GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
+ &neighbour->hashPubKey));
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_put (client->connectmap,
- &neighbour->hashPubKey,
- NULL,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multihashmap_put (client->connectmap,
+ &neighbour->hashPubKey,
+ NULL,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
#endif
size =
- sizeof (struct ConnectNotifyMessage) +
- (atsi_count) * sizeof (struct GNUNET_ATS_Information);
+ sizeof (struct ConnectNotifyMessage) +
+ (atsi_count) * sizeof (struct GNUNET_ATS_Information);
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
- {
- GNUNET_break (0);
- /* recovery strategy: throw away performance data */
- atsi_count = 0;
- size = sizeof (struct ConnectNotifyMessage);
- }
+ {
+ GNUNET_break (0);
+ /* recovery strategy: throw away performance data */
+ atsi_count = 0;
+ size = sizeof (struct ConnectNotifyMessage);
+ }
cnm = (struct ConnectNotifyMessage *) buf;
cnm->header.size = htons (size);
cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
cnm->ats_count = htonl (atsi_count);
- a = (struct GNUNET_ATS_Information* ) &cnm[1];
- memcpy (a, atsi,
- sizeof (struct GNUNET_ATS_Information) * atsi_count);
+ a = (struct GNUNET_ATS_Information *) &cnm[1];
+ memcpy (a, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message to client.\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
"NOTIFY_CONNECT");
#endif
cnm->peer = *neighbour;
@@ -720,12 +708,12 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
/* send disconnect */
#if DEBUG_CONNECTS
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
- &neighbour->hashPubKey));
+ GNUNET_CONTAINER_multihashmap_contains (client->connectmap,
+ &neighbour->hashPubKey));
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (client->connectmap,
- &neighbour->hashPubKey,
- NULL));
+ GNUNET_CONTAINER_multihashmap_remove (client->connectmap,
+ &neighbour->hashPubKey,
+ NULL));
#endif
dcm.header.size = htons (sizeof (struct DisconnectNotifyMessage));
dcm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
@@ -748,27 +736,27 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
* @param tmap_new updated type map for the neighbour, NULL for disconnect
*/
void
-GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count,
- const struct GSC_TypeMap *tmap_old,
- const struct GSC_TypeMap *tmap_new)
+GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity
+ *neighbour,
+ const struct GNUNET_ATS_Information
+ *atsi, unsigned int atsi_count,
+ const struct GSC_TypeMap *tmap_old,
+ const struct GSC_TypeMap *tmap_new)
{
struct GSC_Client *c;
for (c = client_head; c != NULL; c = c->next)
- GSC_CLIENTS_notify_client_about_neighbour (c, neighbour, atsi,
- atsi_count,
- tmap_old, tmap_new);
+ GSC_CLIENTS_notify_client_about_neighbour (c, neighbour, atsi, atsi_count,
+ tmap_old, tmap_new);
}
/**
* Deliver P2P message to interested clients. Caller must have checked
- * that the sending peer actually lists the given message type as one
+ * that the sending peer actually lists the given message type as one
* of its types.
*
- * @param sender peer who sent us the message
+ * @param sender peer who sent us the message
* @param atsi performance information about neighbour
* @param atsi_count number of entries in 'ats' array
* @param msg the message
@@ -778,13 +766,13 @@ GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *ne
*/
void
GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count,
- const struct GNUNET_MessageHeader *msg,
- uint16_t msize,
- int options)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count,
+ const struct GNUNET_MessageHeader *msg,
+ uint16_t msize, int options)
{
- size_t size = msize + sizeof (struct NotifyTrafficMessage) +
+ size_t size =
+ msize + sizeof (struct NotifyTrafficMessage) +
atsi_count * sizeof (struct GNUNET_ATS_Information);
char buf[size];
struct NotifyTrafficMessage *ntm;
@@ -793,8 +781,8 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
if (0 == options)
{
GNUNET_snprintf (buf, sizeof (buf),
- gettext_noop ("# bytes of messages of type %u received"),
- (unsigned int) ntohs (msg->type));
+ gettext_noop ("# bytes of messages of type %u received"),
+ (unsigned int) ntohs (msg->type));
GNUNET_STATISTICS_update (GSC_stats, buf, msize, GNUNET_NO);
}
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -807,8 +795,7 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core service passes message from `%4s' of type %u to client.\n",
- GNUNET_i2s (sender),
- (unsigned int) ntohs (msg->type));
+ GNUNET_i2s (sender), (unsigned int) ntohs (msg->type));
#endif
GSC_SESSIONS_add_to_typemap (sender, ntohs (msg->type));
ntm = (struct NotifyTrafficMessage *) buf;
@@ -817,14 +804,12 @@ GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
ntm->ats_count = htonl (atsi_count);
ntm->peer = *sender;
a = &ntm->ats;
- memcpy (a, atsi,
- sizeof (struct GNUNET_ATS_Information) * atsi_count);
+ memcpy (a, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count);
a[atsi_count].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
a[atsi_count].value = htonl (0);
memcpy (&a[atsi_count + 1], msg, msize);
- send_to_all_clients (sender,
- &ntm->header, GNUNET_YES,
- options, ntohs (msg->type));
+ send_to_all_clients (sender, &ntm->header, GNUNET_YES, options,
+ ntohs (msg->type));
}
@@ -871,7 +856,7 @@ GSC_CLIENTS_done ()
{
struct GSC_Client *c;
- while (NULL != (c = client_head))
+ while (NULL != (c = client_head))
handle_client_disconnect (NULL, c->client_handle);
if (NULL != notifier)
{
diff --git a/src/core/gnunet-service-core_clients.h b/src/core/gnunet-service-core_clients.h
index 2385efc05..bdad20da8 100644
--- a/src/core/gnunet-service-core_clients.h
+++ b/src/core/gnunet-service-core_clients.h
@@ -41,8 +41,8 @@
*/
void
GSC_CLIENTS_send_to_client (struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *msg,
- int can_drop);
+ const struct GNUNET_MessageHeader *msg,
+ int can_drop);
/**
@@ -59,11 +59,12 @@ GSC_CLIENTS_send_to_client (struct GNUNET_SERVER_Client *client,
*/
void
GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
- const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count,
- const struct GSC_TypeMap *tmap_old,
- const struct GSC_TypeMap *tmap_new);
+ const struct GNUNET_PeerIdentity
+ *neighbour,
+ const struct GNUNET_ATS_Information
+ *atsi, unsigned int atsi_count,
+ const struct GSC_TypeMap *tmap_old,
+ const struct GSC_TypeMap *tmap_new);
/**
@@ -78,19 +79,20 @@ GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
* @param tmap_new updated type map for the neighbour, NULL for disconnect
*/
void
-GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count,
- const struct GSC_TypeMap *tmap_old,
- const struct GSC_TypeMap *tmap_new);
+GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity
+ *neighbour,
+ const struct GNUNET_ATS_Information
+ *atsi, unsigned int atsi_count,
+ const struct GSC_TypeMap *tmap_old,
+ const struct GSC_TypeMap *tmap_new);
/**
* Deliver P2P message to interested clients. Caller must have checked
- * that the sending peer actually lists the given message type as one
+ * that the sending peer actually lists the given message type as one
* of its types.
*
- * @param sender peer who sent us the message
+ * @param sender peer who sent us the message
* @param atsi performance information about neighbour
* @param atsi_count number of entries in 'ats' array
* @param msg the message
@@ -100,11 +102,10 @@ GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *ne
*/
void
GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count,
- const struct GNUNET_MessageHeader *msg,
- uint16_t msize,
- int options);
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count,
+ const struct GNUNET_MessageHeader *msg,
+ uint16_t msize, int options);
/**
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 7d27378ac..d49e06e2a 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -112,7 +112,7 @@ struct PongMessage
* first field after header (this is where we start to encrypt!).
*/
uint32_t challenge GNUNET_PACKED;
-
+
/**
* Reserved, always 'GNUNET_BANDWIDTH_VALUE_MAX'.
*/
@@ -495,8 +495,8 @@ do_encrypt (struct GSC_KeyExchangeInfo *kx,
"Encrypted %u bytes for `%4s' using key %u, IV %u\n",
(unsigned int) size, GNUNET_i2s (&kx->peer),
(unsigned int) kx->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (iv,
- sizeof
- (iv)));
+ sizeof
+ (iv)));
#endif
return GNUNET_OK;
}
@@ -526,14 +526,14 @@ do_decrypt (struct GSC_KeyExchangeInfo *kx,
GNUNET_break (0);
return GNUNET_NO;
}
- if ((kx->status != KX_STATE_KEY_RECEIVED) &&
- (kx->status != KX_STATE_UP))
+ if ((kx->status != KX_STATE_KEY_RECEIVED) && (kx->status != KX_STATE_UP))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (size !=
- GNUNET_CRYPTO_aes_decrypt (in, (uint16_t) size, &kx->decrypt_key, iv, out))
+ GNUNET_CRYPTO_aes_decrypt (in, (uint16_t) size, &kx->decrypt_key, iv,
+ out))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -545,8 +545,8 @@ do_decrypt (struct GSC_KeyExchangeInfo *kx,
"Decrypted %u bytes from `%4s' using key %u, IV %u\n",
(unsigned int) size, GNUNET_i2s (&kx->peer),
(unsigned int) kx->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (iv,
- sizeof
- (*iv)));
+ sizeof
+ (*iv)));
#endif
return GNUNET_OK;
}
@@ -573,7 +573,8 @@ set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GSC_KeyExchangeInfo *kx = cls;
kx->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
- kx->set_key_retry_frequency = GNUNET_TIME_relative_multiply (kx->set_key_retry_frequency, 2);
+ kx->set_key_retry_frequency =
+ GNUNET_TIME_relative_multiply (kx->set_key_retry_frequency, 2);
send_key (kx);
}
@@ -590,8 +591,7 @@ set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*/
static void
process_hello (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *hello,
- const char *err_msg)
+ const struct GNUNET_HELLO_Message *hello, const char *err_msg)
{
struct GSC_KeyExchangeInfo *kx = cls;
struct SetKeyMessage *skm;
@@ -607,19 +607,19 @@ process_hello (void *cls, const struct GNUNET_PeerIdentity *peer,
{
kx->pitr = NULL;
if (kx->public_key != NULL)
- return; /* done here */
+ return; /* done here */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to obtain public key for peer `%4s', delaying processing of SET_KEY\n",
- GNUNET_i2s (&kx->peer));
+ "Failed to obtain public key for peer `%4s', delaying processing of SET_KEY\n",
+ GNUNET_i2s (&kx->peer));
#endif
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# Delayed connecting due to lack of public key"),
- 1, GNUNET_NO);
+ gettext_noop
+ ("# Delayed connecting due to lack of public key"),
+ 1, GNUNET_NO);
kx->retry_set_key_task =
- GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency,
- &set_key_retry_task, kx);
+ GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency,
+ &set_key_retry_task, kx);
return;
}
if (kx->public_key != NULL)
@@ -661,22 +661,19 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid)
struct GSC_KeyExchangeInfo *kx;
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Initiating key exchange with `%s'\n",
- GNUNET_i2s (pid));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initiating key exchange with `%s'\n",
+ GNUNET_i2s (pid));
#endif
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# key exchanges initiated"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# key exchanges initiated"), 1,
+ GNUNET_NO);
kx = GNUNET_malloc (sizeof (struct GSC_KeyExchangeInfo));
kx->peer = *pid;
kx->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
- kx->pitr = GNUNET_PEERINFO_iterate (peerinfo,
- pid,
- GNUNET_TIME_UNIT_FOREVER_REL /* timeout? */,
- &process_hello,
- kx);
+ kx->pitr =
+ GNUNET_PEERINFO_iterate (peerinfo, pid,
+ GNUNET_TIME_UNIT_FOREVER_REL /* timeout? */ ,
+ &process_hello, kx);
return kx;
}
@@ -689,10 +686,8 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid)
void
GSC_KX_stop (struct GSC_KeyExchangeInfo *kx)
{
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# key exchanges stopped"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# key exchanges stopped"),
+ 1, GNUNET_NO);
if (kx->pitr != NULL)
{
GNUNET_PEERINFO_iterate_cancel (kx->pitr);
@@ -726,7 +721,7 @@ GSC_KX_stop (struct GSC_KeyExchangeInfo *kx)
*/
void
GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_MessageHeader *msg)
{
const struct SetKeyMessage *m;
struct GNUNET_TIME_Absolute t;
@@ -735,16 +730,16 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
struct PongMessage *pong;
enum KxStateMachine sender_status;
uint16_t size;
-
+
size = ntohs (msg->size);
if (size != sizeof (struct SetKeyMessage))
- {
- GNUNET_break_op (0);
- return;
- }
- m = (const struct SetKeyMessage*) msg;
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+ m = (const struct SetKeyMessage *) msg;
GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# session keys received"),
- 1, GNUNET_NO);
+ 1, GNUNET_NO);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -754,15 +749,16 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
if (kx->public_key == NULL)
{
GNUNET_free_non_null (kx->skm_received);
- kx->skm_received = (struct SetKeyMessage*) GNUNET_copy_message (msg);
+ kx->skm_received = (struct SetKeyMessage *) GNUNET_copy_message (msg);
return;
}
if (0 !=
- memcmp (&m->target, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ memcmp (&m->target, &GSC_my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _("`%s' is for `%s', not for me. Ignoring.\n"),
- "SET_KEY", GNUNET_i2s (&m->target));
+ _("`%s' is for `%s', not for me. Ignoring.\n"), "SET_KEY",
+ GNUNET_i2s (&m->target));
return;
}
if ((ntohl (m->purpose.size) !=
@@ -779,8 +775,7 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
return;
}
t = GNUNET_TIME_absolute_ntoh (m->creation_time);
- if (((kx->status == KX_STATE_KEY_RECEIVED) ||
- (kx->status == KX_STATE_UP)) &&
+ if (((kx->status == KX_STATE_KEY_RECEIVED) || (kx->status == KX_STATE_UP)) &&
(t.abs_value < kx->decrypt_key_created.abs_value))
{
/* this could rarely happen due to massive re-ordering of
@@ -803,9 +798,8 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
gettext_noop ("# SET_KEY messages decrypted"), 1,
GNUNET_NO);
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received SET_KEY from `%s'\n",
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received SET_KEY from `%s'\n",
+ GNUNET_i2s (&kx->peer));
#endif
kx->decrypt_key = k;
if (kx->decrypt_key_created.abs_value != t.abs_value)
@@ -831,9 +825,9 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
/* we're not up, so we are already doing 'send_key' */
break;
case KX_STATE_UP:
- if ( (sender_status == KX_STATE_DOWN) ||
- (sender_status == KX_STATE_KEY_SENT) )
- send_key (kx); /* we are up, but other peer is not! */
+ if ((sender_status == KX_STATE_DOWN) ||
+ (sender_status == KX_STATE_KEY_SENT))
+ send_key (kx); /* we are up, but other peer is not! */
break;
default:
GNUNET_break (0);
@@ -865,7 +859,7 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
*/
void
GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_MessageHeader *msg)
{
const struct PingMessage *m;
struct PingMessage t;
@@ -876,22 +870,21 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
msize = ntohs (msg->size);
if (msize != sizeof (struct PingMessage))
- {
- GNUNET_break_op (0);
- return;
- }
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# PING messages received"),
- 1, GNUNET_NO);
- if ( (kx->status != KX_STATE_KEY_RECEIVED) &&
- (kx->status != KX_STATE_UP) )
- {
- /* defer */
- GNUNET_free_non_null (kx->ping_received);
- kx->ping_received = (struct PingMessage*) GNUNET_copy_message (msg);
- return;
- }
- m = (const struct PingMessage*) msg;
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# PING messages received"), 1,
+ GNUNET_NO);
+ if ((kx->status != KX_STATE_KEY_RECEIVED) && (kx->status != KX_STATE_UP))
+ {
+ /* defer */
+ GNUNET_free_non_null (kx->ping_received);
+ kx->ping_received = (struct PingMessage *) GNUNET_copy_message (msg);
+ return;
+ }
+ m = (const struct PingMessage *) msg;
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core service receives `%s' request from `%4s'.\n", "PING",
@@ -915,15 +908,15 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
GNUNET_snprintf (sender, sizeof (sender), "%8s", GNUNET_i2s (&kx->peer));
GNUNET_snprintf (peer, sizeof (peer), "%8s", GNUNET_i2s (&t.target));
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Received PING from `%s' for different identity: I am `%s', PONG identity: `%s'\n"),
+ _
+ ("Received PING from `%s' for different identity: I am `%s', PONG identity: `%s'\n"),
sender, GNUNET_i2s (&GSC_my_identity), peer);
GNUNET_break_op (0);
return;
}
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received PING from `%s'\n",
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received PING from `%s'\n",
+ GNUNET_i2s (&kx->peer));
#endif
/* construct PONG */
tx.reserved = GNUNET_BANDWIDTH_VALUE_MAX;
@@ -937,12 +930,10 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
do_encrypt (kx, &iv, &tx.challenge, &tp.challenge,
sizeof (struct PongMessage) - ((void *) &tp.challenge -
(void *) &tp));
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# PONG messages created"), 1,
- GNUNET_NO);
- GSC_NEIGHBOURS_transmit (&kx->peer,
- &tp.header,
- GNUNET_TIME_UNIT_FOREVER_REL /* FIXME: timeout */);
+ GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# PONG messages created"),
+ 1, GNUNET_NO);
+ GSC_NEIGHBOURS_transmit (&kx->peer, &tp.header,
+ GNUNET_TIME_UNIT_FOREVER_REL /* FIXME: timeout */ );
}
@@ -963,21 +954,22 @@ setup_fresh_setkey (struct GSC_KeyExchangeInfo *kx)
skm->header.size = htons (sizeof (struct SetKeyMessage));
skm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SET_KEY);
skm->purpose.size =
- htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
- sizeof (struct GNUNET_TIME_AbsoluteNBO) +
- sizeof (struct GNUNET_CRYPTO_RsaEncryptedData) +
- sizeof (struct GNUNET_PeerIdentity));
+ htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
+ sizeof (struct GNUNET_TIME_AbsoluteNBO) +
+ sizeof (struct GNUNET_CRYPTO_RsaEncryptedData) +
+ sizeof (struct GNUNET_PeerIdentity));
skm->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SET_KEY);
skm->creation_time = GNUNET_TIME_absolute_hton (kx->encrypt_key_created);
skm->target = kx->peer;
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_rsa_encrypt (&kx->encrypt_key,
- sizeof (struct
- GNUNET_CRYPTO_AesSessionKey),
- kx->public_key, &skm->encrypted_key));
+ GNUNET_CRYPTO_rsa_encrypt (&kx->encrypt_key,
+ sizeof (struct
+ GNUNET_CRYPTO_AesSessionKey),
+ kx->public_key,
+ &skm->encrypted_key));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_rsa_sign (my_private_key, &skm->purpose,
- &skm->signature));
+ GNUNET_CRYPTO_rsa_sign (my_private_key, &skm->purpose,
+ &skm->signature));
}
@@ -997,13 +989,13 @@ setup_fresh_ping (struct GSC_KeyExchangeInfo *kx)
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);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
derive_iv (&iv, &kx->encrypt_key, pm->iv_seed, &kx->peer);
pp.challenge = kx->ping_challenge;
pp.target = kx->peer;
do_encrypt (kx, &iv, &pp.target, &pm->target,
- sizeof (struct PingMessage) - ((void *) &pm->target -
- (void *) pm));
+ sizeof (struct PingMessage) - ((void *) &pm->target -
+ (void *) pm));
}
@@ -1024,33 +1016,29 @@ send_keep_alive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
kx->keep_alive_task = GNUNET_SCHEDULER_NO_TASK;
left = GNUNET_TIME_absolute_get_remaining (kx->timeout);
if (left.rel_value == 0)
- {
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# sessions terminated by timeout"),
- 1,
- GNUNET_NO);
+ {
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# sessions terminated by timeout"),
+ 1, GNUNET_NO);
GSC_SESSIONS_end (&kx->peer);
kx->status = KX_STATE_DOWN;
return;
}
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending KEEPALIVE to `%s'\n",
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending KEEPALIVE to `%s'\n",
+ GNUNET_i2s (&kx->peer));
#endif
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# keepalive messages sent"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# keepalive messages sent"), 1,
+ GNUNET_NO);
setup_fresh_ping (kx);
- GSC_NEIGHBOURS_transmit (&kx->peer,
- &kx->ping.header,
- kx->set_key_retry_frequency);
+ GSC_NEIGHBOURS_transmit (&kx->peer, &kx->ping.header,
+ kx->set_key_retry_frequency);
retry =
GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
MIN_PING_FREQUENCY);
kx->keep_alive_task =
- GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, kx);
+ GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, kx);
}
@@ -1064,13 +1052,15 @@ send_keep_alive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
update_timeout (struct GSC_KeyExchangeInfo *kx)
{
- kx->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ kx->timeout =
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
if (kx->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (kx->keep_alive_task);
kx->keep_alive_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
- (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- 2), &send_keep_alive, kx);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
+ (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ 2), &send_keep_alive, kx);
}
@@ -1081,7 +1071,8 @@ update_timeout (struct GSC_KeyExchangeInfo *kx)
* @param m the encrypted PONG message itself
*/
void
-GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, const struct GNUNET_MessageHeader *msg)
+GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx,
+ const struct GNUNET_MessageHeader *msg)
{
const struct PongMessage *m;
struct PongMessage t;
@@ -1095,19 +1086,19 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, const struct GNUNET_MessageH
GNUNET_break_op (0);
return;
}
- GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# PONG messages received"),
- 1, GNUNET_NO);
- if ( (kx->status != KX_STATE_KEY_RECEIVED) &&
- (kx->status != KX_STATE_UP) )
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# PONG messages received"), 1,
+ GNUNET_NO);
+ if ((kx->status != KX_STATE_KEY_RECEIVED) && (kx->status != KX_STATE_UP))
{
if (kx->status == KX_STATE_KEY_SENT)
{
GNUNET_free_non_null (kx->pong_received);
- kx->pong_received = (struct PongMessage*) GNUNET_copy_message (msg);
+ kx->pong_received = (struct PongMessage *) GNUNET_copy_message (msg);
}
return;
}
- m = (const struct PongMessage*) msg;
+ m = (const struct PongMessage *) msg;
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core service receives `%s' response from `%4s'.\n", "PONG",
@@ -1125,8 +1116,9 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, const struct GNUNET_MessageH
GNUNET_break_op (0);
return;
}
- GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# PONG messages decrypted"),
- 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# PONG messages decrypted"), 1,
+ GNUNET_NO);
if ((0 != memcmp (&t.target, &kx->peer, sizeof (struct GNUNET_PeerIdentity)))
|| (kx->ping_challenge != t.challenge))
{
@@ -1143,9 +1135,8 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, const struct GNUNET_MessageH
return;
}
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received PONG from `%s'\n",
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received PONG from `%s'\n",
+ GNUNET_i2s (&kx->peer));
#endif
switch (kx->status)
{
@@ -1170,7 +1161,8 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, const struct GNUNET_MessageH
{
emsg = kx->emsg_received;
kx->emsg_received = NULL;
- GSC_KX_handle_encrypted_message (kx, &emsg->header, NULL, 0 /* FIXME: ATSI */);
+ GSC_KX_handle_encrypted_message (kx, &emsg->header, NULL,
+ 0 /* FIXME: ATSI */ );
GNUNET_free (emsg);
}
update_timeout (kx);
@@ -1194,20 +1186,20 @@ static void
send_key (struct GSC_KeyExchangeInfo *kx)
{
GNUNET_assert (kx->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK);
- if (KX_STATE_UP == kx->status)
- return; /* nothing to do */
+ if (KX_STATE_UP == kx->status)
+ return; /* nothing to do */
if (kx->public_key == NULL)
{
/* lookup public key, then try again */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Trying to obtain public key for `%s'\n",
- GNUNET_i2s (&kx->peer));
+ "Trying to obtain public key for `%s'\n",
+ GNUNET_i2s (&kx->peer));
#endif
kx->pitr =
- GNUNET_PEERINFO_iterate (peerinfo, &kx->peer,
- GNUNET_TIME_UNIT_FOREVER_REL /* timeout? */,
- &process_hello, kx);
+ GNUNET_PEERINFO_iterate (peerinfo, &kx->peer,
+ GNUNET_TIME_UNIT_FOREVER_REL /* timeout? */ ,
+ &process_hello, kx);
return;
}
@@ -1215,14 +1207,14 @@ send_key (struct GSC_KeyExchangeInfo *kx)
switch (kx->status)
{
case KX_STATE_DOWN:
- kx->status = KX_STATE_KEY_SENT;
+ kx->status = KX_STATE_KEY_SENT;
/* setup SET KEY message */
setup_fresh_setkey (kx);
setup_fresh_ping (kx);
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# SET_KEY and PING messages created"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# SET_KEY and PING messages created"), 1,
+ GNUNET_NO);
break;
case KX_STATE_KEY_SENT:
break;
@@ -1239,19 +1231,16 @@ send_key (struct GSC_KeyExchangeInfo *kx)
/* always update sender status in SET KEY message */
kx->skm.sender_status = htonl ((int32_t) kx->status);
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending SET_KEY and PING to `%s'\n",
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SET_KEY and PING to `%s'\n",
+ GNUNET_i2s (&kx->peer));
#endif
- GSC_NEIGHBOURS_transmit (&kx->peer,
- &kx->skm.header,
- kx->set_key_retry_frequency);
- GSC_NEIGHBOURS_transmit (&kx->peer,
- &kx->ping.header,
- kx->set_key_retry_frequency);
+ GSC_NEIGHBOURS_transmit (&kx->peer, &kx->skm.header,
+ kx->set_key_retry_frequency);
+ GSC_NEIGHBOURS_transmit (&kx->peer, &kx->ping.header,
+ kx->set_key_retry_frequency);
kx->retry_set_key_task =
- GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency,
- &set_key_retry_task, kx);
+ GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency,
+ &set_key_retry_task, kx);
}
@@ -1264,18 +1253,17 @@ send_key (struct GSC_KeyExchangeInfo *kx)
*/
void
GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
- const void *payload,
- size_t payload_size)
+ const void *payload, size_t payload_size)
{
size_t used = payload_size + sizeof (struct EncryptedMessage);
- char pbuf[used]; /* plaintext */
- char cbuf[used]; /* ciphertext */
+ char pbuf[used]; /* plaintext */
+ char cbuf[used]; /* ciphertext */
struct EncryptedMessage *em; /* encrypted message */
struct EncryptedMessage *ph; /* plaintext header */
struct GNUNET_CRYPTO_AesInitializationVector iv;
struct GNUNET_CRYPTO_AuthKey auth_key;
- ph = (struct EncryptedMessage*) pbuf;
+ ph = (struct EncryptedMessage *) pbuf;
ph->iv_seed =
htonl (GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
@@ -1290,22 +1278,20 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
em->iv_seed = ph->iv_seed;
derive_iv (&iv, &kx->encrypt_key, ph->iv_seed, &kx->peer);
GNUNET_assert (GNUNET_OK ==
- do_encrypt (kx, &iv, &ph->sequence_number, &em->sequence_number,
+ do_encrypt (kx, &iv, &ph->sequence_number,
+ &em->sequence_number,
used - ENCRYPTED_HEADER_SIZE));
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Encrypted %u bytes for %s\n",
- used - ENCRYPTED_HEADER_SIZE,
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted %u bytes for %s\n",
+ used - ENCRYPTED_HEADER_SIZE, GNUNET_i2s (&kx->peer));
#endif
derive_auth_key (&auth_key, &kx->encrypt_key, ph->iv_seed,
kx->encrypt_key_created);
GNUNET_CRYPTO_hmac (&auth_key, &em->sequence_number,
used - ENCRYPTED_HEADER_SIZE, &em->hmac);
- GSC_NEIGHBOURS_transmit (&kx->peer,
- &em->header,
- GNUNET_TIME_UNIT_FOREVER_REL);
-}
+ GSC_NEIGHBOURS_transmit (&kx->peer, &em->header,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+}
/**
@@ -1313,7 +1299,7 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
*/
struct DeliverMessageContext
{
-
+
/**
* Performance information for the connection.
*/
@@ -1330,7 +1316,7 @@ struct DeliverMessageContext
uint32_t atsi_count;
};
-
+
/**
* We received an encrypted message. Decrypt, validate and
* pass on to the appropriate clients.
@@ -1341,10 +1327,10 @@ struct DeliverMessageContext
* @param atsi_count number of entries in ats (excluding 0-termination)
*/
void
-GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count)
+GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
+ const struct GNUNET_MessageHeader *msg,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
const struct EncryptedMessage *m;
struct EncryptedMessage *pt; /* plaintext */
@@ -1363,21 +1349,20 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
GNUNET_break_op (0);
return;
}
- m = (const struct EncryptedMessage*) msg;
- if ( (kx->status != KX_STATE_KEY_RECEIVED) &&
- (kx->status != KX_STATE_UP) )
+ m = (const struct EncryptedMessage *) msg;
+ if ((kx->status != KX_STATE_KEY_RECEIVED) && (kx->status != KX_STATE_UP))
{
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# failed to decrypt message (no session key)"),
- 1, GNUNET_NO);
+ gettext_noop
+ ("# failed to decrypt message (no session key)"),
+ 1, GNUNET_NO);
return;
}
if (kx->status == KX_STATE_KEY_RECEIVED)
{
/* defer */
GNUNET_free_non_null (kx->ping_received);
- kx->emsg_received = (struct EncryptedMessage*) GNUNET_copy_message (msg);
+ kx->emsg_received = (struct EncryptedMessage *) GNUNET_copy_message (msg);
return;
}
/* validate hash */
@@ -1398,10 +1383,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
size - ENCRYPTED_HEADER_SIZE))
return;
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Decrypted %u bytes from %s\n",
- size - ENCRYPTED_HEADER_SIZE,
- GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted %u bytes from %s\n",
+ size - ENCRYPTED_HEADER_SIZE, GNUNET_i2s (&kx->peer));
#endif
pt = (struct EncryptedMessage *) buf;
@@ -1480,7 +1463,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
dmc.atsi_count = atsi_count;
dmc.peer = &kx->peer;
if (GNUNET_OK !=
- GNUNET_SERVER_mst_receive (mst, &dmc, &buf[sizeof (struct EncryptedMessage)],
+ GNUNET_SERVER_mst_receive (mst, &dmc,
+ &buf[sizeof (struct EncryptedMessage)],
size - sizeof (struct EncryptedMessage),
GNUNET_YES, GNUNET_NO))
GNUNET_break_op (0);
@@ -1490,7 +1474,7 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
/**
* Deliver P2P message to interested clients.
* Invokes send twice, once for clients that want the full message, and once
- * for clients that only want the header
+ * for clients that only want the header
*
* @param cls always NULL
* @param client who sent us the message (struct GSC_KeyExchangeInfo)
@@ -1505,20 +1489,15 @@ deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m)
{
case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP:
case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP:
- GSC_SESSIONS_set_typemap (dmc->peer,
- m);
+ GSC_SESSIONS_set_typemap (dmc->peer, m);
return;
default:
- GSC_CLIENTS_deliver_message (dmc->peer,
- dmc->atsi, dmc->atsi_count,
- m,
- ntohs (m->size),
- GNUNET_CORE_OPTION_SEND_FULL_INBOUND);
- GSC_CLIENTS_deliver_message (dmc->peer,
- dmc->atsi, dmc->atsi_count,
- m,
- sizeof (struct GNUNET_MessageHeader),
- GNUNET_CORE_OPTION_SEND_HDR_INBOUND);
+ GSC_CLIENTS_deliver_message (dmc->peer, dmc->atsi, dmc->atsi_count, m,
+ ntohs (m->size),
+ GNUNET_CORE_OPTION_SEND_FULL_INBOUND);
+ GSC_CLIENTS_deliver_message (dmc->peer, dmc->atsi, dmc->atsi_count, m,
+ sizeof (struct GNUNET_MessageHeader),
+ GNUNET_CORE_OPTION_SEND_HDR_INBOUND);
}
}
@@ -1528,17 +1507,18 @@ deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m)
*
* @return GNUNET_OK on success, GNUNET_SYSERR on failure
*/
-int
+int
GSC_KX_init ()
{
char *keyfile;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (GSC_cfg, "GNUNETD", "HOSTKEY",
- &keyfile))
+ &keyfile))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Core service is lacking HOSTKEY configuration setting. Exiting.\n"));
+ _
+ ("Core service is lacking HOSTKEY configuration setting. Exiting.\n"));
return GNUNET_SYSERR;
}
my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
@@ -1569,7 +1549,7 @@ GSC_KX_init ()
/**
* Shutdown KX subsystem.
*/
-void
+void
GSC_KX_done ()
{
if (my_private_key != NULL)
diff --git a/src/core/gnunet-service-core_kx.h b/src/core/gnunet-service-core_kx.h
index 0e963ef7a..5ecd2c17f 100644
--- a/src/core/gnunet-service-core_kx.h
+++ b/src/core/gnunet-service-core_kx.h
@@ -44,8 +44,8 @@ struct GSC_KeyExchangeInfo;
* @param msg the set key message we received
*/
void
-GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg);
+GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
+ const struct GNUNET_MessageHeader *msg);
/**
@@ -56,8 +56,8 @@ GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
* @param msg the encrypted PING message itself
*/
void
-GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg);
+GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
+ const struct GNUNET_MessageHeader *msg);
/**
@@ -68,7 +68,7 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
*/
void
GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg);
+ const struct GNUNET_MessageHeader *msg);
/**
@@ -80,8 +80,7 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx,
*/
void
GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
- const void *payload,
- size_t payload_size);
+ const void *payload, size_t payload_size);
/**
@@ -94,10 +93,10 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
* @param atsi_count number of entries in ats (excluding 0-termination)
*/
void
-GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
- const struct GNUNET_MessageHeader *msg,
- const struct GNUNET_ATS_Information *atsi,
- uint32_t atsi_count);
+GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
+ const struct GNUNET_MessageHeader *msg,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count);
/**
@@ -124,14 +123,14 @@ GSC_KX_stop (struct GSC_KeyExchangeInfo *kx);
*
* @return GNUNET_OK on success, GNUNET_SYSERR on failure
*/
-int
+int
GSC_KX_init (void);
/**
* Shutdown KX subsystem.
*/
-void
+void
GSC_KX_done (void);
#endif
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c
index d7ce91a88..5014298bf 100644
--- a/src/core/gnunet-service-core_neighbours.c
+++ b/src/core/gnunet-service-core_neighbours.c
@@ -158,10 +158,10 @@ free_neighbour (struct Neighbour *n)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th);
n->th = NULL;
}
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# sessions terminated by transport disconnect"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop
+ ("# sessions terminated by transport disconnect"),
+ 1, GNUNET_NO);
GSC_SESSIONS_end (&n->peer);
if (NULL != n->kxinfo)
{
@@ -175,8 +175,9 @@ free_neighbour (struct Neighbour *n)
}
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_remove (neighbours,
- &n->peer.hashPubKey, n));
- GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# neighbour entries allocated"),
+ &n->peer.hashPubKey, n));
+ GNUNET_STATISTICS_set (GSC_stats,
+ gettext_noop ("# neighbour entries allocated"),
GNUNET_CONTAINER_multihashmap_size (neighbours),
GNUNET_NO);
GNUNET_free (n);
@@ -239,10 +240,10 @@ transmit_ready (void *cls, size_t size, void *buf)
ret = m->size;
#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));
+ "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));
#endif
GNUNET_free (m);
process_queue (n);
@@ -271,7 +272,7 @@ process_queue (struct Neighbour *n)
if (m == NULL)
{
/* notify sessions that the queue is empty and more messages
- could thus be queued now */
+ * could thus be queued now */
GSC_SESSIONS_solicit (&n->peer);
return;
}
@@ -283,12 +284,10 @@ process_queue (struct Neighbour *n)
GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value);
#endif
n->th =
- GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size,
- 0,
- GNUNET_TIME_absolute_get_remaining
- (m->deadline),
- &transmit_ready,
- n);
+ GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size, 0,
+ GNUNET_TIME_absolute_get_remaining
+ (m->deadline), &transmit_ready,
+ n);
if (n->th != NULL)
return;
/* message request too large or duplicate request */
@@ -313,8 +312,8 @@ process_queue (struct Neighbour *n)
static void
handle_transport_notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information
- *atsi, uint32_t atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct Neighbour *n;
@@ -340,7 +339,8 @@ handle_transport_notify_connect (void *cls,
GNUNET_CONTAINER_multihashmap_put (neighbours,
&n->peer.hashPubKey, n,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# neighbour entries allocated"),
+ GNUNET_STATISTICS_set (GSC_stats,
+ gettext_noop ("# neighbour entries allocated"),
GNUNET_CONTAINER_multihashmap_size (neighbours),
GNUNET_NO);
n->kxinfo = GSC_KX_start (peer);
@@ -423,9 +423,7 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
GSC_KX_handle_pong (n->kxinfo, message);
break;
case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
- GSC_KX_handle_encrypted_message (n->kxinfo,
- message, atsi,
- atsi_count);
+ GSC_KX_handle_encrypted_message (n->kxinfo, message, atsi, atsi_count);
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -438,15 +436,15 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
/**
* Transmit the given message to the given target.
- *
+ *
* @param target peer that should receive the message (must be connected)
* @param msg message to transmit
* @param timeout by when should the transmission be done?
*/
void
GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_MessageHeader *msg,
- struct GNUNET_TIME_Relative timeout)
+ const struct GNUNET_MessageHeader *msg,
+ struct GNUNET_TIME_Relative timeout)
{
struct NeighbourMessageEntry *me;
struct Neighbour *n;
@@ -463,9 +461,7 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target,
me->deadline = GNUNET_TIME_relative_to_absolute (timeout);
me->size = msize;
memcpy (&me[1], msg, msize);
- GNUNET_CONTAINER_DLL_insert_tail (n->message_head,
- n->message_tail,
- me);
+ GNUNET_CONTAINER_DLL_insert_tail (n->message_head, n->message_tail, me);
process_queue (n);
}
@@ -478,8 +474,7 @@ GSC_NEIGHBOURS_init ()
{
neighbours = GNUNET_CONTAINER_multihashmap_create (128);
transport =
- GNUNET_TRANSPORT_connect (GSC_cfg,
- &GSC_my_identity, NULL,
+ GNUNET_TRANSPORT_connect (GSC_cfg, &GSC_my_identity, NULL,
&handle_transport_receive,
&handle_transport_notify_connect,
&handle_transport_notify_disconnect);
@@ -530,4 +525,3 @@ GSC_NEIGHBOURS_done ()
}
/* end of gnunet-service-core_neighbours.c */
-
diff --git a/src/core/gnunet-service-core_neighbours.h b/src/core/gnunet-service-core_neighbours.h
index 36682770e..d613c46a5 100644
--- a/src/core/gnunet-service-core_neighbours.h
+++ b/src/core/gnunet-service-core_neighbours.h
@@ -35,15 +35,15 @@
* when the message queue is empty). Outbound quotas and memory
* bounds will then be enfoced (as GSC_SESSION_solicit is only called
* if sufficient banwdith is available).
- *
+ *
* @param target peer that should receive the message (must be connected)
* @param msg message to transmit
* @param timeout by when should the transmission be done?
*/
void
GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_MessageHeader *msg,
- struct GNUNET_TIME_Relative timeout);
+ const struct GNUNET_MessageHeader *msg,
+ struct GNUNET_TIME_Relative timeout);
/**
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index a8f7bf6bf..108fd47cf 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -20,7 +20,7 @@
/**
* @file core/gnunet-service-core_sessions.c
- * @brief code for managing of 'encrypted' sessions (key exchange done)
+ * @brief code for managing of 'encrypted' sessions (key exchange done)
* @author Christian Grothoff
*/
#include "platform.h"
@@ -133,7 +133,7 @@ struct Session
/**
* Is the neighbour queue empty and thus ready for us
- * to transmit an encrypted message?
+ * to transmit an encrypted message?
*/
int ready_to_transmit;
@@ -162,7 +162,7 @@ find_session (const struct GNUNET_PeerIdentity *peer)
/**
* End the session with the given peer (we are no longer
- * connected).
+ * connected).
*
* @param pid identity of peer to kill session with
*/
@@ -176,8 +176,7 @@ GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid)
if (NULL == session)
return;
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Destroying session for peer `%4s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying session for peer `%4s'\n",
GNUNET_i2s (&session->peer));
#endif
if (GNUNET_SCHEDULER_NO_TASK != session->cork_task)
@@ -188,22 +187,21 @@ GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid)
while (NULL != (car = session->active_client_request_head))
{
GNUNET_CONTAINER_DLL_remove (session->active_client_request_head,
- session->active_client_request_tail,
- car);
+ session->active_client_request_tail, car);
GSC_CLIENTS_reject_request (car);
}
GNUNET_SCHEDULER_cancel (session->typemap_task);
- GSC_CLIENTS_notify_clients_about_neighbour (&session->peer,
- NULL, 0 /* FIXME: ATSI */,
- session->tmap,
- NULL);
+ GSC_CLIENTS_notify_clients_about_neighbour (&session->peer, NULL,
+ 0 /* FIXME: ATSI */ ,
+ session->tmap, NULL);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (sessions,
- &session->peer.hashPubKey, session));
- GNUNET_STATISTICS_set (GSC_stats,
- gettext_noop ("# entries in session map"),
- GNUNET_CONTAINER_multihashmap_size (sessions),
- GNUNET_NO);
+ &session->
+ peer.hashPubKey,
+ session));
+ GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# entries in session map"),
+ GNUNET_CONTAINER_multihashmap_size (sessions),
+ GNUNET_NO);
GSC_TYPEMAP_destroy (session->tmap);
session->tmap = NULL;
GNUNET_free (session);
@@ -216,10 +214,9 @@ GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid)
*
* @param cls the 'struct Session*'
* @param tc unused
- */
+ */
static void
-transmit_typemap_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_typemap_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Session *session = cls;
struct GNUNET_MessageHeader *hdr;
@@ -227,19 +224,15 @@ transmit_typemap_task (void *cls,
delay = TYPEMAP_FREQUENCY;
/* randomize a bit to avoid spont. sync */
- delay.rel_value += GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- 1000);
- session->typemap_task = GNUNET_SCHEDULER_add_delayed (delay,
- &transmit_typemap_task,
- session);
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# type map refreshes sent"),
- 1,
- GNUNET_NO);
+ delay.rel_value +=
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
+ session->typemap_task =
+ GNUNET_SCHEDULER_add_delayed (delay, &transmit_typemap_task, session);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# type map refreshes sent"), 1,
+ GNUNET_NO);
hdr = GSC_TYPEMAP_compute_type_map_message ();
- GSC_KX_encrypt_and_transmit (session->kxinfo,
- hdr,
- ntohs (hdr->size));
+ GSC_KX_encrypt_and_transmit (session->kxinfo, hdr, ntohs (hdr->size));
GNUNET_free (hdr);
}
@@ -252,33 +245,30 @@ transmit_typemap_task (void *cls,
*/
void
GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
- struct GSC_KeyExchangeInfo *kx)
+ struct GSC_KeyExchangeInfo *kx)
{
struct Session *session;
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating session for peer `%4s'\n", GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating session for peer `%4s'\n",
+ GNUNET_i2s (peer));
#endif
session = GNUNET_malloc (sizeof (struct Session));
session->tmap = GSC_TYPEMAP_create ();
session->peer = *peer;
session->kxinfo = kx;
session->time_established = GNUNET_TIME_absolute_get ();
- session->typemap_task = GNUNET_SCHEDULER_add_now (&transmit_typemap_task,
- session);
+ session->typemap_task =
+ GNUNET_SCHEDULER_add_now (&transmit_typemap_task, session);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (sessions,
- &peer->hashPubKey, session,
+ GNUNET_CONTAINER_multihashmap_put (sessions, &peer->hashPubKey,
+ session,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- GNUNET_STATISTICS_set (GSC_stats,
- gettext_noop ("# entries in session map"),
- GNUNET_CONTAINER_multihashmap_size (sessions),
- GNUNET_NO);
- GSC_CLIENTS_notify_clients_about_neighbour (peer,
- NULL, 0 /* FIXME: ATSI */,
- NULL,
- session->tmap);
+ GNUNET_STATISTICS_set (GSC_stats, gettext_noop ("# entries in session map"),
+ GNUNET_CONTAINER_multihashmap_size (sessions),
+ GNUNET_NO);
+ GSC_CLIENTS_notify_clients_about_neighbour (peer, NULL, 0 /* FIXME: ATSI */ ,
+ NULL, session->tmap);
}
@@ -286,23 +276,20 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
* Notify the given client about the session (client is new).
*
* @param cls the 'struct GSC_Client'
- * @param key peer identity
+ * @param key peer identity
* @param value the 'struct Session'
* @return GNUNET_OK (continue to iterate)
*/
static int
-notify_client_about_session (void *cls,
- const GNUNET_HashCode *key,
- void *value)
+notify_client_about_session (void *cls, const GNUNET_HashCode * key,
+ void *value)
{
struct GSC_Client *client = cls;
struct Session *session = value;
- GSC_CLIENTS_notify_client_about_neighbour (client,
- &session->peer,
- NULL, 0, /* FIXME: ATS!? */
- NULL, /* old TMAP: none */
- session->tmap);
+ GSC_CLIENTS_notify_client_about_neighbour (client, &session->peer, NULL, 0, /* FIXME: ATS!? */
+ NULL, /* old TMAP: none */
+ session->tmap);
return GNUNET_OK;
}
@@ -316,8 +303,8 @@ void
GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client)
{
/* notify new client about existing sessions */
- GNUNET_CONTAINER_multihashmap_iterate (sessions,
- &notify_client_about_session, client);
+ GNUNET_CONTAINER_multihashmap_iterate (sessions, &notify_client_about_session,
+ client);
}
@@ -373,7 +360,7 @@ GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car)
"Received client transmission request. queueing\n");
#endif
GNUNET_CONTAINER_DLL_insert (session->active_client_request_head,
- session->active_client_request_tail, car);
+ session->active_client_request_tail, car);
try_transmission (session);
}
@@ -389,11 +376,11 @@ GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car)
{
struct Session *s;
- if (0 == memcmp (&car->target,
- &GSC_my_identity,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 ==
+ memcmp (&car->target, &GSC_my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
return;
- s = find_session (&car->target);
+ s = find_session (&car->target);
GNUNET_assert (NULL != s);
GNUNET_CONTAINER_DLL_remove (s->active_client_request_head,
s->active_client_request_tail, car);
@@ -411,7 +398,7 @@ discard_expired_requests (struct Session *session)
struct GSC_ClientActiveRequest *pos;
struct GSC_ClientActiveRequest *nxt;
struct GNUNET_TIME_Absolute now;
-
+
now = GNUNET_TIME_absolute_get ();
pos = NULL;
nxt = session->active_client_request_head;
@@ -419,16 +406,15 @@ discard_expired_requests (struct Session *session)
{
pos = nxt;
nxt = pos->next;
- if ( (pos->deadline.abs_value < now.abs_value) &&
- (GNUNET_YES != pos->was_solicited) )
+ if ((pos->deadline.abs_value < now.abs_value) &&
+ (GNUNET_YES != pos->was_solicited))
{
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop
("# messages discarded (expired prior to transmission)"),
1, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (session->active_client_request_head,
- session->active_client_request_tail,
- pos);
+ session->active_client_request_tail, pos);
GSC_CLIENTS_reject_request (pos);
}
}
@@ -446,7 +432,7 @@ solicit_messages (struct Session *session)
struct GSC_ClientActiveRequest *car;
size_t so_size;
- discard_expired_requests (session);
+ discard_expired_requests (session);
so_size = 0;
for (car = session->active_client_request_head; NULL != car; car = car->next)
{
@@ -462,15 +448,14 @@ solicit_messages (struct Session *session)
/**
- * Some messages were delayed (corked), but the timeout has now expired.
+ * Some messages were delayed (corked), but the timeout has now expired.
* Send them now.
*
* @param cls 'struct Session' with the messages to transmit now
* @param tc scheduler context (unused)
*/
static void
-pop_cork_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+pop_cork_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct Session *session = cls;
@@ -499,31 +484,31 @@ try_transmission (struct Session *session)
min_deadline = GNUNET_TIME_UNIT_FOREVER_ABS;
/* check 'ready' messages */
pos = session->sme_head;
- while ( (NULL != pos) &&
- (msize + pos->size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) )
+ while ((NULL != pos) &&
+ (msize + pos->size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE))
{
GNUNET_assert (pos->size < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
msize += pos->size;
- min_deadline = GNUNET_TIME_absolute_min (min_deadline,
- pos->deadline);
+ min_deadline = GNUNET_TIME_absolute_min (min_deadline, pos->deadline);
pos = pos->next;
}
now = GNUNET_TIME_absolute_get ();
- if ( (msize == 0) ||
- ( (msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
- (min_deadline.abs_value > now.abs_value) ) )
+ if ((msize == 0) ||
+ ((msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
+ (min_deadline.abs_value > now.abs_value)))
{
/* not enough ready yet, try to solicit more */
solicit_messages (session);
if (msize > 0)
{
/* if there is data to send, just not yet, make sure we do transmit
- it once the deadline is reached */
+ * it once the deadline is reached */
if (session->cork_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel (session->cork_task);
- session->cork_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining (min_deadline),
- &pop_cork_task,
- session);
+ GNUNET_SCHEDULER_cancel (session->cork_task);
+ session->cork_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
+ (min_deadline), &pop_cork_task,
+ session);
}
return;
}
@@ -531,18 +516,15 @@ try_transmission (struct Session *session)
{
static unsigned long long total_bytes;
static unsigned int total_msgs;
- char pbuf[msize]; /* plaintext */
+ char pbuf[msize]; /* plaintext */
size_t used;
used = 0;
- while ( (NULL != (pos = session->sme_head)) &&
- (used + pos->size <= msize) )
+ while ((NULL != (pos = session->sme_head)) && (used + pos->size <= msize))
{
memcpy (&pbuf[used], &pos[1], pos->size);
used += pos->size;
- GNUNET_CONTAINER_DLL_remove (session->sme_head,
- session->sme_tail,
- pos);
+ GNUNET_CONTAINER_DLL_remove (session->sme_head, session->sme_tail, pos);
GNUNET_free (pos);
}
/* compute average payload size */
@@ -554,15 +536,11 @@ try_transmission (struct Session *session)
total_msgs = 1;
total_bytes = used;
}
- GNUNET_STATISTICS_set (GSC_stats,
- "# avg payload per encrypted message",
- total_bytes / total_msgs,
- GNUNET_NO);
+ GNUNET_STATISTICS_set (GSC_stats, "# avg payload per encrypted message",
+ total_bytes / total_msgs, GNUNET_NO);
/* now actually transmit... */
session->ready_to_transmit = GNUNET_NO;
- GSC_KX_encrypt_and_transmit (session->kxinfo,
- pbuf,
- used);
+ GSC_KX_encrypt_and_transmit (session->kxinfo, pbuf, used);
}
}
@@ -587,9 +565,7 @@ do_send_message (void *cls, const GNUNET_HashCode * key, void *value)
m = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size);
memcpy (&m[1], hdr, size);
m->size = size;
- GNUNET_CONTAINER_DLL_insert (session->sme_head,
- session->sme_tail,
- m);
+ GNUNET_CONTAINER_DLL_insert (session->sme_head, session->sme_tail, m);
try_transmission (session);
return GNUNET_OK;
}
@@ -605,8 +581,8 @@ GSC_SESSIONS_broadcast (const struct GNUNET_MessageHeader *msg)
{
if (NULL == sessions)
return;
- GNUNET_CONTAINER_multihashmap_iterate (sessions,
- &do_send_message, (void*) msg);
+ GNUNET_CONTAINER_multihashmap_iterate (sessions, &do_send_message,
+ (void *) msg);
}
@@ -640,8 +616,7 @@ GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid)
*/
void
GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
- const struct GNUNET_MessageHeader *msg,
- int cork)
+ const struct GNUNET_MessageHeader *msg, int cork)
{
struct Session *session;
struct SessionMessageEntry *sme;
@@ -655,10 +630,9 @@ GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
memcpy (&sme[1], msg, msize);
sme->size = msize;
if (GNUNET_YES == cork)
- sme->deadline = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_MAX_CORK_DELAY);
- GNUNET_CONTAINER_DLL_insert_tail (session->sme_head,
- session->sme_tail,
- sme);
+ sme->deadline =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_MAX_CORK_DELAY);
+ GNUNET_CONTAINER_DLL_insert_tail (session->sme_head, session->sme_tail, sme);
try_transmission (session);
}
@@ -678,7 +652,7 @@ queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value)
struct GNUNET_SERVER_TransmitContext *tc = cls;
struct Session *session = value;
struct ConnectNotifyMessage cnm;
-
+
/* FIXME: code duplication with clients... */
cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
@@ -693,23 +667,23 @@ queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value)
/**
* Handle CORE_ITERATE_PEERS request. For this request type, the client
* does not have to have transmitted an INIT request. All current peers
- * are returned, regardless of which message types they accept.
+ * are returned, regardless of which message types they accept.
*
* @param cls unused
* @param client client sending the iteration request
* @param message iteration request message
*/
void
-GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+GSC_SESSIONS_handle_client_iterate_peers (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader
+ *message)
{
struct GNUNET_MessageHeader done_msg;
struct GNUNET_SERVER_TransmitContext *tc;
tc = GNUNET_SERVER_transmit_context_create (client);
- GNUNET_CONTAINER_multihashmap_iterate (sessions,
- &queue_connect_message,
- tc);
+ GNUNET_CONTAINER_multihashmap_iterate (sessions, &queue_connect_message, tc);
done_msg.size = htons (sizeof (struct GNUNET_MessageHeader));
done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END);
GNUNET_SERVER_transmit_context_append_message (tc, &done_msg);
@@ -728,14 +702,16 @@ GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client
* @param message iteration request message
*/
void
-GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+GSC_SESSIONS_handle_client_have_peer (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader
+ *message)
{
struct GNUNET_MessageHeader done_msg;
struct GNUNET_SERVER_TransmitContext *tc;
const struct GNUNET_PeerIdentity *peer;
- peer = (const struct GNUNET_PeerIdentity *) &message[1]; // YUCK!
+ peer = (const struct GNUNET_PeerIdentity *) &message[1]; // YUCK!
tc = GNUNET_SERVER_transmit_context_create (client);
GNUNET_CONTAINER_multihashmap_get_multiple (sessions, &peer->hashPubKey,
&queue_connect_message, tc);
@@ -755,24 +731,22 @@ GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *cl
*/
void
GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *msg)
+ const struct GNUNET_MessageHeader *msg)
{
struct Session *session;
struct GSC_TypeMap *nmap;
nmap = GSC_TYPEMAP_get_from_message (msg);
if (NULL == nmap)
- return; /* malformed */
+ return; /* malformed */
session = find_session (peer);
if (NULL == session)
{
GNUNET_break (0);
return;
}
- GSC_CLIENTS_notify_clients_about_neighbour (peer,
- NULL, 0, /* FIXME: ATS */
- session->tmap,
- nmap);
+ GSC_CLIENTS_notify_clients_about_neighbour (peer, NULL, 0, /* FIXME: ATS */
+ session->tmap, nmap);
GSC_TYPEMAP_destroy (session->tmap);
session->tmap = nmap;
}
@@ -788,7 +762,7 @@ GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
*/
void
GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
- uint16_t type)
+ uint16_t type)
{
struct Session *session;
struct GSC_TypeMap *nmap;
@@ -797,16 +771,11 @@ GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
return;
session = find_session (peer);
GNUNET_assert (NULL != session);
- if (GNUNET_YES ==
- GSC_TYPEMAP_test_match (session->tmap,
- &type, 1))
- return; /* already in it */
- nmap = GSC_TYPEMAP_extend (session->tmap,
- &type, 1);
- GSC_CLIENTS_notify_clients_about_neighbour (peer,
- NULL, 0, /* FIXME: ATS */
- session->tmap,
- nmap);
+ if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap, &type, 1))
+ return; /* already in it */
+ nmap = GSC_TYPEMAP_extend (session->tmap, &type, 1);
+ GSC_CLIENTS_notify_clients_about_neighbour (peer, NULL, 0, /* FIXME: ATS */
+ session->tmap, nmap);
GSC_TYPEMAP_destroy (session->tmap);
session->tmap = nmap;
}
@@ -846,12 +815,9 @@ free_session_helper (void *cls, const GNUNET_HashCode * key, void *value)
void
GSC_SESSIONS_done ()
{
- GNUNET_CONTAINER_multihashmap_iterate (sessions,
- &free_session_helper,
- NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (sessions, &free_session_helper, NULL);
GNUNET_CONTAINER_multihashmap_destroy (sessions);
sessions = NULL;
}
/* end of gnunet-service-core_sessions.c */
-
diff --git a/src/core/gnunet-service-core_sessions.h b/src/core/gnunet-service-core_sessions.h
index b70bd59fd..e09cf500e 100644
--- a/src/core/gnunet-service-core_sessions.h
+++ b/src/core/gnunet-service-core_sessions.h
@@ -20,7 +20,7 @@
/**
* @file core/gnunet-service-core_neighbours.h
- * @brief code for managing of 'encrypted' sessions (key exchange done)
+ * @brief code for managing of 'encrypted' sessions (key exchange done)
* @author Christian Grothoff
*/
#ifndef GNUNET_SERVICE_CORE_SESSIONS_H
@@ -38,12 +38,12 @@
*/
void
GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
- struct GSC_KeyExchangeInfo *kx);
+ struct GSC_KeyExchangeInfo *kx);
/**
* End the session with the given peer (we are no longer
- * connected).
+ * connected).
*
* @param pid identity of peer to kill session with
*/
@@ -95,8 +95,7 @@ GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
*/
void
GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
- const struct GNUNET_MessageHeader *msg,
- int cork);
+ const struct GNUNET_MessageHeader *msg, int cork);
/**
@@ -125,7 +124,7 @@ GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
*/
void
GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *msg);
+ const struct GNUNET_MessageHeader *msg);
/**
@@ -138,7 +137,7 @@ GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
*/
void
GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
- uint16_t type);
+ uint16_t type);
/**
@@ -151,8 +150,10 @@ GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
* @param message iteration request message
*/
void
-GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+GSC_SESSIONS_handle_client_iterate_peers (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader
+ *message);
/**
@@ -166,8 +167,10 @@ GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client
* @param message iteration request message
*/
void
-GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+GSC_SESSIONS_handle_client_have_peer (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader
+ *message);
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c
index c54e446c6..d3214ea67 100644
--- a/src/core/gnunet-service-core_typemap.c
+++ b/src/core/gnunet-service-core_typemap.c
@@ -36,7 +36,7 @@
* A type map describing which messages a given neighbour is able
* to process.
*/
-struct GSC_TypeMap
+struct GSC_TypeMap
{
uint32_t bits[(UINT16_MAX + 1) / 32];
};
@@ -107,10 +107,8 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg)
switch (ntohs (msg->type))
{
case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP:
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# type maps received"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"),
+ 1, GNUNET_NO);
if (size != sizeof (struct GSC_TypeMap))
{
GNUNET_break_op (0);
@@ -120,16 +118,13 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg)
memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap));
return ret;
case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP:
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# type maps received"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"),
+ 1, GNUNET_NO);
ret = GNUNET_malloc (sizeof (struct GSC_TypeMap));
dlen = sizeof (struct GSC_TypeMap);
- if ( (Z_OK !=
- uncompress ((Bytef*) ret, &dlen,
- (const Bytef*) &msg[1], (uLong) size)) ||
- (dlen != sizeof (struct GSC_TypeMap) ) )
+ if ((Z_OK !=
+ uncompress ((Bytef *) ret, &dlen, (const Bytef *) &msg[1],
+ (uLong) size)) || (dlen != sizeof (struct GSC_TypeMap)))
{
GNUNET_break_op (0);
GNUNET_free (ret);
@@ -152,10 +147,9 @@ broadcast_my_type_map ()
struct GNUNET_MessageHeader *hdr;
hdr = GSC_TYPEMAP_compute_type_map_message ();
- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# updates to my type map"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# updates to my type map"), 1,
+ GNUNET_NO);
GSC_SESSIONS_broadcast (hdr);
GNUNET_free (hdr);
}
@@ -165,14 +159,13 @@ broadcast_my_type_map ()
* Add a set of types to our type map.
*/
void
-GSC_TYPEMAP_add (const uint16_t *types,
- unsigned int tlen)
+GSC_TYPEMAP_add (const uint16_t * types, unsigned int tlen)
{
unsigned int i;
int changed;
changed = GNUNET_NO;
- for (i=0;i<tlen;i++)
+ for (i = 0; i < tlen; i++)
{
if (0 == map_counters[types[i]]++)
{
@@ -189,14 +182,13 @@ GSC_TYPEMAP_add (const uint16_t *types,
* Remove a set of types from our type map.
*/
void
-GSC_TYPEMAP_remove (const uint16_t *types,
- unsigned int tlen)
+GSC_TYPEMAP_remove (const uint16_t * types, unsigned int tlen)
{
unsigned int i;
int changed;
changed = GNUNET_NO;
- for (i=0;i<tlen;i++)
+ for (i = 0; i < tlen; i++)
{
if (0 == --map_counters[types[i]])
{
@@ -217,19 +209,18 @@ GSC_TYPEMAP_remove (const uint16_t *types,
* @param types array of types
* @param tcnt number of entries in types
* @return GNUNET_YES if a type is in the map, GNUNET_NO if not
- */
+ */
int
-GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
- const uint16_t *types,
- unsigned int tcnt)
-{
+GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, const uint16_t * types,
+ unsigned int tcnt)
+{
unsigned int i;
if (NULL == tmap)
return GNUNET_NO;
if (0 == tcnt)
- return GNUNET_YES; /* matches all */
- for (i=0;i<tcnt;i++)
+ return GNUNET_YES; /* matches all */
+ for (i = 0; i < tcnt; i++)
if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32))))
return GNUNET_YES;
return GNUNET_NO;
@@ -243,11 +234,10 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
* @param types array of types to add
* @param tcnt number of entries in types
* @return updated type map (fresh copy)
- */
+ */
struct GSC_TypeMap *
-GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
- const uint16_t *types,
- unsigned int tcnt)
+GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t * types,
+ unsigned int tcnt)
{
struct GSC_TypeMap *ret;
unsigned int i;
@@ -255,7 +245,7 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
ret = GNUNET_malloc (sizeof (struct GSC_TypeMap));
if (NULL != tmap)
memcpy (ret, tmap, sizeof (struct GSC_TypeMap));
- for (i=0;i<tcnt;i++)
+ for (i = 0; i < tcnt; i++)
ret->bits[types[i] / 32] |= (1 << (types[i] % 32));
return ret;
}
diff --git a/src/core/gnunet-service-core_typemap.h b/src/core/gnunet-service-core_typemap.h
index d589c0b1c..ab106a161 100644
--- a/src/core/gnunet-service-core_typemap.h
+++ b/src/core/gnunet-service-core_typemap.h
@@ -39,16 +39,14 @@ struct GSC_TypeMap;
* Add a set of types to our type map.
*/
void
-GSC_TYPEMAP_add (const uint16_t *types,
- unsigned int tlen);
+GSC_TYPEMAP_add (const uint16_t * types, unsigned int tlen);
/**
* Remove a set of types from our type map.
*/
void
-GSC_TYPEMAP_remove (const uint16_t *types,
- unsigned int tlen);
+GSC_TYPEMAP_remove (const uint16_t * types, unsigned int tlen);
/**
@@ -78,11 +76,10 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg);
* @param types array of types
* @param tcnt number of entries in types
* @return GNUNET_YES if a type is in the map, GNUNET_NO if not
- */
+ */
int
-GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
- const uint16_t *types,
- unsigned int tcnt);
+GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, const uint16_t * types,
+ unsigned int tcnt);
/**
@@ -92,11 +89,10 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
* @param types array of types to add
* @param tcnt number of entries in types
* @return updated type map (fresh copy)
- */
+ */
struct GSC_TypeMap *
-GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
- const uint16_t *types,
- unsigned int tcnt);
+GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t * types,
+ unsigned int tcnt);
/**
* Create an empty type map.
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index be3edf974..e63fc9f9d 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -76,7 +76,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received (my) `%s' from transport service\n", "HELLO");
GNUNET_assert (message != NULL);
- if ((p == &p1) && (p2.th != NULL))
+ if ((p == &p1) && (p2.th != NULL))
GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
if ((p == &p2) && (p1.th != NULL))
GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
@@ -165,7 +165,8 @@ transmit_ready (void *cls, size_t size, void *buf)
static void
connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct PeerContext *pc = cls;
@@ -218,7 +219,8 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
static int
inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core provides inbound data from `%4s'.\n", GNUNET_i2s (other));
@@ -229,7 +231,8 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
static int
outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core notifies about outbound data for `%4s'.\n",
@@ -242,7 +245,8 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
static int
process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message from `%4s'.\n",
GNUNET_i2s (peer));
@@ -296,9 +300,8 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server,
/* connect p2 */
p2.ch =
GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify,
- &disconnect_notify, &inbound_notify,
- GNUNET_YES, &outbound_notify, GNUNET_YES,
- handlers);
+ &disconnect_notify, &inbound_notify, GNUNET_YES,
+ &outbound_notify, GNUNET_YES, handlers);
}
else
{
@@ -344,8 +347,8 @@ run (void *cls, char *const *args, const char *cfgfile,
&terminate_task_error, NULL);
p1.ch =
GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify,
- &disconnect_notify, &inbound_notify,
- GNUNET_YES, &outbound_notify, GNUNET_YES, handlers);
+ &disconnect_notify, &inbound_notify, GNUNET_YES,
+ &outbound_notify, GNUNET_YES, handlers);
}
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 6a764c126..b2079ba35 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -156,7 +156,7 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_CORE_disconnect (p2.ch);
p2.ch = NULL;
}
- if (connect_task != GNUNET_SCHEDULER_NO_TASK)
+ if (connect_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (connect_task);
if (p1.th != NULL)
{
@@ -177,8 +177,9 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &try_connect, NULL);
+ connect_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
+ NULL);
GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
}
@@ -239,7 +240,8 @@ transmit_ready (void *cls, size_t size, void *buf)
static void
connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct PeerContext *pc = cls;
@@ -284,7 +286,8 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
static int
inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -297,7 +300,8 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
static int
outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -314,7 +318,8 @@ transmit_ready (void *cls, size_t size, void *buf);
static int
process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
static int n;
unsigned int s;
diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c
index cf9608ede..29b1f75f3 100644
--- a/src/core/test_core_api_send_to_self.c
+++ b/src/core/test_core_api_send_to_self.c
@@ -182,8 +182,8 @@ run (void *cls, char *const *args, const char *cfgfile,
"test_core_api_peer1.conf"));
core =
- GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL,
- NULL, 0, NULL, 0, handlers);
+ GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL, NULL,
+ 0, NULL, 0, handlers);
die_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index f27866c19..b06b97899 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -68,7 +68,7 @@ static int ok;
static void
connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
}
@@ -83,7 +83,7 @@ static int
inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
return GNUNET_OK;
}
@@ -93,7 +93,7 @@ static int
outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
return GNUNET_OK;
}
@@ -130,9 +130,8 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server,
/* connect p2 */
p2.ch =
GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify,
- &disconnect_notify, &inbound_notify,
- GNUNET_YES, &outbound_notify, GNUNET_YES,
- handlers);
+ &disconnect_notify, &inbound_notify, GNUNET_YES,
+ &outbound_notify, GNUNET_YES, handlers);
}
else
{
@@ -193,8 +192,8 @@ run (void *cls, char *const *args, const char *cfgfile,
&timeout_task, NULL);
p1.ch =
GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify,
- &disconnect_notify, &inbound_notify,
- GNUNET_YES, &outbound_notify, GNUNET_YES, handlers);
+ &disconnect_notify, &inbound_notify, GNUNET_YES,
+ &outbound_notify, GNUNET_YES, handlers);
}
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index be875c235..856ed13fd 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -185,8 +185,9 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- connect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &try_connect, NULL);
+ connect_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect,
+ NULL);
GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
GNUNET_TRANSPORT_try_connect (p2.th, &p1.id);
}
@@ -231,13 +232,11 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value;
- throughput_out = total_bytes_sent * 1000 / delta; /* convert to bytes/s */
- throughput_in = total_bytes_recv * 1000 / delta; /* convert to bytes/s */
+ throughput_out = total_bytes_sent * 1000 / delta; /* convert to bytes/s */
+ throughput_in = total_bytes_recv * 1000 / delta; /* convert to bytes/s */
- max_quota_in = GNUNET_MIN (current_quota_p1_in,
- current_quota_p2_in);
- max_quota_out = GNUNET_MIN (current_quota_p1_out,
- current_quota_p2_out);
+ max_quota_in = GNUNET_MIN (current_quota_p1_in, current_quota_p2_in);
+ max_quota_out = GNUNET_MIN (current_quota_p1_out, current_quota_p2_out);
if (max_quota_out < max_quota_in)
quota_delta = max_quota_in / 5;
else
@@ -274,7 +273,7 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2);
if (ok != 0)
- kind = GNUNET_ERROR_TYPE_ERROR;
+ kind = GNUNET_ERROR_TYPE_ERROR;
switch (test)
{
case SYMMETRIC:
@@ -294,12 +293,10 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
};
GNUNET_log (kind, "Peer 1 send rate: %llu b/s (%llu bytes in %llu ms)\n",
throughput_out, total_bytes_sent, delta);
- GNUNET_log (kind, "Peer 1 send quota: %llu b/s\n",
- current_quota_p1_out);
+ GNUNET_log (kind, "Peer 1 send quota: %llu b/s\n", current_quota_p1_out);
GNUNET_log (kind, "Peer 2 receive rate: %llu b/s (%llu bytes in %llu ms)\n",
throughput_in, total_bytes_recv, delta);
- GNUNET_log (kind, "Peer 2 receive quota: %llu b/s\n",
- current_quota_p2_in);
+ GNUNET_log (kind, "Peer 2 receive quota: %llu b/s\n", current_quota_p2_in);
/*
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu b/s\n",max_quota_in );
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu b/s\n",max_quota_out);
@@ -322,10 +319,11 @@ transmit_ready (void *cls, size_t size, void *buf)
{
if ((p1.ch != NULL) && (p1.connect_status == 1))
GNUNET_break (NULL !=
- (p1.nth = GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
- FAST_TIMEOUT, &p2.id,
- MESSAGESIZE,
- &transmit_ready, &p1)));
+ (p1.nth =
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ FAST_TIMEOUT, &p2.id,
+ MESSAGESIZE,
+ &transmit_ready, &p1)));
return 0;
}
GNUNET_assert (tr_n < TOTAL_MSGS);
@@ -364,12 +362,13 @@ transmit_ready (void *cls, size_t size, void *buf)
static void
connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct PeerContext *pc = cls;
if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity)))
- return; /* loopback */
+ return; /* loopback */
GNUNET_assert (pc->connect_status == 0);
pc->connect_status = 1;
if (pc == &p1)
@@ -393,10 +392,11 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
NULL);
GNUNET_break (NULL !=
- (p1.nth = GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
- TIMEOUT, &p2.id,
- MESSAGESIZE,
- &transmit_ready, &p1)));
+ (p1.nth =
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ TIMEOUT, &p2.id,
+ MESSAGESIZE,
+ &transmit_ready, &p1)));
}
}
@@ -407,12 +407,12 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
struct PeerContext *pc = cls;
if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity)))
- return; /* loopback */
+ return; /* loopback */
pc->connect_status = 0;
if (GNUNET_SCHEDULER_NO_TASK != measure_task)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Measurement aborted due to disconnect!\n");
+ "Measurement aborted due to disconnect!\n");
GNUNET_SCHEDULER_cancel (measure_task);
measure_task = GNUNET_SCHEDULER_NO_TASK;
}
@@ -431,7 +431,8 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
static int
inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
#if DEBUG_TRANSMISSION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -446,7 +447,8 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
static int
outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
#if DEBUG_TRANSMISSION
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -463,7 +465,8 @@ transmit_ready (void *cls, size_t size, void *buf);
static int
process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
static int n;
const struct TestMessage *hdr;
@@ -532,9 +535,10 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server,
GNUNET_assert (ok == 2);
OKPP;
/* connect p2 */
- p2.ch = GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify,
- &disconnect_notify, &inbound_notify, GNUNET_YES,
- &outbound_notify, GNUNET_YES, handlers);
+ p2.ch =
+ GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify,
+ &disconnect_notify, &inbound_notify, GNUNET_YES,
+ &outbound_notify, GNUNET_YES, handlers);
}
else
{
@@ -546,8 +550,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server,
"Asking core (1) to connect to peer `%4s'\n",
GNUNET_i2s (&p2.id));
#endif
- connect_task = GNUNET_SCHEDULER_add_now (&try_connect,
- NULL);
+ connect_task = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
}
@@ -642,9 +645,10 @@ run (void *cls, char *const *args, const char *cfgfile,
"TOTAL_QUOTA_OUT",
&current_quota_p2_out));
- p1.ch = GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify,
- &disconnect_notify, &inbound_notify, GNUNET_YES,
- &outbound_notify, GNUNET_YES, handlers);
+ p1.ch =
+ GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify,
+ &disconnect_notify, &inbound_notify, GNUNET_YES,
+ &outbound_notify, GNUNET_YES, handlers);
}
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 324ab78ef..d68ba72b5 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -109,8 +109,7 @@ env_delete_notify (void *cls, const GNUNET_HashCode * key, size_t size)
struct GNUNET_DATACACHE_Handle *h = cls;
#if DEBUG_DATACACHE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Content under key `%s' discarded\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Content under key `%s' discarded\n",
GNUNET_h2s (key));
#endif
GNUNET_assert (h->utilization >= size);
@@ -243,8 +242,7 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
return GNUNET_SYSERR;
}
#if DEBUG_DATACACHE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Stored data under key `%s' in cache\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Stored data under key `%s' in cache\n",
GNUNET_h2s (key));
#endif
GNUNET_STATISTICS_update (h->stats, gettext_noop ("# bytes stored"), size,
@@ -276,8 +274,7 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
GNUNET_STATISTICS_update (h->stats, gettext_noop ("# requests received"), 1,
GNUNET_NO);
#if DEBUG_DATACACHE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Processing request for key `%s'\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n",
GNUNET_h2s (key));
#endif
if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key))
@@ -287,9 +284,8 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
("# requests filtered by bloom filter"), 1,
GNUNET_NO);
#if DEBUG_DATACACHE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Bloomfilter filters request for key `%s'\n",
- GNUNET_h2s (key));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Bloomfilter filters request for key `%s'\n",
+ GNUNET_h2s (key));
#endif
return 0; /* can not be present */
}
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c
index 44799be63..f852d3b06 100644
--- a/src/datacache/plugin_datacache_sqlite.c
+++ b/src/datacache/plugin_datacache_sqlite.c
@@ -123,9 +123,8 @@ sqlite_plugin_put (void *cls, const GNUNET_HashCode * key, size_t size,
"INSERT INTO ds090 (type, expire, key, value) VALUES (?, ?, ?, ?)",
&stmt) != SQLITE_OK)
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sq_prepare");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
return 0;
}
if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) ||
@@ -192,9 +191,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
"SELECT count(*) FROM ds090 WHERE key=? AND type=? AND expire >= ?",
&stmt) != SQLITE_OK)
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sq_prepare");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
return 0;
}
ntime = (int64_t) now.abs_value;
@@ -218,8 +216,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
sqlite3_finalize (stmt);
#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "No content found when processing `%s' for key `%4s'\n",
- "GET", GNUNET_h2s (key));
+ "No content found when processing `%s' for key `%4s'\n", "GET",
+ GNUNET_h2s (key));
#endif
return 0;
}
@@ -230,8 +228,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
#if DEBUG_DATACACHE_SQLITE
if (0 == total)
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "No content found when processing `%s' for key `%4s'\n",
- "GET", GNUNET_h2s (key));
+ "No content found when processing `%s' for key `%4s'\n", "GET",
+ GNUNET_h2s (key));
#endif
return total;
}
@@ -246,9 +244,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
off);
if (sq_prepare (plugin->dbh, scratch, &stmt) != SQLITE_OK)
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sq_prepare");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
return cnt;
}
if ((SQLITE_OK !=
@@ -273,10 +270,8 @@ sqlite_plugin_get (void *cls, const GNUNET_HashCode * key,
cnt++;
#if DEBUG_DATACACHE_SQLITE
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found %u-byte result when processing `%s' for key `%4s'\n",
- (unsigned int) size,
- "GET",
- GNUNET_h2s (key));
+ "Found %u-byte result when processing `%s' for key `%4s'\n",
+ (unsigned int) size, "GET", GNUNET_h2s (key));
#endif
if (GNUNET_OK != iter (iter_cls, exp, key, size, dat, type))
{
@@ -316,18 +311,16 @@ sqlite_plugin_del (void *cls)
"SELECT _ROWID_,key,value FROM ds090 ORDER BY expire ASC LIMIT 1",
&stmt) != SQLITE_OK)
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sq_prepare");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
if (stmt != NULL)
(void) sqlite3_finalize (stmt);
return GNUNET_SYSERR;
}
if (SQLITE_ROW != sqlite3_step (stmt))
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_step");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_step");
(void) sqlite3_finalize (stmt);
return GNUNET_SYSERR;
}
@@ -336,42 +329,35 @@ sqlite_plugin_del (void *cls)
memcpy (&hc, sqlite3_column_blob (stmt, 1), sizeof (GNUNET_HashCode));
dsize = sqlite3_column_bytes (stmt, 2);
if (SQLITE_OK != sqlite3_finalize (stmt))
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_step");
- if (sq_prepare
- (plugin->dbh, "DELETE FROM ds090 WHERE _ROWID_=?",
- &dstmt) != SQLITE_OK)
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_step");
+ if (sq_prepare (plugin->dbh, "DELETE FROM ds090 WHERE _ROWID_=?", &dstmt) !=
+ SQLITE_OK)
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sq_prepare");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sq_prepare");
if (stmt != NULL)
(void) sqlite3_finalize (stmt);
return GNUNET_SYSERR;
}
- if (SQLITE_OK !=
- sqlite3_bind_int64 (dstmt, 1, rowid))
+ if (SQLITE_OK != sqlite3_bind_int64 (dstmt, 1, rowid))
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_bind");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_bind");
(void) sqlite3_finalize (dstmt);
return GNUNET_SYSERR;
}
if (sqlite3_step (dstmt) != SQLITE_DONE)
{
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_step");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_step");
(void) sqlite3_finalize (dstmt);
return GNUNET_SYSERR;
}
plugin->env->delete_notify (plugin->env->cls, &hc, dsize + OVERHEAD);
if (SQLITE_OK != sqlite3_finalize (dstmt))
- LOG_SQLITE (plugin->dbh,
- GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "sqlite3_finalize");
+ LOG_SQLITE (plugin->dbh, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "sqlite3_finalize");
return GNUNET_OK;
}
@@ -435,8 +421,7 @@ libgnunet_plugin_datacache_sqlite_init (void *cls)
api->get = &sqlite_plugin_get;
api->put = &sqlite_plugin_put;
api->del = &sqlite_plugin_del;
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("Sqlite datacache running\n"));
+ LOG (GNUNET_ERROR_TYPE_INFO, _("Sqlite datacache running\n"));
return api;
}
@@ -468,19 +453,19 @@ libgnunet_plugin_datacache_sqlite_done (void *cls)
if (result == SQLITE_BUSY)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Tried to close sqlite without finalizing all prepared statements.\n"));
+ _
+ ("Tried to close sqlite without finalizing all prepared statements.\n"));
stmt = sqlite3_next_stmt (plugin->dbh, NULL);
while (stmt != NULL)
{
#if DEBUG_SQLITE
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Closing statement %p\n", stmt);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Closing statement %p\n", stmt);
#endif
result = sqlite3_finalize (stmt);
#if DEBUG_SQLITE
if (result != SQLITE_OK)
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to close statement %p: %d\n", stmt, result);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to close statement %p: %d\n",
+ stmt, result);
#endif
stmt = sqlite3_next_stmt (plugin->dbh, NULL);
}
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 318c22cf5..6d3d56c02 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -325,41 +325,35 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg,
&plugin->updRepl) != SQLITE_OK) ||
(sq_prepare
(plugin->dbh,
- "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ "
- "FROM gn090 "
+ "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " "FROM gn090 "
#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_repl_rvalue "
+ "INDEXED BY idx_repl_rvalue "
#endif
- "WHERE repl=?2 AND "
- " (rvalue>=?1 OR "
+ "WHERE repl=?2 AND " " (rvalue>=?1 OR "
" NOT EXISTS (SELECT 1 FROM gn090 "
#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_repl_rvalue "
+ "INDEXED BY idx_repl_rvalue "
#endif
- "WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) "
+ "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"
+ (sq_prepare (plugin->dbh, "SELECT MAX(repl) FROM gn090"
#if SQLITE_VERSION_NUMBER >= 3007000
- " INDEXED BY idx_repl_rvalue"
+ " INDEXED BY idx_repl_rvalue"
#endif
- "",
- &plugin->maxRepl) != SQLITE_OK) ||
+ "", &plugin->maxRepl) != SQLITE_OK) ||
(sq_prepare
(plugin->dbh,
- "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ "
- "FROM gn090 "
+ "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " "FROM gn090 "
#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_expire "
+ "INDEXED BY idx_expire "
#endif
"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 "
+ "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " "FROM gn090 "
#if SQLITE_VERSION_NUMBER >= 3007000
- "INDEXED BY idx_anon_type_hash "
+ "INDEXED BY idx_anon_type_hash "
#endif
"WHERE (anonLevel = 0 AND type=?1) "
"ORDER BY hash DESC LIMIT 1 OFFSET ?2",
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index b1dd0e5de..0309a6592 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -185,11 +185,11 @@ check_value (void *cls, const GNUNET_HashCode * key, size_t size,
if (NULL == key)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Value check failed (got NULL key) in %d/%d\n",
- crc->phase, crc->i);
+ "Value check failed (got NULL key) in %d/%d\n", crc->phase,
+ crc->i);
crc->phase = RP_ERROR;
GNUNET_SCHEDULER_add_continuation (&run_continuation, crc,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ GNUNET_SCHEDULER_REASON_PREREQ_DONE);
return;
}
#if 0
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index 720e82a41..ac69b7a4e 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -249,12 +249,11 @@ add_request_to_pending (void *cls, const GNUNET_HashCode * key, void *value)
struct GNUNET_DHT_GetHandle *rh = value;
if (GNUNET_NO == rh->message->in_pending_queue)
- {
+ {
#if DEBUG_DHT
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Retransmitting request related to %s to DHT %p\n",
- GNUNET_h2s (key),
- handle);
+ "Retransmitting request related to %s to DHT %p\n", GNUNET_h2s (key),
+ handle);
#endif
GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
rh->message);
@@ -284,9 +283,7 @@ try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_DHT_Handle *handle = cls;
#if DEBUG_DHT
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Reconnecting with DHT %p\n",
- handle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting with DHT %p\n", handle);
#endif
handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
if (handle->retry_time.rel_value < GNUNET_CONSTANTS_SERVICE_RETRY.rel_value)
@@ -324,8 +321,8 @@ do_disconnect (struct GNUNET_DHT_Handle *handle)
GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
handle->th = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnecting from DHT service, will try to reconnect in %llu ms\n",
- (unsigned long long) handle->retry_time.rel_value);
+ "Disconnecting from DHT service, will try to reconnect in %llu ms\n",
+ (unsigned long long) handle->retry_time.rel_value);
GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO);
handle->client = NULL;
handle->reconnect_task =
@@ -351,7 +348,7 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle)
if (handle->client == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "process_pending_messages called, but client is null, reconnecting\n");
+ "process_pending_messages called, but client is null, reconnecting\n");
do_disconnect (handle);
return;
}
@@ -368,7 +365,7 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle)
if (NULL != handle->th)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "notify_transmit_ready returned NULL, reconnecting\n");
+ "notify_transmit_ready returned NULL, reconnecting\n");
do_disconnect (handle);
}
@@ -432,7 +429,7 @@ transmit_pending (void *cls, size_t size, void *buf)
#endif
handle->in_receive = GNUNET_YES;
GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ GNUNET_TIME_UNIT_FOREVER_REL);
}
return tsize;
}
@@ -466,9 +463,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
{
/* UID mismatch */
#if DEBUG_DHT
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Ignoring reply for %s: UID mismatch: %llu/%llu\n",
- GNUNET_h2s (key),
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Ignoring reply for %s: UID mismatch: %llu/%llu\n", GNUNET_h2s (key),
dht_msg->unique_id, get_handle->unique_id);
#endif
return GNUNET_YES;
@@ -490,10 +486,8 @@ process_reply (void *cls, const GNUNET_HashCode * key, void *value)
}
data_length = msize - meta_length;
#if DEBUG_DHT
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Giving %u byte reply for %s to application\n",
- (unsigned int) data_length,
- GNUNET_h2s (key));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving %u byte reply for %s to application\n",
+ (unsigned int) data_length, GNUNET_h2s (key));
#endif
put_path = (const struct GNUNET_PeerIdentity *) &dht_msg[1];
get_path = &put_path[put_path_length];
@@ -542,10 +536,8 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
}
dht_msg = (const struct GNUNET_DHT_ClientResultMessage *) msg;
#if DEBUG_DHT
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received reply for `%s' from DHT service %p\n",
- GNUNET_h2s (&dht_msg->key),
- handle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Received reply for `%s' from DHT service %p\n",
+ GNUNET_h2s (&dht_msg->key), handle);
#endif
GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests,
&dht_msg->key, &process_reply,
@@ -641,7 +633,7 @@ timeout_put_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct GNUNET_DHT_Handle *handle;
handle = pending->handle;
- GNUNET_assert (GNUNET_YES == pending->in_pending_queue);
+ GNUNET_assert (GNUNET_YES == pending->in_pending_queue);
GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail,
pending);
pending->in_pending_queue = GNUNET_NO;
@@ -752,10 +744,8 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
return NULL;
}
#if DEBUG_DHT
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending query for %s to DHT %p\n",
- GNUNET_h2s (key),
- handle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending query for %s to DHT %p\n",
+ GNUNET_h2s (key), handle);
#endif
pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
get_msg = (struct GNUNET_DHT_ClientGetMessage *) &pending[1];
@@ -803,10 +793,8 @@ GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle)
get_msg =
(const struct GNUNET_DHT_ClientGetMessage *) get_handle->message->msg;
#if DEBUG_DHT
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending STOP for %s to DHT via %p\n",
- GNUNET_h2s (&get_msg->key),
- handle);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending STOP for %s to DHT via %p\n",
+ GNUNET_h2s (&get_msg->key), handle);
#endif
/* generate STOP */
pending =
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c
index 8720e76aa..763ff8e6f 100644
--- a/src/dht/gnunet-dht-get.c
+++ b/src/dht/gnunet-dht-get.c
@@ -124,10 +124,10 @@ static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, 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);
@@ -186,9 +186,9 @@ run (void *cls, char *const *args, const char *cfgfile,
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,
- replication, GNUNET_DHT_RO_NONE, NULL,
- 0, &get_result_iterator, NULL);
+ GNUNET_DHT_get_start (dht_handle, timeout, query_type, &key, replication,
+ GNUNET_DHT_RO_NONE, NULL, 0, &get_result_iterator,
+ NULL);
}
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c
index f165aa4a4..079a8866e 100644
--- a/src/dht/gnunet-dht-put.c
+++ b/src/dht/gnunet-dht-put.c
@@ -151,9 +151,9 @@ run (void *cls, char *const *args, const char *cfgfile,
if (verbose)
fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"),
query_key, data);
- GNUNET_DHT_put (dht_handle, &key, replication, GNUNET_DHT_RO_NONE,
- query_type, strlen (data), data, expiration, timeout,
- &message_sent_cont, NULL);
+ GNUNET_DHT_put (dht_handle, &key, replication, GNUNET_DHT_RO_NONE, query_type,
+ strlen (data), data, expiration, timeout, &message_sent_cont,
+ NULL);
}
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 3e0f3c8d9..72575acae 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -81,8 +81,7 @@ static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
* @param message HELLO message of peer
*/
static void
-process_hello (void *cls,
- const struct GNUNET_MessageHeader *message)
+process_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
GNUNET_assert (message != NULL);
GNUNET_free_non_null (GDS_my_hello);
@@ -149,24 +148,22 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
GDS_DATACACHE_init ();
GDS_HELLO_init ();
GDS_CLIENTS_init (server);
- if (GNUNET_OK !=
- GDS_NEIGHBOURS_init ())
- {
- shutdown_task (NULL, NULL);
- return;
- }
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task, NULL);
+ if (GNUNET_OK != GDS_NEIGHBOURS_init ())
+ {
+ shutdown_task (NULL, NULL);
+ return;
+ }
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
+ NULL);
GDS_transport_handle =
- GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL);
+ GNUNET_TRANSPORT_connect (GDS_cfg, NULL, NULL, NULL, NULL, NULL);
if (GDS_transport_handle == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to connect to transport service!\n"));
- return;
- }
- ghh = GNUNET_TRANSPORT_get_hello (GDS_transport_handle,
- &process_hello, NULL);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to connect to transport service!\n"));
+ return;
+ }
+ ghh = GNUNET_TRANSPORT_get_hello (GDS_transport_handle, &process_hello, NULL);
}
@@ -181,12 +178,11 @@ int
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;
GDS_CLIENTS_done ();
return ret;
}
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 4b9eecc58..dde8c6d7a 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -53,7 +53,7 @@ struct PendingMessage
/**
* Actual message to be sent, allocated at the end of the struct:
- * // msg = (cast) &pm[1];
+ * // msg = (cast) &pm[1];
* // memcpy (&pm[1], data, len);
*/
const struct GNUNET_MessageHeader *msg;
@@ -224,15 +224,13 @@ find_active_client (struct GNUNET_SERVER_Client *client)
}
ret = GNUNET_malloc (sizeof (struct ClientList));
ret->client_handle = client;
- GNUNET_CONTAINER_DLL_insert (client_head,
- client_tail,
- ret);
+ GNUNET_CONTAINER_DLL_insert (client_head, client_tail, ret);
return ret;
}
/**
- * Iterator over hash map entries that frees all entries
+ * Iterator over hash map entries that frees all entries
* associated with the given client.
*
* @param cls client to search for in source routes
@@ -250,18 +248,15 @@ remove_client_records (void *cls, const GNUNET_HashCode * key, void *value)
return GNUNET_YES;
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing client %p's record for key %s\n",
- client,
- GNUNET_h2s (key));
+ "Removing client %p's record for key %s\n", client,
+ GNUNET_h2s (key));
#endif
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (forward_map,
- key, record));
+ GNUNET_CONTAINER_multihashmap_remove (forward_map, key,
+ record));
if (NULL != record->hnode)
GNUNET_CONTAINER_heap_remove_node (record->hnode);
- GNUNET_array_grow (record->seen_replies,
- record->seen_replies_count,
- 0);
+ GNUNET_array_grow (record->seen_replies, record->seen_replies_count, 0);
GNUNET_free (record);
return GNUNET_YES;
}
@@ -276,37 +271,31 @@ remove_client_records (void *cls, const GNUNET_HashCode * key, void *value)
* for the last call when the server is destroyed
*/
static void
-handle_client_disconnect (void *cls,
- struct GNUNET_SERVER_Client *client)
+handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
{
struct ClientList *pos;
struct PendingMessage *reply;
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Local client %p disconnects\n",
- client);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local client %p disconnects\n", client);
#endif
pos = find_active_client (client);
- GNUNET_CONTAINER_DLL_remove (client_head,
- client_tail,
- pos);
+ GNUNET_CONTAINER_DLL_remove (client_head, client_tail, pos);
if (pos->transmit_handle != NULL)
GNUNET_CONNECTION_notify_transmit_ready_cancel (pos->transmit_handle);
while (NULL != (reply = pos->pending_head))
- {
- GNUNET_CONTAINER_DLL_remove (pos->pending_head, pos->pending_tail,
- reply);
- GNUNET_free (reply);
- }
- GNUNET_CONTAINER_multihashmap_iterate (forward_map,
- &remove_client_records, pos);
+ {
+ GNUNET_CONTAINER_DLL_remove (pos->pending_head, pos->pending_tail, reply);
+ GNUNET_free (reply);
+ }
+ GNUNET_CONTAINER_multihashmap_iterate (forward_map, &remove_client_records,
+ pos);
GNUNET_free (pos);
}
/**
- * Route the given request via the DHT. This includes updating
+ * Route the given request via the DHT. This includes updating
* the bloom filter and retransmission times, building the P2P
* message and initiating the routing operation.
*/
@@ -318,33 +307,30 @@ transmit_request (struct ClientQueryRecord *cqr)
struct GNUNET_CONTAINER_BloomFilter *peer_bf;
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# GET requests from clients injected"), 1,
+ gettext_noop
+ ("# GET requests from clients injected"), 1,
GNUNET_NO);
- reply_bf_mutator = (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX);
- reply_bf = GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator,
- cqr->seen_replies,
- cqr->seen_replies_count);
- peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
- DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
- GDS_NEIGHBOURS_handle_get (cqr->type,
- cqr->msg_options,
- cqr->replication,
- 0 /* hop count */,
- &cqr->key,
- cqr->xquery,
- cqr->xquery_size,
- reply_bf,
- reply_bf_mutator,
- peer_bf);
+ reply_bf_mutator =
+ (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT32_MAX);
+ reply_bf =
+ GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator, cqr->seen_replies,
+ cqr->seen_replies_count);
+ peer_bf =
+ GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GDS_NEIGHBOURS_handle_get (cqr->type, cqr->msg_options, cqr->replication,
+ 0 /* hop count */ ,
+ &cqr->key, cqr->xquery, cqr->xquery_size, reply_bf,
+ reply_bf_mutator, peer_bf);
GNUNET_CONTAINER_bloomfilter_free (reply_bf);
GNUNET_CONTAINER_bloomfilter_free (peer_bf);
/* exponential back-off for retries, max 1h */
- cqr->retry_frequency =
- GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS,
- GNUNET_TIME_relative_multiply (cqr->retry_frequency, 2));
+ cqr->retry_frequency =
+ GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS,
+ GNUNET_TIME_relative_multiply
+ (cqr->retry_frequency, 2));
cqr->retry_time = GNUNET_TIME_relative_to_absolute (cqr->retry_frequency);
}
@@ -359,7 +345,7 @@ transmit_request (struct ClientQueryRecord *cqr)
*/
static void
transmit_next_request_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ClientQueryRecord *cqr;
struct GNUNET_TIME_Relative delay;
@@ -368,22 +354,24 @@ transmit_next_request_task (void *cls,
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap)))
+ {
+ cqr->hnode = NULL;
+ delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time);
+ if (delay.rel_value > 0)
{
- cqr->hnode = NULL;
- delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time);
- if (delay.rel_value > 0)
- {
- cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value);
- retry_task = GNUNET_SCHEDULER_add_delayed (delay,
- &transmit_next_request_task,
- NULL);
- return;
- }
- transmit_request (cqr);
- cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value);
+ cqr->hnode =
+ GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
+ cqr->retry_time.abs_value);
+ retry_task =
+ GNUNET_SCHEDULER_add_delayed (delay, &transmit_next_request_task,
+ NULL);
+ return;
}
+ transmit_request (cqr);
+ cqr->hnode =
+ GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
+ cqr->retry_time.abs_value);
+ }
}
@@ -396,58 +384,52 @@ transmit_next_request_task (void *cls,
*/
static void
handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientPutMessage *dht_msg;
struct GNUNET_CONTAINER_BloomFilter *peer_bf;
uint16_t size;
-
+
size = ntohs (message->size);
if (size < sizeof (struct GNUNET_DHT_ClientPutMessage))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# PUT requests received from clients"), 1,
+ gettext_noop
+ ("# PUT requests received from clients"), 1,
GNUNET_NO);
dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
/* give to local clients */
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Handling local PUT of %u-bytes for query %s\n",
- size - sizeof (struct GNUNET_DHT_ClientPutMessage),
- GNUNET_h2s (&dht_msg->key));
+ "Handling local PUT of %u-bytes for query %s\n",
+ size - sizeof (struct GNUNET_DHT_ClientPutMessage),
+ GNUNET_h2s (&dht_msg->key));
#endif
GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- &dht_msg->key,
- 0, NULL,
- 0, NULL,
- ntohl (dht_msg->type),
- size - sizeof (struct GNUNET_DHT_ClientPutMessage),
- &dht_msg[1]);
+ &dht_msg->key, 0, NULL, 0, NULL,
+ ntohl (dht_msg->type),
+ size - sizeof (struct GNUNET_DHT_ClientPutMessage),
+ &dht_msg[1]);
/* store locally */
GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- &dht_msg->key,
- 0, NULL,
- ntohl (dht_msg->type),
- size - sizeof (struct GNUNET_DHT_ClientPutMessage),
- &dht_msg[1]);
+ &dht_msg->key, 0, NULL, ntohl (dht_msg->type),
+ size - sizeof (struct GNUNET_DHT_ClientPutMessage),
+ &dht_msg[1]);
/* route to other peers */
- peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
- DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
- GDS_NEIGHBOURS_handle_put (ntohl (dht_msg->type),
- ntohl (dht_msg->options),
- ntohl (dht_msg->desired_replication_level),
- GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- 0 /* hop count */,
- peer_bf,
- &dht_msg->key,
- 0, NULL,
- &dht_msg[1],
- size - sizeof (struct GNUNET_DHT_ClientPutMessage));
+ peer_bf =
+ GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GDS_NEIGHBOURS_handle_put (ntohl (dht_msg->type), ntohl (dht_msg->options),
+ ntohl (dht_msg->desired_replication_level),
+ GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
+ 0 /* hop count */ ,
+ peer_bf, &dht_msg->key, 0, NULL, &dht_msg[1],
+ size -
+ sizeof (struct GNUNET_DHT_ClientPutMessage));
GNUNET_CONTAINER_bloomfilter_free (peer_bf);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -464,58 +446,55 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
*/
static void
handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientGetMessage *get;
struct ClientQueryRecord *cqr;
size_t xquery_size;
- const char* xquery;
+ const char *xquery;
uint16_t size;
size = ntohs (message->size);
if (size < sizeof (struct GNUNET_DHT_ClientGetMessage))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
xquery_size = size - sizeof (struct GNUNET_DHT_ClientGetMessage);
get = (const struct GNUNET_DHT_ClientGetMessage *) message;
- xquery = (const char*) &get[1];
+ xquery = (const char *) &get[1];
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# GET requests received from clients"), 1,
+ gettext_noop
+ ("# GET requests received from clients"), 1,
GNUNET_NO);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received request for %s from local client %p\n",
- GNUNET_h2s (&get->key),
- client);
+ "Received request for %s from local client %p\n",
+ GNUNET_h2s (&get->key), client);
#endif
cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
cqr->key = get->key;
cqr->client = find_active_client (client);
- cqr->xquery = (void*) &cqr[1];
+ cqr->xquery = (void *) &cqr[1];
memcpy (&cqr[1], xquery, xquery_size);
- cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0);
+ cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0);
cqr->retry_frequency = GNUNET_TIME_UNIT_MILLISECONDS;
cqr->retry_time = GNUNET_TIME_absolute_get ();
cqr->unique_id = get->unique_id;
cqr->xquery_size = xquery_size;
cqr->replication = ntohl (get->desired_replication_level);
cqr->msg_options = ntohl (get->options);
- cqr->type = ntohl (get->type);
+ cqr->type = ntohl (get->type);
GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* start remote requests */
if (GNUNET_SCHEDULER_NO_TASK != retry_task)
GNUNET_SCHEDULER_cancel (retry_task);
retry_task = GNUNET_SCHEDULER_add_now (&transmit_next_request_task, NULL);
/* perform local lookup */
- GDS_DATACACHE_handle_get (&get->key,
- cqr->type,
- cqr->xquery,
- xquery_size,
- NULL, 0);
+ GDS_DATACACHE_handle_get (&get->key, cqr->type, cqr->xquery, xquery_size,
+ NULL, 0);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -538,7 +517,7 @@ struct RemoveByUniqueIdContext
/**
- * Iterator over hash map entries that frees all entries
+ * Iterator over hash map entries that frees all entries
* that match the given client and unique ID.
*
* @param cls unique ID and client to search for in source routes
@@ -556,9 +535,8 @@ remove_by_unique_id (void *cls, const GNUNET_HashCode * key, void *value)
return GNUNET_YES;
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing client %p's record for key %s (by unique id)\n",
- ctx->client->client_handle,
- GNUNET_h2s (key));
+ "Removing client %p's record for key %s (by unique id)\n",
+ ctx->client->client_handle, GNUNET_h2s (key));
#endif
return remove_client_records (ctx->client, key, record);
}
@@ -575,27 +553,24 @@ remove_by_unique_id (void *cls, const GNUNET_HashCode * key, void *value)
*/
static void
handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg =
- (const struct GNUNET_DHT_ClientGetStopMessage *) message;
+ (const struct GNUNET_DHT_ClientGetStopMessage *) message;
struct RemoveByUniqueIdContext ctx;
-
+
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# GET STOP requests received from clients"), 1,
+ gettext_noop
+ ("# GET STOP requests received from clients"), 1,
GNUNET_NO);
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %p stopped request for key %s\n",
- client,
- GNUNET_h2s (&dht_stop_msg->key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p stopped request for key %s\n",
+ client, GNUNET_h2s (&dht_stop_msg->key));
#endif
ctx.client = find_active_client (client);
ctx.unique_id = dht_stop_msg->unique_id;
- GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
- &dht_stop_msg->key,
- &remove_by_unique_id,
- &ctx);
+ GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, &dht_stop_msg->key,
+ &remove_by_unique_id, &ctx);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -636,8 +611,8 @@ send_reply_to_client (void *cls, size_t size, void *buf)
/* client disconnected */
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %p disconnected, pending messages will be discarded\n",
- client->client_handle);
+ "Client %p disconnected, pending messages will be discarded\n",
+ client->client_handle);
#endif
return 0;
}
@@ -650,20 +625,15 @@ send_reply_to_client (void *cls, size_t size, void *buf)
memcpy (&cbuf[off], reply->msg, msize);
GNUNET_free (reply);
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting %u bytes to client %p\n",
- msize,
- client->client_handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to client %p\n",
+ msize, client->client_handle);
#endif
off += msize;
}
process_pending_messages (client);
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitted %u/%u bytes to client %p\n",
- (unsigned int) off,
- (unsigned int) size,
- client->client_handle);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitted %u/%u bytes to client %p\n",
+ (unsigned int) off, (unsigned int) size, client->client_handle);
#endif
return off;
}
@@ -681,20 +651,17 @@ process_pending_messages (struct ClientList *client)
{
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Not asking for transmission to %p now: %s\n",
- client->client_handle,
- client->pending_head == NULL
- ? "no more messages"
- : "request already pending");
+ "Not asking for transmission to %p now: %s\n",
+ client->client_handle,
+ client->pending_head ==
+ NULL ? "no more messages" : "request already pending");
#endif
return;
}
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking for transmission of %u bytes to client %p\n",
- ntohs (client->pending_head->
- msg->size),
- client->client_handle);
+ "Asking for transmission of %u bytes to client %p\n",
+ ntohs (client->pending_head->msg->size), client->client_handle);
#endif
client->transmit_handle =
GNUNET_SERVER_notify_transmit_ready (client->client_handle,
@@ -716,7 +683,7 @@ add_pending_message (struct ClientList *client,
struct PendingMessage *pending_message)
{
GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, client->pending_tail,
- pending_message);
+ pending_message);
process_pending_messages (client);
}
@@ -728,7 +695,7 @@ struct ForwardReplyContext
{
/**
- * Actual message to send to matching clients.
+ * Actual message to send to matching clients.
*/
struct PendingMessage *pm;
@@ -777,51 +744,43 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
int do_free;
GNUNET_HashCode ch;
unsigned int i;
-
- if ( (record->type != GNUNET_BLOCK_TYPE_ANY) &&
- (record->type != frc->type) )
+
+ if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type))
+ {
+#if DEBUG_DHT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Record type missmatch, not passing request for key %s to local client\n",
+ GNUNET_h2s (key));
+#endif
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop
+ ("# Key match, type mismatches in REPLY to CLIENT"),
+ 1, GNUNET_NO);
+ return GNUNET_YES; /* type mismatch */
+ }
+ GNUNET_CRYPTO_hash (frc->data, frc->data_size, &ch);
+ for (i = 0; i < record->seen_replies_count; i++)
+ if (0 == memcmp (&record->seen_replies[i], &ch, sizeof (GNUNET_HashCode)))
{
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Record type missmatch, not passing request for key %s to local client\n",
- GNUNET_h2s (key));
+ "Duplicate reply, not passing request for key %s to local client\n",
+ GNUNET_h2s (key));
#endif
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Key match, type mismatches in REPLY to CLIENT"), 1,
- GNUNET_NO);
- return GNUNET_YES; /* type mismatch */
+ gettext_noop
+ ("# Duplicate REPLIES to CLIENT request dropped"),
+ 1, GNUNET_NO);
+ return GNUNET_YES; /* duplicate */
}
- GNUNET_CRYPTO_hash (frc->data,
- frc->data_size,
- &ch);
- for (i=0;i<record->seen_replies_count;i++)
- if (0 == memcmp (&record->seen_replies[i],
- &ch,
- sizeof (GNUNET_HashCode)))
- {
-#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Duplicate reply, not passing request for key %s to local client\n",
- GNUNET_h2s (key));
-#endif
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Duplicate REPLIES to CLIENT request dropped"), 1,
- GNUNET_NO);
- return GNUNET_YES; /* duplicate */
- }
eval =
- GNUNET_BLOCK_evaluate (GDS_block_context,
- record->type, key,
- NULL, 0,
- record->xquery,
- record->xquery_size,
- frc->data,
- frc->data_size);
+ GNUNET_BLOCK_evaluate (GDS_block_context, record->type, key, NULL, 0,
+ record->xquery, record->xquery_size, frc->data,
+ frc->data_size);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Evaluation result is %d for key %s for local client's query\n",
- (int) eval,
- GNUNET_h2s (key));
+ "Evaluation result is %d for key %s for local client's query\n",
+ (int) eval, GNUNET_h2s (key));
#endif
switch (eval)
{
@@ -829,9 +788,7 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
do_free = GNUNET_YES;
break;
case GNUNET_BLOCK_EVALUATION_OK_MORE:
- GNUNET_array_append (record->seen_replies,
- record->seen_replies_count,
- ch);
+ GNUNET_array_append (record->seen_replies, record->seen_replies_count, ch);
do_free = GNUNET_NO;
break;
case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
@@ -849,38 +806,36 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
return GNUNET_NO;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Unsupported block type (%u) in request!\n"),
- record->type);
+ _("Unsupported block type (%u) in request!\n"), record->type);
return GNUNET_NO;
default:
GNUNET_break (0);
return GNUNET_NO;
}
if (GNUNET_NO == frc->do_copy)
- {
- /* first time, we can use the original data */
- pm = frc->pm;
- frc->do_copy = GNUNET_YES;
- }
+ {
+ /* first time, we can use the original data */
+ pm = frc->pm;
+ frc->do_copy = GNUNET_YES;
+ }
else
- {
- /* two clients waiting for same reply, must copy for queueing */
- pm = GNUNET_malloc (sizeof (struct PendingMessage) +
- ntohs (frc->pm->msg->size));
- memcpy (pm, frc->pm,
- sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
- pm->next = pm->prev = NULL;
- }
+ {
+ /* two clients waiting for same reply, must copy for queueing */
+ pm = GNUNET_malloc (sizeof (struct PendingMessage) +
+ ntohs (frc->pm->msg->size));
+ memcpy (pm, frc->pm,
+ sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
+ pm->next = pm->prev = NULL;
+ }
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# RESULTS queued for clients"), 1,
GNUNET_NO);
- reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1];
+ reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
reply->unique_id = record->unique_id;
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queueing reply to query %s for client %p\n",
- GNUNET_h2s (key),
- record->client->client_handle);
+ "Queueing reply to query %s for client %p\n", GNUNET_h2s (key),
+ record->client->client_handle);
#endif
add_pending_message (record->client, pm);
if (GNUNET_YES == do_free)
@@ -906,14 +861,13 @@ forward_reply (void *cls, const GNUNET_HashCode * key, void *value)
*/
void
GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
- const GNUNET_HashCode *key,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- enum GNUNET_BLOCK_Type type,
- size_t data_size,
- const void *data)
+ const GNUNET_HashCode * key,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ enum GNUNET_BLOCK_Type type, size_t data_size,
+ const void *data)
{
struct ForwardReplyContext frc;
struct PendingMessage *pm;
@@ -921,57 +875,57 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
struct GNUNET_PeerIdentity *paths;
size_t msize;
- if (NULL ==
- GNUNET_CONTAINER_multihashmap_get (forward_map, key))
+ if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key))
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# REPLIES ignored for CLIENTS (no match)"), 1,
- GNUNET_NO);
- return; /* no matching request, fast exit! */
+ gettext_noop
+ ("# REPLIES ignored for CLIENTS (no match)"), 1,
+ GNUNET_NO);
+ return; /* no matching request, fast exit! */
}
- msize = sizeof(struct GNUNET_DHT_ClientResultMessage) + data_size +
- (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
+ msize =
+ sizeof (struct GNUNET_DHT_ClientResultMessage) + data_size +
+ (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Could not pass reply to client, message too big!\n"));
- return;
- }
- pm = (struct PendingMessage *) GNUNET_malloc (msize + sizeof (struct PendingMessage));
- reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1];
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Could not pass reply to client, message too big!\n"));
+ return;
+ }
+ pm = (struct PendingMessage *) GNUNET_malloc (msize +
+ sizeof (struct PendingMessage));
+ reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
pm->msg = &reply->header;
reply->header.size = htons ((uint16_t) msize);
reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT);
reply->type = htonl (type);
reply->get_path_length = htonl (get_path_length);
reply->put_path_length = htonl (put_path_length);
- reply->unique_id = 0; /* filled in later */
+ reply->unique_id = 0; /* filled in later */
reply->expiration = GNUNET_TIME_absolute_hton (expiration);
reply->key = *key;
- paths = (struct GNUNET_PeerIdentity*) &reply[1];
- memcpy (paths, put_path,
- sizeof (struct GNUNET_PeerIdentity) * put_path_length);
- memcpy (&paths[put_path_length],
- get_path, sizeof (struct GNUNET_PeerIdentity) * get_path_length);
- memcpy (&paths[get_path_length + put_path_length],
- data,
- data_size);
+ paths = (struct GNUNET_PeerIdentity *) &reply[1];
+ memcpy (paths, put_path,
+ sizeof (struct GNUNET_PeerIdentity) * put_path_length);
+ memcpy (&paths[put_path_length], get_path,
+ sizeof (struct GNUNET_PeerIdentity) * get_path_length);
+ memcpy (&paths[get_path_length + put_path_length], data, data_size);
frc.do_copy = GNUNET_NO;
frc.pm = pm;
frc.data = data;
frc.data_size = data_size;
frc.type = type;
- GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key,
- &forward_reply,
- &frc);
+ GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply,
+ &frc);
if (GNUNET_NO == frc.do_copy)
- {
- /* did not match any of the requests, free! */
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# REPLIES ignored for CLIENTS (no match)"), 1,
- GNUNET_NO);
- GNUNET_free (pm);
- }
+ {
+ /* did not match any of the requests, free! */
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop
+ ("# REPLIES ignored for CLIENTS (no match)"), 1,
+ GNUNET_NO);
+ GNUNET_free (pm);
+ }
}
@@ -980,17 +934,17 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
*
* @param server the initialized server
*/
-void
+void
GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
{
static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
- {&handle_dht_local_put, NULL,
+ {&handle_dht_local_put, NULL,
GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT, 0},
- {&handle_dht_local_get, NULL,
+ {&handle_dht_local_get, NULL,
GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET, 0},
{&handle_dht_local_get_stop, NULL,
- GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP,
- sizeof (struct GNUNET_DHT_ClientGetStopMessage) },
+ GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP,
+ sizeof (struct GNUNET_DHT_ClientGetStopMessage)},
{NULL, NULL, 0, 0}
};
forward_map = GNUNET_CONTAINER_multihashmap_create (1024);
@@ -1009,10 +963,10 @@ GDS_CLIENTS_done ()
GNUNET_assert (client_head == NULL);
GNUNET_assert (client_tail == NULL);
if (GNUNET_SCHEDULER_NO_TASK != retry_task)
- {
- GNUNET_SCHEDULER_cancel (retry_task);
- retry_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ {
+ GNUNET_SCHEDULER_cancel (retry_task);
+ retry_task = GNUNET_SCHEDULER_NO_TASK;
+ }
GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (retry_heap));
GNUNET_CONTAINER_heap_destroy (retry_heap);
retry_heap = NULL;
@@ -1022,4 +976,3 @@ GDS_CLIENTS_done ()
}
/* end of gnunet-service-dht_clients.c */
-
diff --git a/src/dht/gnunet-service-dht_clients.h b/src/dht/gnunet-service-dht_clients.h
index 66fa433c0..21b2343e7 100644
--- a/src/dht/gnunet-service-dht_clients.h
+++ b/src/dht/gnunet-service-dht_clients.h
@@ -47,14 +47,13 @@
*/
void
GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
- const GNUNET_HashCode *key,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- enum GNUNET_BLOCK_Type type,
- size_t data_size,
- const void *data);
+ const GNUNET_HashCode * key,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ enum GNUNET_BLOCK_Type type, size_t data_size,
+ const void *data);
/**
@@ -62,7 +61,7 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
*
* @param server the initialized server
*/
-void
+void
GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server);
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c
index f3b2e5b2f..82cd06727 100644
--- a/src/dht/gnunet-service-dht_datacache.c
+++ b/src/dht/gnunet-service-dht_datacache.c
@@ -74,44 +74,42 @@ struct DHTPutEntry
*/
void
GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- enum GNUNET_BLOCK_Type type,
- size_t data_size,
- const void *data)
+ const GNUNET_HashCode * key,
+ unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ enum GNUNET_BLOCK_Type type, size_t data_size,
+ const void *data)
{
- size_t plen = data_size + put_path_length * sizeof(struct GNUNET_PeerIdentity) + sizeof(struct DHTPutEntry);
+ size_t plen =
+ data_size + put_path_length * sizeof (struct GNUNET_PeerIdentity) +
+ sizeof (struct DHTPutEntry);
char buf[plen];
struct DHTPutEntry *pe;
struct GNUNET_PeerIdentity *pp;
if (datacache == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("%s request received, but have no datacache!\n"),
- "PUT");
- return;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("%s request received, but have no datacache!\n"), "PUT");
+ return;
+ }
if (data_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
- {
- GNUNET_break (0);
- return;
- }
+ {
+ GNUNET_break (0);
+ return;
+ }
/* Put size is actual data size plus struct overhead plus path length (if any) */
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# ITEMS stored in datacache"), 1,
- GNUNET_NO);
+ gettext_noop ("# ITEMS stored in datacache"), 1,
+ GNUNET_NO);
pe = (struct DHTPutEntry *) buf;
pe->data_size = htons (data_size);
pe->path_length = htons ((uint16_t) put_path_length);
pp = (struct GNUNET_PeerIdentity *) &pe[1];
memcpy (pp, put_path, put_path_length * sizeof (struct GNUNET_PeerIdentity));
- memcpy (&pp[put_path_length],
- data, data_size);
- (void) GNUNET_DATACACHE_put (datacache, key,
- plen, (const char *) pe, type,
- expiration);
+ memcpy (&pp[put_path_length], data, data_size);
+ (void) GNUNET_DATACACHE_put (datacache, key, plen, (const char *) pe, type,
+ expiration);
}
@@ -190,20 +188,15 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
return GNUNET_OK;
}
pp = (const struct GNUNET_PeerIdentity *) &pe[1];
- rdata = (const char*) &pp[put_path_length];
+ rdata = (const char *) &pp[put_path_length];
eval =
- GNUNET_BLOCK_evaluate (GDS_block_context, type, key,
- ctx->reply_bf,
- ctx->reply_bf_mutator,
- ctx->xquery,
- ctx->xquery_size,
- rdata,
- rdata_size);
+ GNUNET_BLOCK_evaluate (GDS_block_context, type, key, ctx->reply_bf,
+ ctx->reply_bf_mutator, ctx->xquery,
+ ctx->xquery_size, rdata, rdata_size);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Found reply for query %s in datacache, evaluation result is %d\n",
- GNUNET_h2s (key),
- (int) eval);
+ "Found reply for query %s in datacache, evaluation result is %d\n",
+ GNUNET_h2s (key), (int) eval);
#endif
ctx->eval = eval;
switch (eval)
@@ -212,27 +205,26 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
case GNUNET_BLOCK_EVALUATION_OK_MORE:
/* forward to local clients */
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Good RESULTS found in datacache"), 1,
- GNUNET_NO);
- GDS_CLIENTS_handle_reply (exp,
- key,
- 0, NULL,
- put_path_length, pp,
- type, rdata_size, rdata);
+ gettext_noop
+ ("# Good RESULTS found in datacache"), 1,
+ GNUNET_NO);
+ GDS_CLIENTS_handle_reply (exp, key, 0, NULL, put_path_length, pp, type,
+ rdata_size, rdata);
/* forward to other peers */
- GDS_ROUTING_process (type, exp,
- key, put_path_length, pp,
- 0, NULL, rdata, rdata_size);
+ GDS_ROUTING_process (type, exp, key, put_path_length, pp, 0, NULL, rdata,
+ rdata_size);
break;
case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Duplicate RESULTS found in datacache"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Duplicate RESULTS found in datacache"), 1,
+ GNUNET_NO);
break;
case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Invalid RESULTS found in datacache"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Invalid RESULTS found in datacache"), 1,
+ GNUNET_NO);
break;
case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
GNUNET_break (0);
@@ -242,11 +234,11 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
return GNUNET_SYSERR;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Unsupported RESULTS found in datacache"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Unsupported RESULTS found in datacache"), 1,
+ GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Unsupported block type (%u) in local response!\n"),
- type);
+ _("Unsupported block type (%u) in local response!\n"), type);
break;
}
return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK;
@@ -256,7 +248,7 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
/**
* Handle a GET request we've received from another peer.
*
- * @param key the query
+ * @param key the query
* @param type requested data type
* @param xquery extended query
* @param xquery_size number of bytes in xquery
@@ -265,28 +257,27 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
* @return evaluation result for the local replies
*/
enum GNUNET_BLOCK_EvaluationResult
-GDS_DATACACHE_handle_get (const GNUNET_HashCode *key,
- enum GNUNET_BLOCK_Type type,
- const void *xquery,
- size_t xquery_size,
- struct GNUNET_CONTAINER_BloomFilter **reply_bf,
- uint32_t reply_bf_mutator)
+GDS_DATACACHE_handle_get (const GNUNET_HashCode * key,
+ enum GNUNET_BLOCK_Type type, const void *xquery,
+ size_t xquery_size,
+ struct GNUNET_CONTAINER_BloomFilter **reply_bf,
+ uint32_t reply_bf_mutator)
{
struct GetRequestContext ctx;
if (datacache == NULL)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# GET requests given to datacache"), 1,
- GNUNET_NO);
+ gettext_noop ("# GET requests given to datacache"),
+ 1, GNUNET_NO);
ctx.eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
ctx.key = *key;
ctx.xquery = xquery;
ctx.xquery_size = xquery_size;
ctx.reply_bf = reply_bf;
ctx.reply_bf_mutator = reply_bf_mutator;
- (void) GNUNET_DATACACHE_get (datacache, key, type,
- &datacache_get_iterator, &ctx);
+ (void) GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator,
+ &ctx);
return ctx.eval;
}
@@ -294,7 +285,7 @@ GDS_DATACACHE_handle_get (const GNUNET_HashCode *key,
/**
* Initialize datacache subsystem.
*/
-void
+void
GDS_DATACACHE_init ()
{
datacache = GNUNET_DATACACHE_create (GDS_cfg, "dhtcache");
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h
index ccd854570..926ad5326 100644
--- a/src/dht/gnunet-service-dht_datacache.h
+++ b/src/dht/gnunet-service-dht_datacache.h
@@ -44,18 +44,17 @@
*/
void
GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- enum GNUNET_BLOCK_Type type,
- size_t data_size,
- const void *data);
+ const GNUNET_HashCode * key,
+ unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ enum GNUNET_BLOCK_Type type, size_t data_size,
+ const void *data);
/**
* Handle a GET request we've received from another peer.
*
- * @param key the query
+ * @param key the query
* @param type requested data type
* @param xquery extended query
* @param xquery_size number of bytes in xquery
@@ -63,19 +62,18 @@ GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
* @param reply_bf_mutator mutation value for reply_bf
* @return evaluation result for the local replies
*/
-enum GNUNET_BLOCK_EvaluationResult
-GDS_DATACACHE_handle_get (const GNUNET_HashCode *key,
- enum GNUNET_BLOCK_Type type,
- const void *xquery,
- size_t xquery_size,
- struct GNUNET_CONTAINER_BloomFilter **reply_bf,
- uint32_t reply_bf_mutator);
+enum GNUNET_BLOCK_EvaluationResult
+GDS_DATACACHE_handle_get (const GNUNET_HashCode * key,
+ enum GNUNET_BLOCK_Type type, const void *xquery,
+ size_t xquery_size,
+ struct GNUNET_CONTAINER_BloomFilter **reply_bf,
+ uint32_t reply_bf_mutator);
/**
* Initialize datacache subsystem.
*/
-void
+void
GDS_DATACACHE_init (void);
diff --git a/src/dht/gnunet-service-dht_hello.c b/src/dht/gnunet-service-dht_hello.c
index 5be0cbfec..578e651f8 100644
--- a/src/dht/gnunet-service-dht_hello.c
+++ b/src/dht/gnunet-service-dht_hello.c
@@ -54,8 +54,7 @@ GDS_HELLO_get (const struct GNUNET_PeerIdentity *peer)
{
if (NULL == peer_to_hello)
return NULL;
- return GNUNET_CONTAINER_multihashmap_get (peer_to_hello,
- &peer->hashPubKey);
+ return GNUNET_CONTAINER_multihashmap_get (peer_to_hello, &peer->hashPubKey);
}
@@ -68,11 +67,8 @@ GDS_HELLO_get (const struct GNUNET_PeerIdentity *peer)
* @param error message
*/
static void
-process_hello (void *cls,
- const struct GNUNET_PeerIdentity *
- peer,
- const struct GNUNET_HELLO_Message *
- hello, const char *err_msg)
+process_hello (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_HELLO_Message *hello, const char *err_msg)
{
struct GNUNET_TIME_Absolute ex;
struct GNUNET_HELLO_Message *hm;
@@ -83,18 +79,16 @@ process_hello (void *cls,
if (GNUNET_TIME_absolute_get_remaining (ex).rel_value == 0)
return;
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# HELLOs obtained from peerinfo"), 1,
- GNUNET_NO);
- hm = GNUNET_CONTAINER_multihashmap_get (peer_to_hello,
- &peer->hashPubKey);
+ gettext_noop ("# HELLOs obtained from peerinfo"), 1,
+ GNUNET_NO);
+ hm = GNUNET_CONTAINER_multihashmap_get (peer_to_hello, &peer->hashPubKey);
GNUNET_free_non_null (hm);
hm = GNUNET_malloc (GNUNET_HELLO_size (hello));
memcpy (hm, hello, GNUNET_HELLO_size (hello));
GNUNET_assert (GNUNET_SYSERR !=
- GNUNET_CONTAINER_multihashmap_put (peer_to_hello,
- &peer->hashPubKey,
- hm,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE));
+ GNUNET_CONTAINER_multihashmap_put (peer_to_hello,
+ &peer->hashPubKey, hm,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE));
}
@@ -104,9 +98,7 @@ process_hello (void *cls,
void
GDS_HELLO_init ()
{
- pnc = GNUNET_PEERINFO_notify (GDS_cfg,
- &process_hello,
- NULL);
+ pnc = GNUNET_PEERINFO_notify (GDS_cfg, &process_hello, NULL);
peer_to_hello = GNUNET_CONTAINER_multihashmap_create (256);
}
@@ -115,9 +107,7 @@ GDS_HELLO_init ()
* Free memory occopied by the HELLO.
*/
static int
-free_hello (void *cls,
- const GNUNET_HashCode *key,
- void *hello)
+free_hello (void *cls, const GNUNET_HashCode * key, void *hello)
{
GNUNET_free (hello);
return GNUNET_OK;
@@ -137,9 +127,7 @@ GDS_HELLO_done ()
}
if (NULL != peer_to_hello)
{
- GNUNET_CONTAINER_multihashmap_iterate (peer_to_hello,
- &free_hello,
- NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (peer_to_hello, &free_hello, NULL);
GNUNET_CONTAINER_multihashmap_destroy (peer_to_hello);
}
}
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 02124b488..9ebf16400 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -275,7 +275,7 @@ struct P2PPendingMessage
/**
* Actual message to be sent, allocated at the end of the struct:
- * // msg = (cast) &pm[1];
+ * // msg = (cast) &pm[1];
* // memcpy (&pm[1], data, len);
*/
const struct GNUNET_MessageHeader *msg;
@@ -399,7 +399,7 @@ static GNUNET_SCHEDULER_TaskIdentifier find_peer_task;
/**
* Identity of this peer.
- */
+ */
static struct GNUNET_PeerIdentity my_identity;
/**
@@ -428,11 +428,11 @@ find_bucket (const GNUNET_HashCode * hc)
bits = GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey, hc);
if (bits == MAX_BUCKETS)
- {
- /* How can all bits match? Got my own ID? */
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ {
+ /* How can all bits match? Got my own ID? */
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
return MAX_BUCKETS - bits - 1;
}
@@ -442,7 +442,7 @@ find_bucket (const GNUNET_HashCode * hc)
*
* @param cls the 'struct PeerInfo' of the peer
* @param tc scheduler context.
- */
+ */
static void
update_core_preference (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -454,10 +454,10 @@ update_core_preference (void *cls,
peer->preference_task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
- return;
+ return;
matching =
- GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey,
- &peer->id.hashPubKey);
+ GNUNET_CRYPTO_hash_matching_bits (&my_identity.hashPubKey,
+ &peer->id.hashPubKey);
if (matching >= 64)
matching = 63;
bucket = find_bucket (&peer->id.hashPubKey);
@@ -469,22 +469,21 @@ update_core_preference (void *cls,
preference = (1LL << matching) / k_buckets[bucket].peers_size;
}
if (preference == 0)
- {
- peer->preference_task
- = GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
- &update_core_preference, peer);
- return;
- }
+ {
+ peer->preference_task =
+ GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
+ &update_core_preference, peer);
+ return;
+ }
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Preference updates given to core"), 1,
- GNUNET_NO);
+ gettext_noop ("# Preference updates given to core"),
+ 1, GNUNET_NO);
GNUNET_ATS_change_preference (atsAPI, &peer->id,
- GNUNET_ATS_PREFERENCE_BANDWIDTH,
- (double) preference,
- GNUNET_ATS_PREFERENCE_END);
- peer->preference_task
- = GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
- &update_core_preference, peer);
+ GNUNET_ATS_PREFERENCE_BANDWIDTH,
+ (double) preference, GNUNET_ATS_PREFERENCE_END);
+ peer->preference_task =
+ GNUNET_SCHEDULER_add_delayed (DHT_DEFAULT_PREFERENCE_INTERVAL,
+ &update_core_preference, peer);
}
@@ -525,9 +524,8 @@ add_known_to_bloom (void *cls, const GNUNET_HashCode * key, void *value)
GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
- GNUNET_h2s (key),
- ctx->bf_mutator);
+ "Adding known peer (%s) to bloomfilter for FIND PEER with mutation %u\n",
+ GNUNET_h2s (key), ctx->bf_mutator);
#endif
GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
return GNUNET_YES;
@@ -553,46 +551,46 @@ send_find_peer_message (void *cls,
find_peer_task = GNUNET_SCHEDULER_NO_TASK;
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
- if (newly_found_peers > bucket_size)
+ if (newly_found_peers > bucket_size)
{
/* If we are finding many peers already, no need to send out our request right now! */
- find_peer_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
- &send_find_peer_message, NULL);
+ find_peer_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ &send_find_peer_message, NULL);
newly_found_peers = 0;
return;
}
- bcc.bf_mutator = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
+ bcc.bf_mutator =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
bcc.bloom =
- GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, GNUNET_CONSTANTS_BLOOMFILTER_K);
- GNUNET_CONTAINER_multihashmap_iterate (all_known_peers,
- &add_known_to_bloom,
+ GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_CONTAINER_multihashmap_iterate (all_known_peers, &add_known_to_bloom,
&bcc);
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# FIND PEER messages initiated"), 1,
- GNUNET_NO);
- peer_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
- DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
+ gettext_noop ("# FIND PEER messages initiated"), 1,
+ GNUNET_NO);
+ peer_bf =
+ GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
// FIXME: pass priority!?
GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
- GNUNET_DHT_RO_FIND_PEER,
- FIND_PEER_REPLICATION_LEVEL,
- 0,
- &my_identity.hashPubKey,
- NULL, 0,
- bcc.bloom, bcc.bf_mutator,
- peer_bf);
+ GNUNET_DHT_RO_FIND_PEER,
+ FIND_PEER_REPLICATION_LEVEL, 0,
+ &my_identity.hashPubKey, NULL, 0, bcc.bloom,
+ bcc.bf_mutator, peer_bf);
GNUNET_CONTAINER_bloomfilter_free (peer_bf);
GNUNET_CONTAINER_bloomfilter_free (bcc.bloom);
/* schedule next round */
next_send_time.rel_value =
- DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
- GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / (newly_found_peers+1));
+ DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value +
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value /
+ (newly_found_peers + 1));
newly_found_peers = 0;
- find_peer_task = GNUNET_SCHEDULER_add_delayed (next_send_time,
- &send_find_peer_message,
- NULL);
+ find_peer_task =
+ GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message,
+ NULL);
}
@@ -607,7 +605,7 @@ send_find_peer_message (void *cls,
static void
handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct PeerInfo *ret;
int peer_bucket;
@@ -616,10 +614,8 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connected %s to %s\n",
- GNUNET_i2s (&my_identity),
- GNUNET_h2s (&peer->hashPubKey));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected %s to %s\n",
+ GNUNET_i2s (&my_identity), GNUNET_h2s (&peer->hashPubKey));
#endif
if (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_contains (all_known_peers,
@@ -628,11 +624,10 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_break (0);
return;
}
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers connected"), 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# Peers connected"), 1,
+ GNUNET_NO);
peer_bucket = find_bucket (&peer->hashPubKey);
- GNUNET_assert ( (peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS) );
+ GNUNET_assert ((peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS));
ret = GNUNET_malloc (sizeof (struct PeerInfo));
#if 0
ret->latency = latency;
@@ -640,25 +635,23 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
#endif
ret->id = *peer;
GNUNET_CONTAINER_DLL_insert_tail (k_buckets[peer_bucket].head,
- k_buckets[peer_bucket].tail, ret);
+ k_buckets[peer_bucket].tail, ret);
k_buckets[peer_bucket].peers_size++;
- closest_bucket = GNUNET_MAX (closest_bucket,
- peer_bucket);
- if ( (peer_bucket > 0) &&
- (k_buckets[peer_bucket].peers_size <= bucket_size) )
+ closest_bucket = GNUNET_MAX (closest_bucket, peer_bucket);
+ if ((peer_bucket > 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);
newly_found_peers++;
}
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (all_known_peers,
- &peer->hashPubKey, ret,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multihashmap_put (all_known_peers,
+ &peer->hashPubKey, ret,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
if (1 == GNUNET_CONTAINER_multihashmap_size (all_known_peers))
{
/* got a first connection, good time to start with FIND PEER requests... */
- find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message,
- NULL);
+ find_peer_task = GNUNET_SCHEDULER_add_now (&send_find_peer_message, NULL);
}
}
@@ -681,21 +674,18 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnected %s from %s\n",
- GNUNET_i2s (&my_identity),
- GNUNET_h2s (&peer->hashPubKey));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnected %s from %s\n",
+ GNUNET_i2s (&my_identity), GNUNET_h2s (&peer->hashPubKey));
#endif
to_remove =
GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey);
if (NULL == to_remove)
- {
- GNUNET_break (0);
- return;
- }
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers connected"), -1,
- GNUNET_NO);
+ {
+ GNUNET_break (0);
+ return;
+ }
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# Peers connected"), -1,
+ GNUNET_NO);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (all_known_peers,
&peer->hashPubKey,
@@ -708,15 +698,13 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
current_bucket = find_bucket (&to_remove->id.hashPubKey);
GNUNET_assert (current_bucket >= 0);
GNUNET_CONTAINER_DLL_remove (k_buckets[current_bucket].head,
- k_buckets[current_bucket].tail,
- to_remove);
+ k_buckets[current_bucket].tail, to_remove);
GNUNET_assert (k_buckets[current_bucket].peers_size > 0);
k_buckets[current_bucket].peers_size--;
- while ( (closest_bucket > 0) &&
- (k_buckets[closest_bucket].peers_size == 0) )
+ while ((closest_bucket > 0) && (k_buckets[closest_bucket].peers_size == 0))
closest_bucket--;
- if (to_remove->th != NULL)
+ if (to_remove->th != NULL)
{
GNUNET_CORE_notify_transmit_ready_cancel (to_remove->th);
to_remove->th = NULL;
@@ -724,15 +712,14 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
discarded = 0;
while (NULL != (pos = to_remove->head))
{
- GNUNET_CONTAINER_DLL_remove (to_remove->head,
- to_remove->tail,
- pos);
+ GNUNET_CONTAINER_DLL_remove (to_remove->head, to_remove->tail, pos);
discarded++;
GNUNET_free (pos);
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Queued messages discarded (peer disconnected)"), discarded,
- GNUNET_NO);
+ gettext_noop
+ ("# Queued messages discarded (peer disconnected)"),
+ discarded, GNUNET_NO);
GNUNET_free (to_remove);
}
@@ -756,8 +743,8 @@ core_transmit_notify (void *cls, size_t size, void *buf)
size_t msize;
peer->th = NULL;
- while ( (NULL != (pending = peer->head)) &&
- (GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value == 0) )
+ while ((NULL != (pending = peer->head)) &&
+ (GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value == 0))
{
peer->pending_count--;
GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
@@ -770,22 +757,24 @@ core_transmit_notify (void *cls, size_t size, void *buf)
}
if (buf == NULL)
{
- peer->th
- = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
- pending->importance,
- GNUNET_TIME_absolute_get_remaining (pending->timeout),
- &peer->id, ntohs (pending->msg->size),
- &core_transmit_notify, peer);
+ peer->th =
+ GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining
+ (pending->timeout), &peer->id,
+ ntohs (pending->msg->size),
+ &core_transmit_notify, peer);
GNUNET_break (NULL != peer->th);
return 0;
}
off = 0;
- while ( (NULL != (pending = peer->head)) &&
- (size - off >= (msize = ntohs (pending->msg->size))) )
+ while ((NULL != (pending = peer->head)) &&
+ (size - off >= (msize = ntohs (pending->msg->size))))
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Bytes transmitted to other peers"), msize,
- GNUNET_NO);
+ gettext_noop
+ ("# Bytes transmitted to other peers"), msize,
+ GNUNET_NO);
memcpy (&cbuf[off], pending->msg, msize);
off += msize;
peer->pending_count--;
@@ -794,12 +783,12 @@ core_transmit_notify (void *cls, size_t size, void *buf)
}
if (peer->head != NULL)
{
- peer->th
- = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
- pending->importance,
- GNUNET_TIME_absolute_get_remaining (pending->timeout),
- &peer->id, msize,
- &core_transmit_notify, peer);
+ peer->th =
+ GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining
+ (pending->timeout), &peer->id, msize,
+ &core_transmit_notify, peer);
GNUNET_break (NULL != peer->th);
}
return off;
@@ -821,16 +810,16 @@ process_peer_queue (struct PeerInfo *peer)
if (NULL != peer->th)
return;
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Bytes of bandwdith requested from core"),
- ntohs (pending->msg->size),
- GNUNET_NO);
- peer->th
- = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
- pending->importance,
- GNUNET_TIME_absolute_get_remaining (pending->timeout),
- &peer->id,
- ntohs (pending->msg->size),
- &core_transmit_notify, peer);
+ gettext_noop
+ ("# Bytes of bandwdith requested from core"),
+ ntohs (pending->msg->size), GNUNET_NO);
+ peer->th =
+ GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining
+ (pending->timeout), &peer->id,
+ ntohs (pending->msg->size),
+ &core_transmit_notify, peer);
GNUNET_break (NULL != peer->th);
}
@@ -844,8 +833,7 @@ process_peer_queue (struct PeerInfo *peer)
* @return Some number of peers to forward the message to
*/
static unsigned int
-get_forward_count (uint32_t hop_count,
- uint32_t target_replication)
+get_forward_count (uint32_t hop_count, uint32_t target_replication)
{
uint32_t random_value;
uint32_t forward_count;
@@ -862,18 +850,18 @@ get_forward_count (uint32_t hop_count,
return 1;
}
/* bound by system-wide maximum */
- target_replication = GNUNET_MIN (MAXIMUM_REPLICATION_LEVEL,
- target_replication);
+ target_replication =
+ GNUNET_MIN (MAXIMUM_REPLICATION_LEVEL, target_replication);
target_value =
- 1 + (target_replication - 1.0) / (GDS_NSE_get () +
- ((float) (target_replication - 1.0) *
- hop_count));
+ 1 + (target_replication - 1.0) / (GDS_NSE_get () +
+ ((float) (target_replication - 1.0) *
+ hop_count));
/* Set forward count to floor of target_value */
forward_count = (uint32_t) 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_WEAK, UINT32_MAX);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
if (random_value < (target_value * UINT32_MAX))
forward_count++;
return forward_count;
@@ -950,7 +938,7 @@ get_distance (const GNUNET_HashCode * target, const GNUNET_HashCode * have)
* GNUNET_NO otherwise.
*/
static int
-am_closest_peer (const GNUNET_HashCode *key,
+am_closest_peer (const GNUNET_HashCode * key,
const struct GNUNET_CONTAINER_BloomFilter *bloom)
{
int bits;
@@ -978,7 +966,7 @@ am_closest_peer (const GNUNET_HashCode *key,
other_bits = GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, key);
if (other_bits > bits)
return GNUNET_NO;
- if (other_bits == bits) /* We match the same number of bits */
+ if (other_bits == bits) /* We match the same number of bits */
return GNUNET_YES;
pos = pos->next;
}
@@ -997,7 +985,7 @@ am_closest_peer (const GNUNET_HashCode *key,
* exponentially declining probability.
*
* FIXME: double-check that this is fine
- *
+ *
*
* @param key the key we are selecting a peer to route to
* @param bloom a bloomfilter containing entries this request has seen already
@@ -1005,9 +993,8 @@ am_closest_peer (const GNUNET_HashCode *key,
* @return Peer to route to, or NULL on error
*/
static struct PeerInfo *
-select_peer (const GNUNET_HashCode *key,
- const struct GNUNET_CONTAINER_BloomFilter *bloom,
- uint32_t hops)
+select_peer (const GNUNET_HashCode * key,
+ const struct GNUNET_CONTAINER_BloomFilter *bloom, uint32_t hops)
{
unsigned int bc;
unsigned int count;
@@ -1028,10 +1015,10 @@ select_peer (const GNUNET_HashCode *key,
count = 0;
while ((pos != NULL) && (count < bucket_size))
{
- if ( (bloom == NULL) ||
- (GNUNET_NO ==
- GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) )
- {
+ if ((bloom == NULL) ||
+ (GNUNET_NO ==
+ GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)))
+ {
dist = get_distance (key, &pos->id.hashPubKey);
if (dist < smallest_distance)
{
@@ -1040,25 +1027,25 @@ select_peer (const GNUNET_HashCode *key,
}
}
else
- {
+ {
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Excluded peer `%s' due to BF match in greedy routing for %s\n",
- GNUNET_i2s (&pos->id),
- GNUNET_h2s (key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Excluded peer `%s' due to BF match in greedy routing for %s\n",
+ GNUNET_i2s (&pos->id), GNUNET_h2s (key));
#endif
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
- GNUNET_NO);
- }
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop
+ ("# Peers excluded from routing due to Bloomfilter"),
+ 1, GNUNET_NO);
+ }
count++;
pos = pos->next;
}
}
if (NULL == chosen)
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peer selection failed"), 1,
- GNUNET_NO);
+ gettext_noop ("# Peer selection failed"), 1,
+ GNUNET_NO);
return chosen;
}
@@ -1070,18 +1057,18 @@ select_peer (const GNUNET_HashCode *key,
pos = k_buckets[bc].head;
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)))
{
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop
+ ("# Peers excluded from routing due to Bloomfilter"),
+ 1, GNUNET_NO);
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Excluded peer `%s' due to BF match in random routing for %s\n",
- GNUNET_i2s (&pos->id),
- GNUNET_h2s (key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Excluded peer `%s' due to BF match in random routing for %s\n",
+ GNUNET_i2s (&pos->id), GNUNET_h2s (key));
#endif
pos = pos->next;
continue; /* Ignore bloomfiltered peers */
@@ -1093,8 +1080,8 @@ select_peer (const GNUNET_HashCode *key,
if (count == 0) /* No peers to select from! */
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Peer selection failed"), 1,
- GNUNET_NO);
+ gettext_noop ("# Peer selection failed"), 1,
+ GNUNET_NO);
return NULL;
}
/* Now actually choose a peer */
@@ -1105,9 +1092,9 @@ select_peer (const GNUNET_HashCode *key,
pos = k_buckets[bc].head;
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; /* Ignore bloomfiltered peers */
@@ -1136,11 +1123,10 @@ select_peer (const GNUNET_HashCode *key,
* @return number of peers returned in 'targets'.
*/
static unsigned int
-get_target_peers (const GNUNET_HashCode *key,
- struct GNUNET_CONTAINER_BloomFilter *bloom,
- uint32_t hop_count,
- uint32_t target_replication,
- struct PeerInfo ***targets)
+get_target_peers (const GNUNET_HashCode * key,
+ struct GNUNET_CONTAINER_BloomFilter *bloom,
+ uint32_t hop_count, uint32_t target_replication,
+ struct PeerInfo ***targets)
{
unsigned int ret;
unsigned int off;
@@ -1154,25 +1140,23 @@ get_target_peers (const GNUNET_HashCode *key,
*targets = NULL;
return 0;
}
- rtargets = GNUNET_malloc (sizeof (struct PeerInfo*) * ret);
+ rtargets = GNUNET_malloc (sizeof (struct PeerInfo *) * ret);
for (off = 0; off < ret; off++)
{
nxt = select_peer (key, bloom, hop_count);
if (nxt == NULL)
- break;
+ break;
rtargets[off] = nxt;
GNUNET_break (GNUNET_NO ==
- GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey));
+ GNUNET_CONTAINER_bloomfilter_test (bloom,
+ &nxt->id.hashPubKey));
GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[off]->id.hashPubKey);
}
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Selected %u/%u peers at hop %u for %s (target was %u)\n",
- off,
- GNUNET_CONTAINER_multihashmap_size (all_known_peers),
- (unsigned int) hop_count,
- GNUNET_h2s (key),
- ret);
+ "Selected %u/%u peers at hop %u for %s (target was %u)\n", off,
+ GNUNET_CONTAINER_multihashmap_size (all_known_peers),
+ (unsigned int) hop_count, GNUNET_h2s (key), ret);
#endif
if (0 == off)
{
@@ -1206,16 +1190,15 @@ get_target_peers (const GNUNET_HashCode *key,
*/
void
GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- struct GNUNET_TIME_Absolute expiration_time,
- uint32_t hop_count,
- struct GNUNET_CONTAINER_BloomFilter *bf,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- struct GNUNET_PeerIdentity *put_path,
- const void *data,
- size_t data_size)
+ enum GNUNET_DHT_RouteOption options,
+ uint32_t desired_replication_level,
+ struct GNUNET_TIME_Absolute expiration_time,
+ uint32_t hop_count,
+ struct GNUNET_CONTAINER_BloomFilter *bf,
+ const GNUNET_HashCode * key,
+ unsigned int put_path_length,
+ struct GNUNET_PeerIdentity *put_path,
+ const void *data, size_t data_size)
{
unsigned int target_count;
unsigned int i;
@@ -1225,33 +1208,32 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
size_t msize;
struct PeerPutMessage *ppm;
struct GNUNET_PeerIdentity *pp;
-
+
GNUNET_assert (NULL != bf);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding myself (%s) to PUT bloomfilter for %s\n",
- GNUNET_i2s (&my_identity),
- GNUNET_h2s (key));
+ "Adding myself (%s) to PUT bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity), GNUNET_h2s (key));
#endif
GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# PUT requests routed"), 1,
- GNUNET_NO);
- target_count = get_target_peers (key, bf, hop_count,
- desired_replication_level,
- &targets);
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# PUT requests routed"),
+ 1, GNUNET_NO);
+ target_count =
+ get_target_peers (key, bf, hop_count, desired_replication_level,
+ &targets);
if (0 == target_count)
- {
+ {
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Routing PUT for %s terminates after %u hops at %s\n",
- GNUNET_h2s (key),
- (unsigned int) hop_count,
- GNUNET_i2s (&my_identity));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Routing PUT for %s terminates after %u hops at %s\n",
+ GNUNET_h2s (key), (unsigned int) hop_count,
+ GNUNET_i2s (&my_identity));
#endif
- return;
- }
- msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage);
+ return;
+ }
+ msize =
+ put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size +
+ sizeof (struct PeerPutMessage);
if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
put_path_length = 0;
@@ -1264,22 +1246,21 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# PUT messages queued for transmission"), target_count,
- GNUNET_NO);
- for (i=0;i<target_count;i++)
+ gettext_noop
+ ("# PUT messages queued for transmission"),
+ target_count, GNUNET_NO);
+ for (i = 0; i < target_count; i++)
{
target = targets[i];
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Routing PUT for %s after %u hops to %s\n",
- GNUNET_h2s (key),
- (unsigned int) hop_count,
- GNUNET_i2s (&target->id));
+ "Routing PUT for %s after %u hops to %s\n", GNUNET_h2s (key),
+ (unsigned int) hop_count, GNUNET_i2s (&target->id));
#endif
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
- pending->importance = 0; /* FIXME */
- pending->timeout = expiration_time;
- ppm = (struct PeerPutMessage*) &pending[1];
+ pending->importance = 0; /* FIXME */
+ pending->timeout = expiration_time;
+ ppm = (struct PeerPutMessage *) &pending[1];
pending->msg = &ppm->header;
ppm->header.size = htons (msize);
ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT);
@@ -1289,18 +1270,19 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
ppm->desired_replication_level = htonl (desired_replication_level);
ppm->put_path_length = htonl (put_path_length);
ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
- GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &target->id.hashPubKey));
+ GNUNET_break (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (bf,
+ &target->id.hashPubKey));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
- ppm->bloomfilter,
- DHT_BLOOM_SIZE));
+ GNUNET_CONTAINER_bloomfilter_get_raw_data (bf,
+ ppm->bloomfilter,
+ DHT_BLOOM_SIZE));
ppm->key = *key;
- pp = (struct GNUNET_PeerIdentity*) &ppm[1];
- memcpy (pp, put_path, sizeof (struct GNUNET_PeerIdentity) * put_path_length);
+ pp = (struct GNUNET_PeerIdentity *) &ppm[1];
+ memcpy (pp, put_path,
+ sizeof (struct GNUNET_PeerIdentity) * put_path_length);
memcpy (&pp[put_path_length], data, data_size);
- GNUNET_CONTAINER_DLL_insert_tail (target->head,
- target->tail,
- pending);
+ GNUNET_CONTAINER_DLL_insert_tail (target->head, target->tail, pending);
target->pending_count++;
process_peer_queue (target);
}
@@ -1327,15 +1309,13 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
*/
void
GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- uint32_t hop_count,
- const GNUNET_HashCode *key,
- const void *xquery,
- size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator,
- struct GNUNET_CONTAINER_BloomFilter *peer_bf)
+ enum GNUNET_DHT_RouteOption options,
+ uint32_t desired_replication_level,
+ uint32_t hop_count, const GNUNET_HashCode * key,
+ const void *xquery, size_t xquery_size,
+ const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
+ uint32_t reply_bf_mutator,
+ struct GNUNET_CONTAINER_BloomFilter *peer_bf)
{
unsigned int target_count;
unsigned int i;
@@ -1347,28 +1327,25 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
char *xq;
size_t reply_bf_size;
- GNUNET_assert (NULL != peer_bf);
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# GET requests routed"), 1,
- GNUNET_NO);
- target_count = get_target_peers (key, peer_bf, hop_count,
- desired_replication_level,
- &targets);
+ GNUNET_assert (NULL != peer_bf);
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# GET requests routed"),
+ 1, GNUNET_NO);
+ target_count =
+ get_target_peers (key, peer_bf, hop_count, desired_replication_level,
+ &targets);
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding myself (%s) to GET bloomfilter for %s\n",
- GNUNET_i2s (&my_identity),
- GNUNET_h2s (key));
+ "Adding myself (%s) to GET bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity), GNUNET_h2s (key));
#endif
GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
if (0 == target_count)
{
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Routing GET for %s terminates after %u hops at %s\n",
- GNUNET_h2s (key),
- (unsigned int) hop_count,
- GNUNET_i2s (&my_identity));
+ "Routing GET for %s terminates after %u hops at %s\n",
+ GNUNET_h2s (key), (unsigned int) hop_count,
+ GNUNET_i2s (&my_identity));
#endif
return;
}
@@ -1381,23 +1358,22 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# GET messages queued for transmission"), target_count,
- GNUNET_NO);
+ gettext_noop
+ ("# GET messages queued for transmission"),
+ target_count, GNUNET_NO);
/* forward request */
- for (i=0;i<target_count;i++)
+ for (i = 0; i < target_count; i++)
{
target = targets[i];
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Routing GET for %s after %u hops to %s\n",
- GNUNET_h2s (key),
- (unsigned int) hop_count,
- GNUNET_i2s (&target->id));
+ "Routing GET for %s after %u hops to %s\n", GNUNET_h2s (key),
+ (unsigned int) hop_count, GNUNET_i2s (&target->id));
#endif
- pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
- pending->importance = 0; /* FIXME */
+ pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
+ pending->importance = 0; /* FIXME */
pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
- pgm = (struct PeerGetMessage*) &pending[1];
+ pgm = (struct PeerGetMessage *) &pending[1];
pending->msg = &pgm->header;
pgm->header.size = htons (msize);
pgm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET);
@@ -1406,23 +1382,24 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
pgm->hop_count = htonl (hop_count + 1);
pgm->desired_replication_level = htonl (desired_replication_level);
pgm->xquery_size = htonl (xquery_size);
- pgm->bf_mutator = reply_bf_mutator;
- GNUNET_break (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (peer_bf, &target->id.hashPubKey));
+ pgm->bf_mutator = reply_bf_mutator;
+ GNUNET_break (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (peer_bf,
+ &target->id.hashPubKey));
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
- pgm->bloomfilter,
- DHT_BLOOM_SIZE));
+ GNUNET_CONTAINER_bloomfilter_get_raw_data (peer_bf,
+ pgm->bloomfilter,
+ DHT_BLOOM_SIZE));
pgm->key = *key;
xq = (char *) &pgm[1];
memcpy (xq, xquery, xquery_size);
if (NULL != reply_bf)
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf,
- &xq[xquery_size],
- reply_bf_size));
- GNUNET_CONTAINER_DLL_insert_tail (target->head,
- target->tail,
- pending);
+ GNUNET_CONTAINER_bloomfilter_get_raw_data (reply_bf,
+ &xq
+ [xquery_size],
+ reply_bf_size));
+ GNUNET_CONTAINER_DLL_insert_tail (target->head, target->tail, pending);
target->pending_count++;
process_peer_queue (target);
}
@@ -1448,46 +1425,49 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
*/
void
GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute expiration_time,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- const void *data,
- size_t data_size)
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute expiration_time,
+ const GNUNET_HashCode * key,
+ unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *get_path,
+ const void *data, size_t data_size)
{
struct PeerInfo *pi;
struct P2PPendingMessage *pending;
size_t msize;
struct PeerResultMessage *prm;
struct GNUNET_PeerIdentity *paths;
-
- msize = data_size + sizeof (struct PeerResultMessage) +
- (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity);
- if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
- (get_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
- (put_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
- (data_size > GNUNET_SERVER_MAX_MESSAGE_SIZE) )
+
+ msize =
+ data_size + sizeof (struct PeerResultMessage) + (get_path_length +
+ put_path_length) *
+ sizeof (struct GNUNET_PeerIdentity);
+ if ((msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (get_path_length >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ (put_path_length >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ (data_size > GNUNET_SERVER_MAX_MESSAGE_SIZE))
{
GNUNET_break (0);
return;
}
- pi = GNUNET_CONTAINER_multihashmap_get (all_known_peers,
- &target->hashPubKey);
+ pi = GNUNET_CONTAINER_multihashmap_get (all_known_peers, &target->hashPubKey);
if (NULL == pi)
{
/* peer disconnected in the meantime, drop reply */
return;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# RESULT messages queued for transmission"), 1,
- GNUNET_NO);
- pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
- pending->importance = 0; /* FIXME */
+ gettext_noop
+ ("# RESULT messages queued for transmission"), 1,
+ GNUNET_NO);
+ pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
+ pending->importance = 0; /* FIXME */
pending->timeout = expiration_time;
- prm = (struct PeerResultMessage*) &pending[1];
+ prm = (struct PeerResultMessage *) &pending[1];
pending->msg = &prm->header;
prm->header.size = htons (msize);
prm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT);
@@ -1496,15 +1476,13 @@ GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
prm->get_path_length = htonl (get_path_length);
prm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
prm->key = *key;
- paths = (struct GNUNET_PeerIdentity*) &prm[1];
- memcpy (paths, put_path, put_path_length * sizeof (struct GNUNET_PeerIdentity));
- memcpy (&paths[put_path_length],
- get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity));
- memcpy (&paths[put_path_length + get_path_length],
- data, data_size);
- GNUNET_CONTAINER_DLL_insert (pi->head,
- pi->tail,
- pending);
+ paths = (struct GNUNET_PeerIdentity *) &prm[1];
+ memcpy (paths, put_path,
+ put_path_length * sizeof (struct GNUNET_PeerIdentity));
+ memcpy (&paths[put_path_length], get_path,
+ get_path_length * sizeof (struct GNUNET_PeerIdentity));
+ memcpy (&paths[put_path_length + get_path_length], data, data_size);
+ GNUNET_CONTAINER_DLL_insert (pi->head, pi->tail, pending);
pi->pending_count++;
process_peer_queue (pi);
}
@@ -1539,12 +1517,10 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
* GNUNET_SYSERR to close it (signal serious error)
*/
static int
-handle_dht_p2p_put (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
const struct PeerPutMessage *put;
const struct GNUNET_PeerIdentity *put_path;
@@ -1555,33 +1531,36 @@ handle_dht_p2p_put (void *cls,
enum GNUNET_DHT_RouteOption options;
struct GNUNET_CONTAINER_BloomFilter *bf;
GNUNET_HashCode test_key;
-
+
msize = ntohs (message->size);
if (msize < sizeof (struct PeerPutMessage))
{
GNUNET_break_op (0);
return GNUNET_YES;
}
- put = (const struct PeerPutMessage*) message;
+ put = (const struct PeerPutMessage *) message;
putlen = ntohl (put->put_path_length);
- if ( (msize < sizeof (struct PeerPutMessage) + putlen * sizeof (struct GNUNET_PeerIdentity)) ||
- (putlen > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
- {
- GNUNET_break_op (0);
- return GNUNET_YES;
- }
+ if ((msize <
+ sizeof (struct PeerPutMessage) +
+ putlen * sizeof (struct GNUNET_PeerIdentity)) ||
+ (putlen >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_YES;
+ }
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# P2P PUT requests received"), 1,
- GNUNET_NO);
- put_path = (const struct GNUNET_PeerIdentity*) &put[1];
+ gettext_noop ("# P2P PUT requests received"), 1,
+ GNUNET_NO);
+ put_path = (const struct GNUNET_PeerIdentity *) &put[1];
payload = &put_path[putlen];
options = ntohl (put->options);
- payload_size = msize - (sizeof (struct PeerPutMessage) +
- putlen * sizeof (struct GNUNET_PeerIdentity));
- switch (GNUNET_BLOCK_get_key (GDS_block_context,
- ntohl (put->type),
- payload, payload_size,
- &test_key))
+ payload_size =
+ msize - (sizeof (struct PeerPutMessage) +
+ putlen * sizeof (struct GNUNET_PeerIdentity));
+ switch (GNUNET_BLOCK_get_key
+ (GDS_block_context, ntohl (put->type), payload, payload_size,
+ &test_key))
{
case GNUNET_YES:
if (0 != memcmp (&test_key, &put->key, sizeof (GNUNET_HashCode)))
@@ -1598,18 +1577,16 @@ handle_dht_p2p_put (void *cls,
break;
}
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "PUT for %s at %s\n",
- GNUNET_h2s (&put->key),
- GNUNET_i2s (&my_identity));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for %s at %s\n",
+ GNUNET_h2s (&put->key), GNUNET_i2s (&my_identity));
#endif
- bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
- DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
- GNUNET_break_op (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &peer->hashPubKey));
+ bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_break_op (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (bf, &peer->hashPubKey));
{
- struct GNUNET_PeerIdentity pp[putlen+1];
-
+ struct GNUNET_PeerIdentity pp[putlen + 1];
+
/* extend 'put path' by sender */
if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
{
@@ -1619,37 +1596,23 @@ handle_dht_p2p_put (void *cls,
}
else
putlen = 0;
-
+
/* give to local clients */
GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (put->expiration_time),
- &put->key,
- 0, NULL,
- putlen,
- pp,
- ntohl (put->type),
- payload_size,
- payload);
+ &put->key, 0, NULL, putlen, pp, ntohl (put->type),
+ payload_size, payload);
/* store locally */
- if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
- (am_closest_peer (&put->key,
- bf) ) )
- GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
- &put->key,
- putlen, pp,
- ntohl (put->type),
- payload_size,
- payload);
+ if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
+ (am_closest_peer (&put->key, bf)))
+ GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh
+ (put->expiration_time), &put->key, putlen, pp,
+ ntohl (put->type), payload_size, payload);
/* route to other peers */
- GDS_NEIGHBOURS_handle_put (ntohl (put->type),
- options,
- ntohl (put->desired_replication_level),
- GNUNET_TIME_absolute_ntoh (put->expiration_time),
- ntohl (put->hop_count),
- bf,
- &put->key,
- putlen, pp,
- payload,
- payload_size);
+ GDS_NEIGHBOURS_handle_put (ntohl (put->type), options,
+ ntohl (put->desired_replication_level),
+ GNUNET_TIME_absolute_ntoh (put->expiration_time),
+ ntohl (put->hop_count), bf, &put->key, putlen,
+ pp, payload, payload_size);
}
GNUNET_CONTAINER_bloomfilter_free (bf);
return GNUNET_YES;
@@ -1667,9 +1630,8 @@ handle_dht_p2p_put (void *cls,
*/
static void
handle_find_peer (const struct GNUNET_PeerIdentity *sender,
- const GNUNET_HashCode *key,
- struct GNUNET_CONTAINER_BloomFilter *bf,
- uint32_t bf_mutator)
+ const GNUNET_HashCode * key,
+ struct GNUNET_CONTAINER_BloomFilter *bf, uint32_t bf_mutator)
{
int bucket_idx;
struct PeerBucket *bucket;
@@ -1682,30 +1644,31 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
if (NULL != GDS_my_hello)
{
GNUNET_BLOCK_mingle_hash (&my_identity.hashPubKey, bf_mutator, &mhash);
- if ( (NULL == bf) ||
- (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)) )
+ if ((NULL == bf) ||
+ (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)))
{
- GDS_NEIGHBOURS_handle_reply (sender,
- GNUNET_BLOCK_TYPE_DHT_HELLO,
- GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION),
- key,
- 0, NULL,
- 0, NULL,
- GDS_my_hello,
- GNUNET_HELLO_size ((const struct GNUNET_HELLO_Message*) GDS_my_hello));
+ GDS_NEIGHBOURS_handle_reply (sender, GNUNET_BLOCK_TYPE_DHT_HELLO,
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION),
+ key, 0, NULL, 0, NULL, GDS_my_hello,
+ GNUNET_HELLO_size ((const struct
+ GNUNET_HELLO_Message *)
+ GDS_my_hello));
}
else
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# FIND PEER requests ignored due to Bloomfilter"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# FIND PEER requests ignored due to Bloomfilter"),
+ 1, GNUNET_NO);
}
}
else
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# FIND PEER requests ignored due to lack of HELLO"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# FIND PEER requests ignored due to lack of HELLO"),
+ 1, GNUNET_NO);
}
/* then, also consider sending a random HELLO from the closest bucket */
@@ -1718,8 +1681,8 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
bucket = &k_buckets[bucket_idx];
if (bucket->peers_size == 0)
return;
- choice = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- bucket->peers_size);
+ choice =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, bucket->peers_size);
peer = bucket->head;
while (choice > 0)
{
@@ -1729,25 +1692,22 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
}
choice = bucket->peers_size;
do
- {
- peer = peer->next;
- if (choice-- == 0)
- return; /* no non-masked peer available */
- if (peer == NULL)
- peer = bucket->head;
- GNUNET_BLOCK_mingle_hash (&peer->id.hashPubKey, bf_mutator, &mhash);
- hello = GDS_HELLO_get (&peer->id);
- }
- while ( (hello == NULL) ||
- (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)) );
- GDS_NEIGHBOURS_handle_reply (sender,
- GNUNET_BLOCK_TYPE_DHT_HELLO,
- GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION),
- key,
- 0, NULL,
- 0, NULL,
- hello,
- GNUNET_HELLO_size (hello));
+ {
+ peer = peer->next;
+ if (choice-- == 0)
+ return; /* no non-masked peer available */
+ if (peer == NULL)
+ peer = bucket->head;
+ GNUNET_BLOCK_mingle_hash (&peer->id.hashPubKey, bf_mutator, &mhash);
+ hello = GDS_HELLO_get (&peer->id);
+ }
+ while ((hello == NULL) ||
+ (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (bf, &mhash)));
+ GDS_NEIGHBOURS_handle_reply (sender, GNUNET_BLOCK_TYPE_DHT_HELLO,
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION), key,
+ 0, NULL, 0, NULL, hello,
+ GNUNET_HELLO_size (hello));
}
@@ -1765,10 +1725,9 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
*/
static int
handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct PeerGetMessage *get;
uint32_t xquery_size;
@@ -1781,7 +1740,9 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
struct GNUNET_CONTAINER_BloomFilter *peer_bf;
const char *xquery;
- GNUNET_break (0 != memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)));
+ GNUNET_break (0 !=
+ memcmp (peer, &my_identity,
+ sizeof (struct GNUNET_PeerIdentity)));
/* parse and validate message */
msize = ntohs (message->size);
if (msize < sizeof (struct PeerGetMessage))
@@ -1797,24 +1758,20 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
return GNUNET_YES;
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# P2P GET requests received"), 1,
- GNUNET_NO);
+ gettext_noop ("# P2P GET requests received"), 1,
+ GNUNET_NO);
reply_bf_size = msize - (sizeof (struct PeerGetMessage) + xquery_size);
type = ntohl (get->type);
options = ntohl (get->options);
- xquery = (const char*) &get[1];
+ xquery = (const char *) &get[1];
reply_bf = NULL;
if (reply_bf_size > 0)
- reply_bf = GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size],
- reply_bf_size,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
- eval = GNUNET_BLOCK_evaluate (GDS_block_context,
- type,
- &get->key,
- &reply_bf,
- get->bf_mutator,
- xquery, xquery_size,
- NULL, 0);
+ reply_bf =
+ GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size], reply_bf_size,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ eval =
+ GNUNET_BLOCK_evaluate (GDS_block_context, type, &get->key, &reply_bf,
+ get->bf_mutator, xquery, xquery_size, NULL, 0);
if (eval != GNUNET_BLOCK_EVALUATION_REQUEST_VALID)
{
/* request invalid or block type not supported */
@@ -1824,70 +1781,55 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
return GNUNET_YES;
}
peer_bf =
- GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter,
- DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
- GNUNET_break_op (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (peer_bf, &peer->hashPubKey));
+ GNUNET_CONTAINER_bloomfilter_init (get->bloomfilter, DHT_BLOOM_SIZE,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_break_op (GNUNET_YES ==
+ GNUNET_CONTAINER_bloomfilter_test (peer_bf,
+ &peer->hashPubKey));
/* remember request for routing replies */
- GDS_ROUTING_add (peer,
- type,
- options,
- &get->key,
- xquery, xquery_size,
- reply_bf, get->bf_mutator);
+ GDS_ROUTING_add (peer, type, options, &get->key, xquery, xquery_size,
+ reply_bf, get->bf_mutator);
#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GET for %s at %s after %u hops\n",
- GNUNET_h2s (&get->key),
- GNUNET_i2s (&my_identity),
- (unsigned int) ntohl (get->hop_count));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GET for %s at %s after %u hops\n",
+ GNUNET_h2s (&get->key), GNUNET_i2s (&my_identity),
+ (unsigned int) ntohl (get->hop_count));
#endif
/* local lookup (this may update the reply_bf) */
- if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
- (am_closest_peer (&get->key,
- peer_bf) ) )
- {
- if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER)))
+ if ((0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
+ (am_closest_peer (&get->key, peer_bf)))
+ {
+ if ((0 != (options & GNUNET_DHT_RO_FIND_PEER)))
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# P2P FIND PEER requests processed"), 1,
- GNUNET_NO);
- handle_find_peer (peer,
- &get->key,
- reply_bf,
- get->bf_mutator);
+ gettext_noop
+ ("# P2P FIND PEER requests processed"), 1,
+ GNUNET_NO);
+ handle_find_peer (peer, &get->key, reply_bf, get->bf_mutator);
}
else
{
- eval = GDS_DATACACHE_handle_get (&get->key,
- type,
- xquery, xquery_size,
- &reply_bf,
- get->bf_mutator);
+ eval =
+ GDS_DATACACHE_handle_get (&get->key, type, xquery, xquery_size,
+ &reply_bf, get->bf_mutator);
}
}
else
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# P2P GET requests ONLY routed"), 1,
- GNUNET_NO);
+ gettext_noop ("# P2P GET requests ONLY routed"),
+ 1, GNUNET_NO);
}
-
+
/* P2P forwarding */
if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
- GDS_NEIGHBOURS_handle_get (type,
- options,
- ntohl (get->desired_replication_level),
- ntohl (get->hop_count),
- &get->key,
- xquery, xquery_size,
- reply_bf,
- get->bf_mutator,
- peer_bf);
+ GDS_NEIGHBOURS_handle_get (type, options,
+ ntohl (get->desired_replication_level),
+ ntohl (get->hop_count), &get->key, xquery,
+ xquery_size, reply_bf, get->bf_mutator, peer_bf);
/* clean up */
if (NULL != reply_bf)
GNUNET_CONTAINER_bloomfilter_free (reply_bf);
- GNUNET_CONTAINER_bloomfilter_free (peer_bf);
+ GNUNET_CONTAINER_bloomfilter_free (peer_bf);
return GNUNET_YES;
}
@@ -1904,10 +1846,9 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
*/
static int
handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
const struct PeerResultMessage *prm;
const struct GNUNET_PeerIdentity *put_path;
@@ -1918,7 +1859,7 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
uint16_t msize;
size_t data_size;
enum GNUNET_BLOCK_Type type;
-
+
/* parse and validate message */
msize = ntohs (message->size);
if (msize < sizeof (struct PeerResultMessage))
@@ -1929,23 +1870,28 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
prm = (struct PeerResultMessage *) message;
put_path_length = ntohl (prm->put_path_length);
get_path_length = ntohl (prm->get_path_length);
- if ( (msize < sizeof (struct PeerResultMessage) +
- (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity)) ||
- (get_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
- (put_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
+ if ((msize <
+ sizeof (struct PeerResultMessage) + (get_path_length +
+ put_path_length) *
+ sizeof (struct GNUNET_PeerIdentity)) ||
+ (get_path_length >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
+ (put_path_length >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_break_op (0);
return GNUNET_YES;
- }
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# P2P RESULTS received"), 1,
- GNUNET_NO);
- put_path = (const struct GNUNET_PeerIdentity*) &prm[1];
+ }
+ GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P RESULTS received"),
+ 1, GNUNET_NO);
+ put_path = (const struct GNUNET_PeerIdentity *) &prm[1];
get_path = &put_path[put_path_length];
type = ntohl (prm->type);
- data = (const void*) &get_path[get_path_length];
- data_size = msize - (sizeof (struct PeerResultMessage) +
- (get_path_length + put_path_length) * sizeof (struct GNUNET_PeerIdentity));
+ data = (const void *) &get_path[get_path_length];
+ data_size =
+ msize - (sizeof (struct PeerResultMessage) +
+ (get_path_length +
+ put_path_length) * sizeof (struct GNUNET_PeerIdentity));
/* if we got a HELLO, consider it for our own routing table */
if (type == GNUNET_BLOCK_TYPE_DHT_HELLO)
@@ -1967,8 +1913,7 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
return GNUNET_YES;
}
if (GNUNET_OK !=
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message*) h,
- &pid))
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) h, &pid))
{
GNUNET_break_op (0);
return GNUNET_YES;
@@ -1976,49 +1921,35 @@ handle_dht_p2p_result (void *cls, const struct GNUNET_PeerIdentity *peer,
if (0 != memcmp (&my_identity, &pid, sizeof (struct GNUNET_PeerIdentity)))
{
bucket = find_bucket (&pid.hashPubKey);
- if ( (bucket >= 0) &&
- (k_buckets[bucket].peers_size < bucket_size) )
- {
- if (NULL != GDS_transport_handle)
- {
- GNUNET_TRANSPORT_offer_hello (GDS_transport_handle,
- h, NULL, NULL);
- GNUNET_TRANSPORT_try_connect (GDS_transport_handle,
- &pid);
- }
- }
+ if ((bucket >= 0) && (k_buckets[bucket].peers_size < bucket_size))
+ {
+ if (NULL != GDS_transport_handle)
+ {
+ GNUNET_TRANSPORT_offer_hello (GDS_transport_handle, h, NULL, NULL);
+ GNUNET_TRANSPORT_try_connect (GDS_transport_handle, &pid);
+ }
+ }
}
}
/* append 'peer' to 'get_path' */
- {
- struct GNUNET_PeerIdentity xget_path[get_path_length+1];
+ {
+ struct GNUNET_PeerIdentity xget_path[get_path_length + 1];
- memcpy (xget_path, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity));
+ memcpy (xget_path, get_path,
+ get_path_length * sizeof (struct GNUNET_PeerIdentity));
xget_path[get_path_length] = *peer;
get_path_length++;
- /* forward to local clients */
+ /* forward to local clients */
GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
- &prm->key,
- get_path_length,
- xget_path,
- put_path_length,
- put_path,
- type,
- data_size,
- data);
+ &prm->key, get_path_length, xget_path,
+ put_path_length, put_path, type, data_size, data);
/* forward to other peers */
- GDS_ROUTING_process (type,
- GNUNET_TIME_absolute_ntoh (prm->expiration_time),
- &prm->key,
- put_path_length,
- put_path,
- get_path_length,
- xget_path,
- data,
- data_size);
+ GDS_ROUTING_process (type, GNUNET_TIME_absolute_ntoh (prm->expiration_time),
+ &prm->key, put_path_length, put_path, get_path_length,
+ xget_path, data, data_size);
}
return GNUNET_YES;
}
@@ -2039,21 +1970,16 @@ GDS_NEIGHBOURS_init ()
{NULL, 0, 0}
};
unsigned long long temp_config_num;
-
+
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (GDS_cfg, "DHT", "bucket_size",
&temp_config_num))
- bucket_size = (unsigned int) temp_config_num;
+ bucket_size = (unsigned int) temp_config_num;
atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL);
- coreAPI = GNUNET_CORE_connect (GDS_cfg,
- 1,
- NULL,
- &core_init,
- &handle_core_connect,
- &handle_core_disconnect,
- NULL, GNUNET_NO,
- NULL, GNUNET_NO,
- core_handlers);
+ coreAPI =
+ GNUNET_CORE_connect (GDS_cfg, 1, NULL, &core_init, &handle_core_connect,
+ &handle_core_disconnect, NULL, GNUNET_NO, NULL,
+ GNUNET_NO, core_handlers);
if (coreAPI == NULL)
return GNUNET_SYSERR;
all_known_peers = GNUNET_CONTAINER_multihashmap_create (256);
@@ -2070,9 +1996,9 @@ GDS_NEIGHBOURS_done ()
if (coreAPI == NULL)
return;
GNUNET_CORE_disconnect (coreAPI);
- coreAPI = NULL;
+ coreAPI = NULL;
GNUNET_ATS_performance_done (atsAPI);
- atsAPI = NULL;
+ atsAPI = NULL;
GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (all_known_peers));
GNUNET_CONTAINER_multihashmap_destroy (all_known_peers);
all_known_peers = NULL;
diff --git a/src/dht/gnunet-service-dht_neighbours.h b/src/dht/gnunet-service-dht_neighbours.h
index d23ea10ab..b6e0f0ec0 100644
--- a/src/dht/gnunet-service-dht_neighbours.h
+++ b/src/dht/gnunet-service-dht_neighbours.h
@@ -52,16 +52,15 @@
*/
void
GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- struct GNUNET_TIME_Absolute expiration_time,
- uint32_t hop_count,
- struct GNUNET_CONTAINER_BloomFilter *bf,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- struct GNUNET_PeerIdentity *put_path,
- const void *data,
- size_t data_size);
+ enum GNUNET_DHT_RouteOption options,
+ uint32_t desired_replication_level,
+ struct GNUNET_TIME_Absolute expiration_time,
+ uint32_t hop_count,
+ struct GNUNET_CONTAINER_BloomFilter *bf,
+ const GNUNET_HashCode * key,
+ unsigned int put_path_length,
+ struct GNUNET_PeerIdentity *put_path,
+ const void *data, size_t data_size);
/**
@@ -83,15 +82,13 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
*/
void
GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- uint32_t hop_count,
- const GNUNET_HashCode *key,
- const void *xquery,
- size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator,
- struct GNUNET_CONTAINER_BloomFilter *peer_bf);
+ enum GNUNET_DHT_RouteOption options,
+ uint32_t desired_replication_level,
+ uint32_t hop_count, const GNUNET_HashCode * key,
+ const void *xquery, size_t xquery_size,
+ const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
+ uint32_t reply_bf_mutator,
+ struct GNUNET_CONTAINER_BloomFilter *peer_bf);
/**
@@ -112,15 +109,14 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
*/
void
GDS_NEIGHBOURS_handle_reply (const struct GNUNET_PeerIdentity *target,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute expiration_time,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- const void *data,
- size_t data_size);
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute expiration_time,
+ const GNUNET_HashCode * key,
+ unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *get_path,
+ const void *data, size_t data_size);
/**
diff --git a/src/dht/gnunet-service-dht_nse.c b/src/dht/gnunet-service-dht_nse.c
index 0a662ec7b..777998967 100644
--- a/src/dht/gnunet-service-dht_nse.c
+++ b/src/dht/gnunet-service-dht_nse.c
@@ -56,10 +56,10 @@ update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp,
double logestimate, double std_dev)
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Network size estimates received"), 1,
- GNUNET_NO);
+ gettext_noop ("# Network size estimates received"),
+ 1, GNUNET_NO);
/* do not allow estimates < 0.5 */
- log_of_network_size_estimate = GNUNET_MAX (0.5, logestimate);
+ log_of_network_size_estimate = GNUNET_MAX (0.5, logestimate);
}
@@ -90,9 +90,9 @@ GDS_NSE_init ()
*/
void
GDS_NSE_done ()
-{
+{
if (NULL != nse)
- {
+ {
GNUNET_NSE_disconnect (nse);
nse = NULL;
}
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index 607c756c6..a880bf7cd 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -66,7 +66,7 @@ struct RecentRequest
* Type of the requested block.
*/
enum GNUNET_BLOCK_Type type;
-
+
/**
* extended query (see gnunet_block_lib.h). Allocated at the
* end of this struct.
@@ -114,7 +114,7 @@ struct ProcessContext
/**
* Path of the reply.
- */
+ */
const struct GNUNET_PeerIdentity *get_path;
/**
@@ -156,13 +156,11 @@ struct ProcessContext
* @param cls the 'struct ProcessContext' with the result
* @param key the query
* @param value the 'struct RecentRequest' with the request
- * @return GNUNET_OK (continue to iterate),
+ * @return GNUNET_OK (continue to iterate),
* GNUNET_SYSERR if the result is malformed or type unsupported
*/
static int
-process (void *cls,
- const GNUNET_HashCode *key,
- void *value)
+process (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ProcessContext *pc = cls;
struct RecentRequest *rr = value;
@@ -172,9 +170,8 @@ process (void *cls,
GNUNET_HashCode hc;
const GNUNET_HashCode *eval_key;
- if ( (rr->type != GNUNET_BLOCK_TYPE_ANY) &&
- (rr->type != pc->type) )
- return GNUNET_OK; /* type missmatch */
+ if ((rr->type != GNUNET_BLOCK_TYPE_ANY) && (rr->type != pc->type))
+ return GNUNET_OK; /* type missmatch */
if (0 != (rr->options & GNUNET_DHT_RO_RECORD_ROUTE))
{
@@ -186,59 +183,48 @@ process (void *cls,
gpl = 0;
ppl = 0;
}
- if ( (0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) &&
- (pc->type == GNUNET_BLOCK_TYPE_DHT_HELLO) )
+ if ((0 != (rr->options & GNUNET_DHT_RO_FIND_PEER)) &&
+ (pc->type == GNUNET_BLOCK_TYPE_DHT_HELLO))
{
/* key may not match HELLO, which is OK since
- the search is approximate. Still, the evaluation
- would fail since the match is not exact. So
- we fake it by changing the key to the actual PID ... */
- GNUNET_BLOCK_get_key (GDS_block_context,
- GNUNET_BLOCK_TYPE_DHT_HELLO,
- pc->data, pc->data_size,
- &hc);
+ * the search is approximate. Still, the evaluation
+ * would fail since the match is not exact. So
+ * we fake it by changing the key to the actual PID ... */
+ GNUNET_BLOCK_get_key (GDS_block_context, GNUNET_BLOCK_TYPE_DHT_HELLO,
+ pc->data, pc->data_size, &hc);
eval_key = &hc;
}
else
{
eval_key = key;
}
- eval = GNUNET_BLOCK_evaluate (GDS_block_context,
- pc->type,
- eval_key,
- &rr->reply_bf,
- rr->reply_bf_mutator,
- rr->xquery,
- rr->xquery_size,
- pc->data,
- pc->data_size);
+ eval =
+ GNUNET_BLOCK_evaluate (GDS_block_context, pc->type, eval_key,
+ &rr->reply_bf, rr->reply_bf_mutator, rr->xquery,
+ rr->xquery_size, pc->data, pc->data_size);
switch (eval)
{
case GNUNET_BLOCK_EVALUATION_OK_MORE:
case GNUNET_BLOCK_EVALUATION_OK_LAST:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Good REPLIES matched against routing table"), 1,
- GNUNET_NO);
- GDS_NEIGHBOURS_handle_reply (&rr->peer,
- pc->type,
- pc->expiration_time,
- key,
- ppl,
- pc->put_path,
- gpl,
- pc->get_path,
- pc->data,
- pc->data_size);
+ gettext_noop
+ ("# Good REPLIES matched against routing table"),
+ 1, GNUNET_NO);
+ GDS_NEIGHBOURS_handle_reply (&rr->peer, pc->type, pc->expiration_time, key,
+ ppl, pc->put_path, gpl, pc->get_path, pc->data,
+ pc->data_size);
break;
case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Duplicate REPLIES matched against routing table"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Duplicate REPLIES matched against routing table"),
+ 1, GNUNET_NO);
return GNUNET_OK;
case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Invalid REPLIES matched against routing table"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Invalid REPLIES matched against routing table"),
+ 1, GNUNET_NO);
return GNUNET_SYSERR;
case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
@@ -246,12 +232,13 @@ process (void *cls,
return GNUNET_OK;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Unsupported REPLIES matched against routing table"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Unsupported REPLIES matched against routing table"),
+ 1, GNUNET_NO);
return GNUNET_SYSERR;
default:
GNUNET_break (0);
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
}
return GNUNET_OK;
}
@@ -276,14 +263,12 @@ process (void *cls,
*/
void
GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute expiration_time,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- const void *data,
- size_t data_size)
+ struct GNUNET_TIME_Absolute expiration_time,
+ const GNUNET_HashCode * key, unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *get_path,
+ const void *data, size_t data_size)
{
struct ProcessContext pc;
@@ -295,10 +280,7 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
pc.get_path = get_path;
pc.data = data;
pc.data_size = data_size;
- GNUNET_CONTAINER_multihashmap_get_multiple (recent_map,
- key,
- &process,
- &pc);
+ GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &pc);
}
@@ -316,21 +298,21 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
*/
void
GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
- enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- const GNUNET_HashCode *key,
- const void *xquery,
- size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator)
+ enum GNUNET_BLOCK_Type type,
+ enum GNUNET_DHT_RouteOption options,
+ const GNUNET_HashCode * key, const void *xquery,
+ size_t xquery_size,
+ const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
+ uint32_t reply_bf_mutator)
{
struct RecentRequest *recent_req;
while (GNUNET_CONTAINER_heap_get_size (recent_heap) >= DHT_MAX_RECENT)
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Entries removed from routing table"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Entries removed from routing table"), 1,
+ GNUNET_NO);
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap);
GNUNET_assert (recent_req != NULL);
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node);
@@ -339,25 +321,22 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
}
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Entries added to routing table"), 1,
- GNUNET_NO);
+ gettext_noop ("# Entries added to routing table"),
+ 1, GNUNET_NO);
recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size);
recent_req->peer = *sender;
recent_req->key = *key;
recent_req->heap_node =
- GNUNET_CONTAINER_heap_insert (recent_heap, recent_req,
- GNUNET_TIME_absolute_get ().abs_value);
- recent_req->reply_bf =
- GNUNET_CONTAINER_bloomfilter_copy (reply_bf);
+ GNUNET_CONTAINER_heap_insert (recent_heap, recent_req,
+ GNUNET_TIME_absolute_get ().abs_value);
+ recent_req->reply_bf = GNUNET_CONTAINER_bloomfilter_copy (reply_bf);
recent_req->type = type;
recent_req->options = options;
recent_req->xquery = &recent_req[1];
recent_req->xquery_size = xquery_size;
recent_req->reply_bf_mutator = reply_bf_mutator;
- GNUNET_CONTAINER_multihashmap_put (recent_map,
- key,
- recent_req,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_CONTAINER_multihashmap_put (recent_map, key, recent_req,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
}
@@ -369,10 +348,8 @@ GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
void
GDS_ROUTING_init ()
{
- recent_heap =
- GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- recent_map =
- GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT * 4 / 3);
+ recent_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ recent_map = GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT * 4 / 3);
}
@@ -387,8 +364,9 @@ GDS_ROUTING_done ()
while (GNUNET_CONTAINER_heap_get_size (recent_heap) > 0)
{
GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# Entries removed from routing table"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# Entries removed from routing table"), 1,
+ GNUNET_NO);
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap);
GNUNET_assert (recent_req != NULL);
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node);
diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h
index a2576a3bb..9b12c71de 100644
--- a/src/dht/gnunet-service-dht_routing.h
+++ b/src/dht/gnunet-service-dht_routing.h
@@ -50,14 +50,12 @@
*/
void
GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute expiration_time,
- const GNUNET_HashCode *key,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- const void *data,
- size_t data_size);
+ struct GNUNET_TIME_Absolute expiration_time,
+ const GNUNET_HashCode * key, unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *get_path,
+ const void *data, size_t data_size);
/**
@@ -74,13 +72,12 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
*/
void
GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
- enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- const GNUNET_HashCode *key,
- const void *xquery,
- size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator);
+ enum GNUNET_BLOCK_Type type,
+ enum GNUNET_DHT_RouteOption options,
+ const GNUNET_HashCode * key, const void *xquery,
+ size_t xquery_size,
+ const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
+ uint32_t reply_bf_mutator);
/**
diff --git a/src/dht/test_dht_2dtorus.c b/src/dht/test_dht_2dtorus.c
index 220554e15..1db351841 100644
--- a/src/dht/test_dht_2dtorus.c
+++ b/src/dht/test_dht_2dtorus.c
@@ -138,7 +138,8 @@ shutdown_callback (void *cls, const char *emsg)
else
{
#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: All peers successfully shut down!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "test: All peers successfully shut down!\n");
#endif
}
}
@@ -169,22 +170,21 @@ disconnect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
unsigned int i;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: disconnecting peers\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: disconnecting peers\n");
disconnect_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_SCHEDULER_cancel (put_task);
if (NULL != get_h)
- GNUNET_DHT_get_stop(get_h);
+ GNUNET_DHT_get_stop (get_h);
if (NULL != get_h_2)
- GNUNET_DHT_get_stop(get_h_2);
+ GNUNET_DHT_get_stop (get_h_2);
if (NULL != get_h_far)
- GNUNET_DHT_get_stop(get_h_far);
- for (i = 0; i < num_peers; i++)
+ GNUNET_DHT_get_stop (get_h_far);
+ for (i = 0; i < num_peers; i++)
{
- GNUNET_DHT_disconnect(hs[i]);
+ GNUNET_DHT_disconnect (hs[i]);
}
GNUNET_SCHEDULER_cancel (shutdown_handle);
- shutdown_handle = GNUNET_SCHEDULER_add_now(&shutdown_task, NULL);
+ shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
}
static void
@@ -193,44 +193,39 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
const struct GNUNET_PeerIdentity *get_path,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
int i;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: ************* FOUND!!! ***********\n");
- if (sizeof(GNUNET_HashCode) == size)
+ "test: ************* FOUND!!! ***********\n");
+ if (sizeof (GNUNET_HashCode) == size)
{
const GNUNET_HashCode *h = data;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: Contents: %s\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Contents: %s\n",
GNUNET_h2s_full (h));
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: PATH: (get %u, put %u)\n",
- get_path_length,
- put_path_length);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: LOCAL\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: PATH: (get %u, put %u)\n",
+ get_path_length, put_path_length);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: LOCAL\n");
for (i = get_path_length - 1; i >= 0; i--)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: %s\n",
- GNUNET_i2s (&get_path[i]));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: %s\n",
+ GNUNET_i2s (&get_path[i]));
}
for (i = put_path_length - 1; i >= 0; i--)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: %s\n",
- GNUNET_i2s (&put_path[i]));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: %s\n",
+ GNUNET_i2s (&put_path[i]));
}
found++;
if (found < 3)
return;
ok = 0;
- GNUNET_SCHEDULER_cancel(disconnect_task);
+ GNUNET_SCHEDULER_cancel (disconnect_task);
disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL);
}
@@ -263,7 +258,7 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (strcmp (id_aux, id_near2) == 0)
d2 = aux;
}
- if ( (NULL == o) || (NULL == d) || (NULL == d2) || (NULL == d_far))
+ if ((NULL == o) || (NULL == d) || (NULL == d2) || (NULL == d_far))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"test: Peers not found (hostkey file changed?)\n");
@@ -272,55 +267,39 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: test_task\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: looking for %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n",
GNUNET_h2s_full (&d->id.hashPubKey));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: looking for %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n",
GNUNET_h2s_full (&d2->id.hashPubKey));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: looking for %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: looking for %s\n",
GNUNET_h2s_full (&d_far->id.hashPubKey));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: from %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: from %s\n",
GNUNET_h2s_full (&o->id.hashPubKey));
found = 0;
- get_h = GNUNET_DHT_get_start (hs[0],
- GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
- GNUNET_BLOCK_TYPE_TEST, /* type */
- &d->id.hashPubKey, /*key to search */
- 4U, /* replication level */
- GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_id_handler,
- NULL);
- get_h_2 = GNUNET_DHT_get_start (hs[0],
- GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
- GNUNET_BLOCK_TYPE_TEST, /* type */
+ get_h = GNUNET_DHT_get_start (hs[0], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
+ GNUNET_BLOCK_TYPE_TEST, /* type */
+ &d->id.hashPubKey, /*key to search */
+ 4U, /* replication level */
+ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, /* xquery */
+ 0, /* xquery bits */
+ &dht_get_id_handler, NULL);
+ get_h_2 = GNUNET_DHT_get_start (hs[0], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
+ GNUNET_BLOCK_TYPE_TEST, /* type */
&d2->id.hashPubKey, /*key to search */
- 4U, /* replication level */
- GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_id_handler,
- NULL);
- get_h_far = GNUNET_DHT_get_start (hs[0],
- GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
- GNUNET_BLOCK_TYPE_TEST, /* type */
- &d_far->id.hashPubKey, /*key to search */
- 4U, /* replication level */
- GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_id_handler,
- NULL);
+ 4U, /* replication level */
+ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, /* xquery */
+ 0, /* xquery bits */
+ &dht_get_id_handler, NULL);
+ get_h_far = GNUNET_DHT_get_start (hs[0], GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
+ GNUNET_BLOCK_TYPE_TEST, /* type */
+ &d_far->id.hashPubKey, /*key to search */
+ 4U, /* replication level */
+ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, /* xquery */
+ 0, /* xquery bits */
+ &dht_get_id_handler, NULL);
GNUNET_SCHEDULER_cancel (disconnect_task);
- disconnect_task = GNUNET_SCHEDULER_add_delayed(GET_TIMEOUT,
- &disconnect_peers, NULL);
+ disconnect_task =
+ GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &disconnect_peers, NULL);
}
@@ -331,28 +310,20 @@ put_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
unsigned int i;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting id's in DHT\n");
- for (i = 0; i < num_peers; i++)
+ for (i = 0; i < num_peers; i++)
{
d = GNUNET_TESTING_daemon_get (pg, i);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: putting into DHT: %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: putting into DHT: %s\n",
GNUNET_h2s_full (&d->id.hashPubKey));
- GNUNET_DHT_put(hs[i],
- &d->id.hashPubKey,
- 10U,
- GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_TEST,
- sizeof(struct GNUNET_PeerIdentity),
- (const char *) &d->id,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
- NULL);
+ GNUNET_DHT_put (hs[i], &d->id.hashPubKey, 10U,
+ GNUNET_DHT_RO_RECORD_ROUTE |
+ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
+ GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity),
+ (const char *) &d->id, GNUNET_TIME_UNIT_FOREVER_ABS,
+ GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
}
- put_task = GNUNET_SCHEDULER_add_delayed(PUT_FREQUENCY,
- &put_id, NULL);
+ put_task = GNUNET_SCHEDULER_add_delayed (PUT_FREQUENCY, &put_id, NULL);
}
@@ -373,8 +344,8 @@ peergroup_ready (void *cls, const char *emsg)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"test: Peergroup callback called with error, aborting test!\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: Error from testing: `%s'\n", emsg);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Error from testing: `%s'\n",
+ emsg);
ok++;
GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
return;
@@ -384,8 +355,7 @@ peergroup_ready (void *cls, const char *emsg)
"************************************************************\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"test: Peer Group started successfully!\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: Have %u connections\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Have %u connections\n",
total_connections);
#endif
@@ -398,24 +368,22 @@ peergroup_ready (void *cls, const char *emsg)
GNUNET_free (buf);
}
peers_running = GNUNET_TESTING_daemons_running (pg);
-
+
GNUNET_assert (peers_running == num_peers);
- hs = GNUNET_malloc (num_peers * sizeof(struct GNUNET_DHT_Handle *));
- for (i = 0; i < num_peers; i++)
+ hs = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_Handle *));
+ for (i = 0; i < num_peers; i++)
{
d = GNUNET_TESTING_daemon_get (pg, i);
- hs[i] = GNUNET_DHT_connect(d->cfg, 32);
+ hs[i] = GNUNET_DHT_connect (d->cfg, 32);
}
- put_task = GNUNET_SCHEDULER_add_now(&put_id, NULL);
+ put_task = GNUNET_SCHEDULER_add_now (&put_id, NULL);
test_task =
- GNUNET_SCHEDULER_add_delayed(
- GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2),
- &do_test, NULL);
- disconnect_task =
- GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT,
- &disconnect_peers,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, 2), &do_test,
NULL);
+ disconnect_task =
+ GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &disconnect_peers, NULL);
}
@@ -446,14 +414,13 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *first,
if (emsg == NULL)
{
total_connections++;
- GNUNET_PEER_intern(first);
- GNUNET_PEER_intern(second);
+ GNUNET_PEER_intern (first);
+ GNUNET_PEER_intern (second);
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test: Problem with new connection (%s)\n",
- emsg);
+ "test: Problem with new connection (%s)\n", emsg);
}
}
@@ -496,7 +463,7 @@ run (void *cls, char *const *args, const char *cfgfile,
"num_peers", &num_peers))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Option TESTING:NUM_PEERS is required!\n");
+ "Option TESTING:NUM_PEERS is required!\n");
return;
}
@@ -516,17 +483,17 @@ run (void *cls, char *const *args, const char *cfgfile,
&data_filename))
{
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);
+ 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_free (data_filename);
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n",
+ data_filename);
+ GNUNET_free (data_filename);
+ }
}
if (GNUNET_YES ==
@@ -552,7 +519,7 @@ run (void *cls, char *const *args, const char *cfgfile,
hosts);
GNUNET_assert (pg != NULL);
shutdown_handle =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&shutdown_task, NULL);
}
@@ -584,7 +551,8 @@ main (int xargc, char *xargv[])
NULL
};
- GNUNET_PROGRAM_run (sizeof(argv)/sizeof(char*) - 1, argv, "test_dht_2dtorus",
+ GNUNET_PROGRAM_run (sizeof (argv) / sizeof (char *) - 1, argv,
+ "test_dht_2dtorus",
gettext_noop ("Test dht in a small 2D torus."), options,
&run, NULL);
#if REMOVE_DIR
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c
index 51f7d947c..e636c08ba 100644
--- a/src/dht/test_dht_api.c
+++ b/src/dht/test_dht_api.c
@@ -179,10 +179,10 @@ static void
test_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"test_get_iterator called (we got a result), stopping get request!\n");
@@ -213,9 +213,9 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
peer->get_handle =
GNUNET_DHT_get_start (peer->dht_handle, TOTAL_TIMEOUT,
- GNUNET_BLOCK_TYPE_TEST, &hash,
- 1, GNUNET_DHT_RO_NONE, NULL,
- 0, &test_get_iterator, NULL);
+ GNUNET_BLOCK_TYPE_TEST, &hash, 1,
+ GNUNET_DHT_RO_NONE, NULL, 0, &test_get_iterator,
+ NULL);
if (peer->get_handle == NULL)
{
@@ -250,8 +250,8 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_assert (peer->dht_handle != NULL);
- GNUNET_DHT_put (peer->dht_handle, &hash, 1,
- GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, data_size, data,
+ GNUNET_DHT_put (peer->dht_handle, &hash, 1, 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);
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index 62833a583..f6519239b 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -95,12 +95,12 @@ struct TestPutContext
struct TestGetContext
{
/**
- * This is a linked list
+ * This is a linked list
*/
struct TestGetContext *next;
/**
- * This is a linked list
+ * This is a linked list
*/
struct TestGetContext *prev;
@@ -220,9 +220,7 @@ shutdown_callback (void *cls, const char *emsg)
{
if (emsg != NULL)
{
- fprintf (stderr,
- "Failed to shutdown testing topology: %s\n",
- emsg);
+ fprintf (stderr, "Failed to shutdown testing topology: %s\n", emsg);
if (ok == 0)
ok = 2;
}
@@ -370,18 +368,18 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_free (sm);
i = 0;
while (stats[i].name != NULL)
- {
- fprintf (stderr, "Total : %12s/%50s = %12llu\n", stats[i].subsystem,
- stats[i].name, (unsigned long long) stats[i].total);
- i++;
- }
+ {
+ fprintf (stderr, "Total : %12s/%50s = %12llu\n", stats[i].subsystem,
+ stats[i].name, (unsigned long long) stats[i].total);
+ i++;
+ }
die_task = GNUNET_SCHEDULER_add_now (&do_stop, NULL);
return;
}
sm->stat =
GNUNET_STATISTICS_create ("<driver>",
- GNUNET_TESTING_daemon_get (pg,
- sm->daemon)->cfg);
+ GNUNET_TESTING_daemon_get (pg,
+ sm->daemon)->cfg);
die_task = GNUNET_SCHEDULER_add_now (&stat_run, sm);
}
@@ -404,9 +402,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_SCHEDULER_cancel (test_put->task);
if (test_put->dht_handle != NULL)
GNUNET_DHT_disconnect (test_put->dht_handle);
- GNUNET_CONTAINER_DLL_remove (all_puts_head,
- all_puts_tail,
- test_put);
+ GNUNET_CONTAINER_DLL_remove (all_puts_head, all_puts_tail, test_put);
GNUNET_free (test_put);
}
@@ -418,16 +414,14 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_DHT_get_stop (test_get->get_handle);
if (test_get->dht_handle != NULL)
GNUNET_DHT_disconnect (test_get->dht_handle);
- GNUNET_CONTAINER_DLL_remove (all_gets_head,
- all_gets_tail,
- test_get);
+ GNUNET_CONTAINER_DLL_remove (all_gets_head, all_gets_tail, test_get);
GNUNET_free (test_get);
}
sm = GNUNET_malloc (sizeof (struct StatMaster));
sm->stat =
- GNUNET_STATISTICS_create ("<driver>",
- GNUNET_TESTING_daemon_get (pg,
- sm->daemon)->cfg);
+ GNUNET_STATISTICS_create ("<driver>",
+ GNUNET_TESTING_daemon_get (pg,
+ sm->daemon)->cfg);
die_task = GNUNET_SCHEDULER_add_now (&stat_run, sm);
}
@@ -445,18 +439,14 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
struct TestGetContext *test_get;
die_task = GNUNET_SCHEDULER_NO_TASK;
- fprintf (stderr,
- "Failing test with error: `%s'!\n",
- emsg);
+ fprintf (stderr, "Failing test with error: `%s'!\n", emsg);
while (NULL != (test_put = all_puts_head))
{
if (test_put->task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (test_put->task);
if (test_put->dht_handle != NULL)
GNUNET_DHT_disconnect (test_put->dht_handle);
- GNUNET_CONTAINER_DLL_remove (all_puts_head,
- all_puts_tail,
- test_put);
+ GNUNET_CONTAINER_DLL_remove (all_puts_head, all_puts_tail, test_put);
GNUNET_free (test_put);
}
@@ -468,9 +458,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_DHT_get_stop (test_get->get_handle);
if (test_get->dht_handle != NULL)
GNUNET_DHT_disconnect (test_get->dht_handle);
- GNUNET_CONTAINER_DLL_remove (all_gets_head,
- all_gets_tail,
- test_get);
+ GNUNET_CONTAINER_DLL_remove (all_gets_head, all_gets_tail, test_get);
GNUNET_free (test_get);
}
ok = 1;
@@ -495,10 +483,8 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (test_get->succeeded != GNUNET_YES)
{
gets_failed++;
- fprintf (stderr,
- "Get from peer %s for key %s failed!\n",
- GNUNET_i2s (&test_get->daemon->id),
- GNUNET_h2s (&search_key));
+ fprintf (stderr, "Get from peer %s for key %s failed!\n",
+ GNUNET_i2s (&test_get->daemon->id), GNUNET_h2s (&search_key));
}
GNUNET_assert (test_get->get_handle != NULL);
GNUNET_DHT_get_stop (test_get->get_handle);
@@ -508,29 +494,25 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_DHT_disconnect (test_get->dht_handle);
test_get->dht_handle = NULL;
- GNUNET_CONTAINER_DLL_remove (all_gets_head,
- all_gets_tail,
- test_get);
+ GNUNET_CONTAINER_DLL_remove (all_gets_head, all_gets_tail, test_get);
GNUNET_free (test_get);
- if ((gets_failed > 10) && (outstanding_gets == 0))
+ if ((gets_failed > 10) && (outstanding_gets == 0))
{
/* Had more than 10% failures */
- fprintf (stderr,
- "%llu gets succeeded, %llu gets failed!\n",
- gets_completed, gets_failed);
+ fprintf (stderr, "%llu gets succeeded, %llu gets failed!\n", gets_completed,
+ gets_failed);
GNUNET_SCHEDULER_cancel (die_task);
- ok = 1;
- die_task = GNUNET_SCHEDULER_add_now (&finish_testing, "not all gets succeeded");
+ ok = 1;
+ die_task =
+ GNUNET_SCHEDULER_add_now (&finish_testing, "not all gets succeeded");
return;
}
- if ( (gets_completed + gets_failed == num_peers * num_peers) &&
- (outstanding_gets == 0) ) /* All gets successful */
+ if ((gets_completed + gets_failed == num_peers * num_peers) && (outstanding_gets == 0)) /* All gets successful */
{
- fprintf (stderr,
- "%llu gets succeeded, %llu gets failed!\n",
- gets_completed, gets_failed);
+ fprintf (stderr, "%llu gets succeeded, %llu gets failed!\n", gets_completed,
+ gets_failed);
GNUNET_SCHEDULER_cancel (die_task);
- ok = 0;
+ ok = 0;
die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
}
}
@@ -550,10 +532,10 @@ static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
struct TestGetContext *test_get = cls;
GNUNET_HashCode search_key; /* Key stored under */
@@ -569,9 +551,8 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
{
unsigned int i;
- fprintf (stderr, "PUT (%u) Path: ",
- test_get->uid);
- for (i = 0; i<put_path_length; i++)
+ fprintf (stderr, "PUT (%u) Path: ", test_get->uid);
+ for (i = 0; i < put_path_length; i++)
fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&put_path[i]));
fprintf (stderr, "\n");
}
@@ -579,25 +560,22 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
{
unsigned int i;
- fprintf (stderr, "GET (%u) Path: ",
- test_get->uid);
+ fprintf (stderr, "GET (%u) Path: ", test_get->uid);
for (i = 0; i < get_path_length; i++)
fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&get_path[i]));
- fprintf (stderr, "%s%s\n",
- get_path_length > 0 ? "->":"",
- GNUNET_i2s (&test_get->daemon->id));
+ fprintf (stderr, "%s%s\n", get_path_length > 0 ? "->" : "",
+ GNUNET_i2s (&test_get->daemon->id));
}
#endif
if ((0 != memcmp (&search_key, key, sizeof (GNUNET_HashCode))) ||
(0 != memcmp (original_data, data, sizeof (original_data))))
{
- fprintf (stderr,
- "Key or data is not the same as was inserted!\n");
+ fprintf (stderr, "Key or data is not the same as was inserted!\n");
return;
}
gets_completed++;
- test_get->succeeded = GNUNET_YES;
+ test_get->succeeded = GNUNET_YES;
GNUNET_SCHEDULER_cancel (test_get->task);
test_get->task = GNUNET_SCHEDULER_add_now (&get_stop_task, test_get);
}
@@ -615,7 +593,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (outstanding_gets > MAX_OUTSTANDING_GETS)
{
- test_get->task = GNUNET_SCHEDULER_add_delayed (GET_DELAY, &do_get, test_get);
+ test_get->task =
+ GNUNET_SCHEDULER_add_delayed (GET_DELAY, &do_get, test_get);
return;
}
memset (data, test_get->uid, sizeof (data));
@@ -624,12 +603,11 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
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,
- 1, route_option, NULL, 0,
- &get_result_iterator, test_get);
+ GNUNET_DHT_get_start (test_get->dht_handle, GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_BLOCK_TYPE_TEST, &key, 1, route_option, NULL,
+ 0, &get_result_iterator, test_get);
test_get->task =
- GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &get_stop_task, test_get);
+ GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &get_stop_task, test_get);
}
@@ -644,9 +622,7 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
test_put->task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_DHT_disconnect (test_put->dht_handle);
test_put->dht_handle = NULL;
- GNUNET_CONTAINER_DLL_remove (all_puts_head,
- all_puts_tail,
- test_put);
+ GNUNET_CONTAINER_DLL_remove (all_puts_head, all_puts_tail, test_put);
GNUNET_free (test_put);
}
@@ -661,23 +637,19 @@ start_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
unsigned long long j;
struct TestGetContext *test_get;
-#if VERBOSE
- fprintf (stderr,
- "Issuing %llu GETs\n",
- (unsigned long long) (num_peers * num_peers));
+#if VERBOSE
+ fprintf (stderr, "Issuing %llu GETs\n",
+ (unsigned long long) (num_peers * num_peers));
#endif
for (i = 0; i < num_peers; i++)
for (j = 0; j < num_peers; j++)
- {
- test_get = GNUNET_malloc (sizeof (struct TestGetContext));
- test_get->uid = i + j*num_peers;
- test_get->daemon = GNUNET_TESTING_daemon_get (pg, j);
- GNUNET_CONTAINER_DLL_insert (all_gets_head,
- all_gets_tail,
- test_get);
- test_get->task = GNUNET_SCHEDULER_add_now (&do_get,
- test_get);
- }
+ {
+ test_get = GNUNET_malloc (sizeof (struct TestGetContext));
+ test_get->uid = i + j * num_peers;
+ test_get->daemon = GNUNET_TESTING_daemon_get (pg, j);
+ GNUNET_CONTAINER_DLL_insert (all_gets_head, all_gets_tail, test_get);
+ test_get->task = GNUNET_SCHEDULER_add_now (&do_get, test_get);
+ }
}
@@ -692,15 +664,12 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
outstanding_puts--;
puts_completed++;
GNUNET_SCHEDULER_cancel (test_put->task);
- test_put->task =
- GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
+ test_put->task = GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
if (puts_completed != num_peers * num_peers)
return;
-
+
GNUNET_assert (outstanding_puts == 0);
- GNUNET_SCHEDULER_add_delayed (START_DELAY,
- &start_gets,
- NULL);
+ GNUNET_SCHEDULER_add_delayed (START_DELAY, &start_gets, NULL);
}
@@ -717,7 +686,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
test_put->task = GNUNET_SCHEDULER_NO_TASK;
if (outstanding_puts > MAX_OUTSTANDING_PUTS)
{
- test_put->task = GNUNET_SCHEDULER_add_delayed (PUT_DELAY, &do_put, test_put);
+ test_put->task =
+ GNUNET_SCHEDULER_add_delayed (PUT_DELAY, &do_put, test_put);
return;
}
memset (data, test_put->uid, sizeof (data));
@@ -726,46 +696,43 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_assert (test_put->dht_handle != NULL);
outstanding_puts++;
#if VERBOSE > 2
- fprintf (stderr, "PUT %u at `%s'\n",
- test_put->uid,
- GNUNET_i2s (&test_put->daemon->id));
+ fprintf (stderr, "PUT %u at `%s'\n", test_put->uid,
+ GNUNET_i2s (&test_put->daemon->id));
#endif
- GNUNET_DHT_put (test_put->dht_handle, &key, 1,
- route_option, GNUNET_BLOCK_TYPE_TEST, sizeof (data), data,
+ GNUNET_DHT_put (test_put->dht_handle, &key, 1, 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->task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &put_disconnect_task, test_put);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &put_disconnect_task, test_put);
}
static void
run_dht_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
+{
unsigned long long i;
struct TestPutContext *test_put;
#if PATH_TRACKING
- route_option = GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
+ route_option =
+ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
#else
route_option = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
#endif
die_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
- "from setup puts/gets");
- fprintf (stderr,
- "Issuing %llu PUTs (one per peer)\n",
- (unsigned long long) (num_peers * num_peers));
+ GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
+ "from setup puts/gets");
+ fprintf (stderr, "Issuing %llu PUTs (one per peer)\n",
+ (unsigned long long) (num_peers * num_peers));
for (i = 0; i < num_peers * num_peers; i++)
{
test_put = GNUNET_malloc (sizeof (struct TestPutContext));
test_put->uid = i;
- test_put->daemon = GNUNET_TESTING_daemon_get (pg, i % num_peers);
+ test_put->daemon = GNUNET_TESTING_daemon_get (pg, i % num_peers);
test_put->task = GNUNET_SCHEDULER_add_now (&do_put, test_put);
- GNUNET_CONTAINER_DLL_insert (all_puts_head,
- all_puts_tail,
- test_put);
+ GNUNET_CONTAINER_DLL_insert (all_puts_head, all_puts_tail, test_put);
}
}
@@ -782,17 +749,13 @@ startup_done (void *cls, const char *emsg)
{
if (emsg != NULL)
{
- fprintf (stderr,
- "Failed to setup topology: %s\n",
- emsg);
- die_task =
- GNUNET_SCHEDULER_add_now (&end_badly,
- "topology setup failed");
+ fprintf (stderr, "Failed to setup topology: %s\n", emsg);
+ die_task = GNUNET_SCHEDULER_add_now (&end_badly, "topology setup failed");
return;
}
die_task =
- GNUNET_SCHEDULER_add_delayed (START_DELAY, &run_dht_test,
- "from setup puts/gets");
+ GNUNET_SCHEDULER_add_delayed (START_DELAY, &run_dht_test,
+ "from setup puts/gets");
}
@@ -813,13 +776,8 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
&num_peers))
num_peers = DEFAULT_NUM_PEERS;
- pg = GNUNET_TESTING_peergroup_start (cfg,
- num_peers,
- TIMEOUT,
- NULL,
- &startup_done,
- NULL,
- NULL);
+ pg = GNUNET_TESTING_peergroup_start (cfg, num_peers, TIMEOUT, NULL,
+ &startup_done, NULL, NULL);
GNUNET_assert (NULL != pg);
}
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c
index 8947739c4..04198b48b 100644
--- a/src/dht/test_dht_twopeer.c
+++ b/src/dht/test_dht_twopeer.c
@@ -138,9 +138,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
const char *emsg = cls;
- fprintf (stderr,
- "Error: %s\n",
- emsg);
+ fprintf (stderr, "Error: %s\n", emsg);
if (curr_get_ctx.retry_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (curr_get_ctx.retry_task);
@@ -175,10 +173,10 @@ static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
struct PeerGetContext *get_context = cls;
@@ -257,9 +255,9 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_BLOCK_TYPE_DHT_HELLO,
- &get_context->peer->hashPubKey,
- 1, GNUNET_DHT_RO_NONE, NULL,
- 0, &get_result_iterator, get_context);
+ &get_context->peer->hashPubKey, 1,
+ GNUNET_DHT_RO_NONE, NULL, 0, &get_result_iterator,
+ get_context);
}
@@ -292,9 +290,9 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5),
GNUNET_BLOCK_TYPE_DHT_HELLO,
- &get_context->peer->hashPubKey,
- 1, GNUNET_DHT_RO_FIND_PEER, NULL,
- 0, &get_result_iterator, get_context);
+ &get_context->peer->hashPubKey, 1,
+ GNUNET_DHT_RO_FIND_PEER, NULL, 0,
+ &get_result_iterator, get_context);
}
@@ -335,8 +333,8 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
#endif
GNUNET_SCHEDULER_cancel (die_task);
die_task =
- GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &end_badly, "Timeout trying to GET");
+ GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
+ "Timeout trying to GET");
curr_get_ctx.dht_handle = peer1dht;
curr_get_ctx.peer = &peer2id;
@@ -383,9 +381,7 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
{
if (emsg != NULL)
{
- fprintf (stderr,
- "Failed to start daemon: `%s'\n",
- emsg);
+ fprintf (stderr, "Failed to start daemon: `%s'\n", emsg);
return;
}
GNUNET_assert (id != NULL);
diff --git a/src/dht/test_dht_twopeer_get_put.c b/src/dht/test_dht_twopeer_get_put.c
index 2a79c9ffb..d0da778ea 100644
--- a/src/dht/test_dht_twopeer_get_put.c
+++ b/src/dht/test_dht_twopeer_get_put.c
@@ -215,12 +215,11 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_size,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_size,
- enum GNUNET_BLOCK_Type type, size_t size,
- const void *result_data)
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_size,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int put_path_size, 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 */
@@ -279,8 +278,8 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
#else
GNUNET_BLOCK_TYPE_TEST,
#endif
- &key, 1, GNUNET_DHT_RO_NONE,
- NULL, 0, &get_result_iterator, NULL);
+ &key, 1, GNUNET_DHT_RO_NONE, NULL, 0,
+ &get_result_iterator, NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10), &do_put, NULL);
}
@@ -313,10 +312,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, 1, 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, 1, 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
diff --git a/src/dht/test_dht_twopeer_path_tracking.c b/src/dht/test_dht_twopeer_path_tracking.c
index f2d86e38e..61a3df0a4 100644
--- a/src/dht/test_dht_twopeer_path_tracking.c
+++ b/src/dht/test_dht_twopeer_path_tracking.c
@@ -191,10 +191,10 @@ static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
GNUNET_HashCode original_key; /* Key data was stored data under */
char original_data[4]; /* Made up data that was stored */
@@ -220,14 +220,14 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
if (put_path != NULL)
{
fprintf (stderr, "PUT Path: ");
- for (i = 0; i<put_path_length; i++)
+ for (i = 0; i < put_path_length; i++)
fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&put_path[i]));
fprintf (stderr, "\n");
}
if (get_path != NULL)
{
fprintf (stderr, "GET Path: ");
- for (i = 0; i<get_path_length; i++)
+ for (i = 0; i < get_path_length; i++)
fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (&get_path[i]));
fprintf (stderr, "\n");
}
@@ -256,9 +256,9 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
memset (&key, 42, sizeof (GNUNET_HashCode)); /* Set the key to the same thing as when data was inserted */
global_get_handle =
GNUNET_DHT_get_start (peer2dht, GNUNET_TIME_relative_get_forever (),
- GNUNET_BLOCK_TYPE_TEST, &key,
- 1, GNUNET_DHT_RO_RECORD_ROUTE,
- NULL, 0, &get_result_iterator, NULL);
+ GNUNET_BLOCK_TYPE_TEST, &key, 1,
+ GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0,
+ &get_result_iterator, NULL);
}
/**
@@ -274,10 +274,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, 1,
- 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);
+ GNUNET_DHT_put (peer1dht, &key, 1, 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);
}
/**
diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c
index 44009c257..275a01a32 100644
--- a/src/dht/test_dht_twopeer_put_get.c
+++ b/src/dht/test_dht_twopeer_put_get.c
@@ -207,11 +207,10 @@ static void
get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_size,
+ unsigned int get_path_size,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_size,
- enum GNUNET_BLOCK_Type type, size_t size,
- const void *result_data)
+ unsigned int put_path_size, 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 */
@@ -254,10 +253,9 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
memset (&key, 42, sizeof (GNUNET_HashCode)); /* Set the key to the same thing as when data was inserted */
global_get_handle =
- GNUNET_DHT_get_start (peer2dht, GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_BLOCK_TYPE_TEST,
- &key, 1, GNUNET_DHT_RO_NONE,
- NULL, 0, &get_result_iterator, NULL);
+ GNUNET_DHT_get_start (peer2dht, GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_BLOCK_TYPE_TEST, &key, 1, GNUNET_DHT_RO_NONE,
+ NULL, 0, &get_result_iterator, NULL);
}
@@ -274,10 +272,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, 1, 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, 1, GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST,
+ sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS,
+ GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL);
}
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 7d86fc24c..60745070c 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -1349,13 +1349,13 @@ send_message_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*/
static uint32_t
get_atsi_distance (const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
unsigned int i;
- for (i=0;i<atsi_count;i++)
+ for (i = 0; i < atsi_count; i++)
if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
- return ntohl (atsi->value);
+ return ntohl (atsi->value);
/* FIXME: we do not have distance data? Assume direct neighbor. */
return DIRECT_NEIGHBOR_COST;
}
@@ -1369,14 +1369,14 @@ get_atsi_distance (const struct GNUNET_ATS_Information *atsi,
*/
static struct GNUNET_TIME_Relative
get_atsi_latency (const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
unsigned int i;
- for (i=0;i<atsi_count;i++)
+ for (i = 0; i < atsi_count; i++)
if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY)
return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
- ntohl (atsi->value));
+ ntohl (atsi->value));
GNUNET_break (0);
/* how can we not have latency data? */
return GNUNET_TIME_UNIT_SECONDS;
@@ -1398,7 +1398,7 @@ static int
handle_dv_data_message (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
const p2p_dv_MESSAGE_Data *incoming = (const p2p_dv_MESSAGE_Data *) message;
const struct GNUNET_MessageHeader *packed_message;
@@ -2076,14 +2076,13 @@ static int
handle_dv_gossip_message (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count);
+ unsigned int atsi_count);
static int
handle_dv_disconnect_message (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count);
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count);
/** End forward declarations **/
@@ -2658,10 +2657,10 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
atsi[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
atsi[1].value =
htonl ((uint32_t) referrer->pending_messages[i].
- latency.rel_value);
+ latency.rel_value);
handle_dv_data_message (NULL, &referrer->pending_messages[i].sender,
- referrer->pending_messages[i].message,
- atsi, 2);
+ referrer->pending_messages[i].message, atsi,
+ 2);
GNUNET_free (referrer->pending_messages[i].message);
referrer->pending_messages[i].sender_id = 0;
}
@@ -2732,9 +2731,8 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer,
static int
handle_dv_disconnect_message (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct DirectNeighbor *referrer;
struct DistantNeighbor *distant;
@@ -2784,7 +2782,7 @@ static int
handle_dv_gossip_message (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct DirectNeighbor *referrer;
p2p_dv_MESSAGE_NeighborInfo *enc_message =
@@ -3087,7 +3085,7 @@ process_peerinfo (void *cls, const struct GNUNET_PeerIdentity *peer,
static void
handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct DirectNeighbor *neighbor;
struct DistantNeighbor *about;
@@ -3294,8 +3292,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
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, GNUNET_NO,
- NULL, GNUNET_NO, core_handlers);
+ &handle_core_disconnect, NULL, GNUNET_NO, NULL,
+ GNUNET_NO, core_handlers);
if (coreAPI == NULL)
return;
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index 5e2a6bd6c..6b585f6cc 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -171,8 +171,8 @@ handle_dv_message_received (void *cls, struct GNUNET_PeerIdentity *sender,
plugin->env->receive (plugin->env->cls, sender,
(struct GNUNET_MessageHeader *) msg,
- (const struct GNUNET_ATS_Information *) &ats,
- 2, NULL, sender_address, sender_address_len);
+ (const struct GNUNET_ATS_Information *) &ats, 2, NULL,
+ sender_address, sender_address_len);
}
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index 82b3cb235..0a3bbaa51 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -596,8 +596,8 @@ connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer,
*/
pos->peer2handle =
GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2,
- &connect_notify_peer2, NULL, NULL,
- GNUNET_YES, NULL, GNUNET_YES, handlers);
+ &connect_notify_peer2, NULL, NULL, GNUNET_YES,
+ NULL, GNUNET_YES, handlers);
}
}
@@ -646,8 +646,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*/
pos->peer1handle =
GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
- &connect_notify_peer1, NULL, NULL, GNUNET_NO,
- NULL, GNUNET_NO, no_handlers);
+ &connect_notify_peer1, NULL, NULL, GNUNET_NO, NULL,
+ GNUNET_NO, no_handlers);
GNUNET_assert (pos->peer1handle != NULL);
@@ -936,8 +936,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
new_peer = GNUNET_malloc (sizeof (struct PeerContext));
new_peer->peer_handle =
- GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL,
- NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers);
+ GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL, NULL,
+ GNUNET_NO, NULL, GNUNET_NO, no_handlers);
new_peer->daemon = d;
new_peer->next = all_peers;
all_peers = new_peer;
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c
index ef3a57a87..47b8a1929 100644
--- a/src/fragmentation/fragmentation.c
+++ b/src/fragmentation/fragmentation.c
@@ -152,7 +152,7 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
size = ntohs (fc->msg->size);
if (bit == size / (fc->mtu - sizeof (struct FragmentHeader)))
fsize =
- (size % (fc->mtu - sizeof (struct FragmentHeader))) +
+ (size % (fc->mtu - sizeof (struct FragmentHeader))) +
sizeof (struct FragmentHeader);
else
fsize = fc->mtu;
diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c
index 8f0be87a5..1f7a1776a 100644
--- a/src/fragmentation/test_fragmentation.c
+++ b/src/fragmentation/test_fragmentation.c
@@ -65,8 +65,7 @@ static struct GNUNET_FRAGMENT_Context *frags[NUM_MSGS];
static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
static void
-do_shutdown (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
unsigned int i;
@@ -80,7 +79,7 @@ do_shutdown (void *cls,
continue;
GNUNET_FRAGMENT_context_destroy (frags[i]);
frags[i] = NULL;
- }
+ }
}
@@ -103,8 +102,7 @@ proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
fprintf (stderr, ".");
#endif
/* tolerate 10% loss, i.e. due to duplicate fragment IDs */
- if ( (total >= NUM_MSGS - (NUM_MSGS / 10)) &&
- (ret != 0) )
+ if ((total >= NUM_MSGS - (NUM_MSGS / 10)) && (ret != 0))
{
if (GNUNET_SCHEDULER_NO_TASK == shutdown_task)
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index ce4f189a9..bb84b948e 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -437,7 +437,7 @@ GNUNET_FS_directory_scanner_default (void *cls, struct GNUNET_FS_Handle *h,
*/
struct MetaValueInformation
{
-
+
/**
* Mime-type of data.
*/
@@ -481,21 +481,17 @@ struct MetaValueInformation
* used in the main libextractor library and yielding
* meta data).
* @param type libextractor-type describing the meta data
- * @param format basic format information about data
+ * @param format basic format information about data
* @param data_mime_type mime-type of data (not of the original file);
* can be NULL (if mime-type is not known)
* @param data actual meta-data found
* @param data_len number of bytes in data
* @return 0 to continue extracting / iterating
- */
+ */
static int
-update_metamap (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)
+update_metamap (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_MultiHashMap *map = cls;
GNUNET_HashCode key;
@@ -512,10 +508,10 @@ update_metamap (void *cls,
mvi->type = type;
mvi->format = format;
GNUNET_CONTAINER_multihashmap_put (map, &key, mvi,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
- mvi->frequency++;
- return 0;
+ mvi->frequency++;
+ return 0;
}
@@ -524,7 +520,7 @@ update_metamap (void *cls,
*/
struct KeywordInformation
{
-
+
/**
* Mime-type of keyword.
*/
@@ -581,37 +577,35 @@ struct EntryProcCls
* @param fi information for publishing the file
*/
static void
-dirproc_add (void *cls, const char *filename,
- struct GNUNET_FS_FileInformation *fi)
+dirproc_add (void *cls, const char *filename,
+ struct GNUNET_FS_FileInformation *fi)
{
struct EntryProcCls *dc = cls;
unsigned int i;
const char *kw;
struct KeywordInformation *ki;
GNUNET_HashCode key;
-
+
GNUNET_assert (fi->next == NULL);
GNUNET_assert (fi->dir == NULL);
fi->next = dc->entries;
dc->entries = fi;
dc->count++;
if (NULL != fi->meta)
- GNUNET_CONTAINER_meta_data_iterate (fi->meta,
- &update_metamap,
- dc->metamap);
- for (i=0;i<fi->keywords->data.ksk.keywordCount;i++)
+ GNUNET_CONTAINER_meta_data_iterate (fi->meta, &update_metamap, dc->metamap);
+ for (i = 0; i < fi->keywords->data.ksk.keywordCount; i++)
{
- kw = fi->keywords->data.ksk.keywords[i];
- GNUNET_CRYPTO_hash (kw, strlen(kw), &key);
+ kw = fi->keywords->data.ksk.keywords[i];
+ GNUNET_CRYPTO_hash (kw, strlen (kw), &key);
ki = GNUNET_CONTAINER_multihashmap_get (dc->keywordmap, &key);
if (ki == NULL)
{
ki = GNUNET_malloc (sizeof (struct KeywordInformation));
ki->keyword = &kw[1];
GNUNET_CONTAINER_multihashmap_put (dc->keywordmap, &key, ki,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
}
- ki->frequency++;
+ ki->frequency++;
}
}
@@ -633,7 +627,7 @@ struct ComputeDirectoryMetadataContext
/**
* Threshold to apply for adding meta data.
- */
+ */
unsigned int threshold;
};
@@ -650,29 +644,22 @@ struct ComputeDirectoryMetadataContext
* @return GNUNET_OK
*/
static int
-compute_directory_metadata (void *cls,
- const GNUNET_HashCode *key,
- void *value)
+compute_directory_metadata (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ComputeDirectoryMetadataContext *cdmc = cls;
struct MetaValueInformation *mvi = value;
- if (mvi->frequency > cdmc->threshold)
+ if (mvi->frequency > cdmc->threshold)
{
if (mvi->type != EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME)
- (void) GNUNET_CONTAINER_meta_data_insert (cdmc->meta,
- "<children>",
- mvi->type,
- mvi->format,
- mvi->mime_type,
- mvi->data,
- mvi->data_size);
- if ( (mvi->format == EXTRACTOR_METAFORMAT_UTF8) ||
- (mvi->format == EXTRACTOR_METAFORMAT_C_STRING) )
- GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk,
- mvi->data,
- GNUNET_NO);
- }
+ (void) GNUNET_CONTAINER_meta_data_insert (cdmc->meta, "<children>",
+ mvi->type, mvi->format,
+ mvi->mime_type, mvi->data,
+ mvi->data_size);
+ if ((mvi->format == EXTRACTOR_METAFORMAT_UTF8) ||
+ (mvi->format == EXTRACTOR_METAFORMAT_C_STRING))
+ GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk, mvi->data, GNUNET_NO);
+ }
GNUNET_free (mvi);
return GNUNET_OK;
}
@@ -680,7 +667,7 @@ compute_directory_metadata (void *cls,
/**
* Add keywords that occur in more than the threshold entries of the
- * directory to the directory itself.
+ * directory to the directory itself.
*
* @param cls the 'struct ComputeDirectoryMetadataContext'
* @param key unused
@@ -688,17 +675,13 @@ compute_directory_metadata (void *cls,
* @return GNUNET_OK
*/
static int
-compute_directory_keywords (void *cls,
- const GNUNET_HashCode *key,
- void *value)
+compute_directory_keywords (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ComputeDirectoryMetadataContext *cdmc = cls;
struct KeywordInformation *ki = value;
- if (ki->frequency > cdmc->threshold)
- (void) GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk,
- ki->keyword,
- GNUNET_NO);
+ if (ki->frequency > cdmc->threshold)
+ (void) GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk, ki->keyword, GNUNET_NO);
GNUNET_free (ki);
return GNUNET_OK;
}
@@ -751,36 +734,31 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h,
dc.metamap = GNUNET_CONTAINER_multihashmap_create (64);
dc.keywordmap = GNUNET_CONTAINER_multihashmap_create (64);
/* update children to point to directory and generate statistics
- on all meta data in children */
+ * on all meta data in children */
scanner (scanner_cls, h, filename, do_index, bo, &dirproc_add, &dc, emsg);
cdmc.meta = GNUNET_CONTAINER_meta_data_create ();
cdmc.ksk = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
cdmc.ksk->type = ksk;
- cdmc.threshold = 1 + dc.count / 2; /* 50% threshold for now */
+ cdmc.threshold = 1 + dc.count / 2; /* 50% threshold for now */
GNUNET_FS_meta_data_make_directory (cdmc.meta);
GNUNET_CONTAINER_multihashmap_iterate (dc.metamap,
- &compute_directory_metadata,
- &cdmc);
+ &compute_directory_metadata, &cdmc);
GNUNET_CONTAINER_multihashmap_iterate (dc.keywordmap,
- &compute_directory_keywords,
- &cdmc);
+ &compute_directory_keywords, &cdmc);
GNUNET_CONTAINER_multihashmap_destroy (dc.metamap);
GNUNET_CONTAINER_multihashmap_destroy (dc.keywordmap);
- GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk,
- GNUNET_FS_DIRECTORY_MIME,
- GNUNET_NO);
+ GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk, GNUNET_FS_DIRECTORY_MIME, GNUNET_NO);
cksk = GNUNET_FS_uri_ksk_canonicalize (cdmc.ksk);
/* remove keywords in children that are already in the
- parent */
+ * parent */
for (epos = dc.entries; NULL != epos; epos = epos->next)
{
- for (i=0;i<cksk->data.ksk.keywordCount;i++)
- {
- kw = cksk->data.ksk.keywords[i];
- GNUNET_FS_uri_ksk_remove_keyword (epos->keywords,
- &kw[1]);
- }
+ for (i = 0; i < cksk->data.ksk.keywordCount; i++)
+ {
+ kw = cksk->data.ksk.keywords[i];
+ GNUNET_FS_uri_ksk_remove_keyword (epos->keywords, &kw[1]);
+ }
}
ret =
GNUNET_FS_file_information_create_empty_directory (h, client_info, cksk,
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 2057a18f6..48fabc1fb 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -1033,9 +1033,8 @@ canonicalize_keyword (const char *in)
wpos++;
break;
default:
- if (isspace ((unsigned char) *rpos) ||
- isdigit ((unsigned char) *rpos) )
- break;
+ if (isspace ((unsigned char) *rpos) || isdigit ((unsigned char) *rpos))
+ break;
/* replace characters listed above with '_' */
*wpos = '_';
wpos++;
@@ -1073,24 +1072,19 @@ GNUNET_FS_uri_ksk_canonicalize (const struct GNUNET_FS_Uri *uri)
for (i = 0; i < kc; i++)
{
in = uri->data.ksk.keywords[i];
- GNUNET_FS_uri_ksk_add_keyword (ret,
- &in[1],
- (in[0] == '+') ? GNUNET_YES : GNUNET_NO);
+ GNUNET_FS_uri_ksk_add_keyword (ret, &in[1],
+ (in[0] == '+') ? GNUNET_YES : GNUNET_NO);
sb = GNUNET_strdup (&in[1]);
#define DELIMS " \\|\"'`/&@-_,.;!?+-*^$#~=[]{}()<>"
for (tok = strtok (sb, DELIMS); NULL != tok; tok = strtok (NULL, DELIMS))
#undef DELIMS
{
- if (strlen(tok) < 3)
- continue;
- GNUNET_FS_uri_ksk_add_keyword (ret,
- tok,
- GNUNET_NO);
+ if (strlen (tok) < 3)
+ continue;
+ GNUNET_FS_uri_ksk_add_keyword (ret, tok, GNUNET_NO);
cc = canonicalize_keyword (tok);
if (strlen (cc) > 2)
- GNUNET_FS_uri_ksk_add_keyword (ret,
- cc,
- GNUNET_NO);
+ GNUNET_FS_uri_ksk_add_keyword (ret, cc, GNUNET_NO);
}
GNUNET_free (sb);
}
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
index 9b3602d73..310c8a1ae 100644
--- a/src/fs/gnunet-fs.c
+++ b/src/fs/gnunet-fs.c
@@ -53,8 +53,7 @@ static int verbose;
* @param tc unused
*/
static void
-do_shutdown (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_FS_stop (fs);
fs = NULL;
@@ -70,18 +69,12 @@ do_shutdown (void *cls,
* @return GNUNET_OK to continue iteration
*/
static int
-print_indexed (void *cls, const char *filename,
- const GNUNET_HashCode * file_id)
+print_indexed (void *cls, const char *filename, const GNUNET_HashCode * file_id)
{
if (verbose)
- fprintf (stdout,
- "%s: %s\n",
- GNUNET_h2s (file_id),
- filename);
+ fprintf (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
else
- fprintf (stdout,
- "%s\n",
- filename);
+ fprintf (stdout, "%s\n", filename);
return GNUNET_OK;
}
@@ -100,18 +93,13 @@ run (void *cls, char *const *args, const char *cfgfile,
{
if (list_indexed_files)
{
- fs = GNUNET_FS_start (cfg,
- "gnunet-fs",
- NULL, NULL,
- GNUNET_FS_FLAGS_NONE);
+ fs = GNUNET_FS_start (cfg, "gnunet-fs", NULL, NULL, GNUNET_FS_FLAGS_NONE);
if (NULL == fs)
{
ret = 1;
return;
}
- GNUNET_FS_get_indexed_files (fs,
- &print_indexed, NULL,
- &do_shutdown, NULL);
+ GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL, &do_shutdown, NULL);
}
}
@@ -134,8 +122,7 @@ main (int argc, char *const *argv)
};
return (GNUNET_OK ==
GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]",
- gettext_noop
- ("Special file-sharing operations"),
+ gettext_noop ("Special file-sharing operations"),
options, &run, NULL)) ? ret : 1;
}
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 404993130..f588ee9c4 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -226,19 +226,20 @@ GSF_test_get_load_too_high_ (uint32_t priority)
*/
static void
update_latencies (const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
unsigned int i;
- for (i=0;i<atsi_count;i++)
+ for (i = 0; i < atsi_count; i++)
{
- if (ntohl(atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY)
+ if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY)
{
- GSF_avg_latency.rel_value = (GSF_avg_latency.rel_value * 31 + ntohl (atsi[i].value)) / 32;
+ GSF_avg_latency.rel_value =
+ (GSF_avg_latency.rel_value * 31 + ntohl (atsi[i].value)) / 32;
GNUNET_STATISTICS_set (GSF_stats,
- gettext_noop ("# running average P2P latency (ms)"),
- GSF_avg_latency.rel_value,
- GNUNET_NO);
+ gettext_noop
+ ("# running average P2P latency (ms)"),
+ GSF_avg_latency.rel_value, GNUNET_NO);
break;
}
}
@@ -261,7 +262,7 @@ static int
handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct GSF_ConnectedPeer *cp;
@@ -294,13 +295,11 @@ consider_request_for_forwarding (void *cls,
{
struct GSF_PendingRequest *pr = cls;
- if (GNUNET_YES !=
- GSF_pending_request_test_target_ (pr,
- peer))
+ if (GNUNET_YES != GSF_pending_request_test_target_ (pr, peer))
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# Loopback routes suppressed"), 1,
- GNUNET_NO);
+ gettext_noop ("# Loopback routes suppressed"), 1,
+ GNUNET_NO);
return;
}
GSF_plan_add_ (cp, pr);
@@ -343,7 +342,7 @@ static int
handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct GSF_PendingRequest *pr;
@@ -475,13 +474,11 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key,
struct GNUNET_PeerIdentity pid;
GSF_connected_peer_get_identity_ (cp, &pid);
- if (GNUNET_YES !=
- GSF_pending_request_test_target_ (pr,
- &pid))
+ if (GNUNET_YES != GSF_pending_request_test_target_ (pr, &pid))
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# Loopback routes suppressed"), 1,
- GNUNET_NO);
+ gettext_noop ("# Loopback routes suppressed"), 1,
+ GNUNET_NO);
return GNUNET_YES;
}
GSF_plan_add_ (cp, pr);
@@ -500,7 +497,7 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key,
static void
peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct GSF_ConnectedPeer *cp;
@@ -568,9 +565,8 @@ main_init (struct GNUNET_SERVER_Handle *server,
GSF_core = GNUNET_CORE_connect (GSF_cfg, 2, /* larger? */
NULL, &peer_init_handler,
&peer_connect_handler,
- &GSF_peer_disconnect_handler_,
- NULL, GNUNET_NO,
- NULL, GNUNET_NO, p2p_handlers);
+ &GSF_peer_disconnect_handler_, NULL,
+ GNUNET_NO, NULL, GNUNET_NO, p2p_handlers);
if (NULL == GSF_core)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 859d9275f..d4c81d509 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -332,15 +332,14 @@ get_trust_filename (const struct GNUNET_PeerIdentity *id)
* @return connection latency
*/
static struct GNUNET_TIME_Relative
-get_latency (const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+get_latency (const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
{
unsigned int i;
- for (i=0;i<atsi_count;i++)
+ for (i = 0; i < atsi_count; i++)
if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DELAY)
return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
- ntohl (atsi->value));
+ ntohl (atsi->value));
return GNUNET_TIME_UNIT_SECONDS;
}
@@ -354,8 +353,7 @@ get_latency (const struct GNUNET_ATS_Information *atsi,
*/
static void
update_atsi (struct GSF_ConnectedPeer *cp,
- const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
{
struct GNUNET_TIME_Relative latency;
@@ -402,7 +400,7 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf);
*/
static void
ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
- int32_t amount, struct GNUNET_TIME_Relative res_delay);
+ int32_t amount, struct GNUNET_TIME_Relative res_delay);
/**
@@ -425,11 +423,9 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
if (0 != cp->inc_preference)
{
- GNUNET_ATS_change_preference (ats,
- &target,
- GNUNET_ATS_PREFERENCE_BANDWIDTH,
- (double) cp->inc_preference,
- GNUNET_ATS_PREFERENCE_END);
+ GNUNET_ATS_change_preference (ats, &target, GNUNET_ATS_PREFERENCE_BANDWIDTH,
+ (double) cp->inc_preference,
+ GNUNET_ATS_PREFERENCE_END);
cp->inc_preference = 0;
}
@@ -442,9 +438,8 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
/* reservation already done! */
pth->was_reserved = GNUNET_YES;
cp->rc =
- GNUNET_ATS_reserve_bandwidth (ats, &target,
- DBLOCK_SIZE,
- &ats_reserve_callback, cp);
+ GNUNET_ATS_reserve_bandwidth (ats, &target, DBLOCK_SIZE,
+ &ats_reserve_callback, cp);
}
GNUNET_assert (pth->cth == NULL);
pth->cth_in_progress++;
@@ -525,9 +520,8 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_PEER_resolve (cp->ppd.pid, &target);
cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK;
cp->rc =
- GNUNET_ATS_reserve_bandwidth (ats, &target,
- DBLOCK_SIZE,
- &ats_reserve_callback, cp);
+ GNUNET_ATS_reserve_bandwidth (ats, &target, DBLOCK_SIZE,
+ &ats_reserve_callback, cp);
}
@@ -543,15 +537,14 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*/
static void
ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
- int32_t amount, struct GNUNET_TIME_Relative res_delay)
+ int32_t amount, struct GNUNET_TIME_Relative res_delay)
{
struct GSF_ConnectedPeer *cp = cls;
struct GSF_PeerTransmitHandle *pth;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Reserved %d bytes / need to wait %llu ms for reservation\n",
- (int) amount,
- (unsigned long long) res_delay.rel_value);
+ "Reserved %d bytes / need to wait %llu ms for reservation\n",
+ (int) amount, (unsigned long long) res_delay.rel_value);
cp->rc = NULL;
if (0 == amount)
{
@@ -587,22 +580,20 @@ ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
struct GSF_ConnectedPeer *
GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
struct GSF_ConnectedPeer *cp;
char *fn;
uint32_t trust;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connected to peer %s\n",
- GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n",
+ GNUNET_i2s (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->rc =
- GNUNET_ATS_reserve_bandwidth (ats, peer,
- DBLOCK_SIZE,
- &ats_reserve_callback, cp);
+ GNUNET_ATS_reserve_bandwidth (ats, peer, DBLOCK_SIZE,
+ &ats_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))))
@@ -613,11 +604,9 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey,
cp,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- GNUNET_STATISTICS_set (GSF_stats,
- gettext_noop
- ("# peers connected"),
- GNUNET_CONTAINER_multihashmap_size (cp_map),
- GNUNET_NO);
+ GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"),
+ GNUNET_CONTAINER_multihashmap_size (cp_map),
+ GNUNET_NO);
update_atsi (cp, atsi, atsi_count);
GSF_push_start_ (cp);
return cp;
@@ -681,9 +670,8 @@ int
GSF_handle_p2p_migration_stop_ (void *cls,
const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count)
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count)
{
struct GSF_ConnectedPeer *cp;
const struct MigrationStopMessage *msm;
@@ -697,9 +685,8 @@ GSF_handle_p2p_migration_stop_ (void *cls,
return GNUNET_OK;
}
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- ("# migration stop messages received"),
- 1, GNUNET_NO);
+ gettext_noop ("# migration stop messages received"),
+ 1, GNUNET_NO);
bt = GNUNET_TIME_relative_ntoh (msm->duration);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Migration of content to peer `%s' blocked for %llu ms\n"),
@@ -841,8 +828,8 @@ get_randomized_delay ()
ret =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
GNUNET_CRYPTO_random_u32
- (GNUNET_CRYPTO_QUALITY_WEAK,
- 2 * GSF_avg_latency.rel_value + 1));
+ (GNUNET_CRYPTO_QUALITY_WEAK,
+ 2 * GSF_avg_latency.rel_value + 1));
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
("# artificial delays introduced (ms)"),
@@ -1179,7 +1166,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
return NULL;
}
if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
- cp = GSF_peer_get_ ((const struct GNUNET_PeerIdentity*) &opt[bits++]);
+ cp = GSF_peer_get_ ((const struct GNUNET_PeerIdentity *) &opt[bits++]);
else
cp = cps;
if (cp == NULL)
@@ -1323,9 +1310,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
0) ? (const char *) &opt[bits] : NULL,
bfsize, ntohl (gm->filter_mutator),
1 /* anonymity */ ,
- (uint32_t) priority, ttl, spid,
- GNUNET_PEER_intern (other),
- NULL, 0, /* replies_seen */
+ (uint32_t) priority, ttl, spid, GNUNET_PEER_intern (other), NULL, 0, /* replies_seen */
&handle_p2p_reply, peerreq);
GNUNET_assert (NULL != pr);
peerreq->pr = pr;
@@ -1547,11 +1532,9 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer)
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (cp_map,
&peer->hashPubKey, cp));
- GNUNET_STATISTICS_set (GSF_stats,
- gettext_noop
- ("# peers connected"),
- GNUNET_CONTAINER_multihashmap_size (cp_map),
- GNUNET_NO);
+ GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"),
+ GNUNET_CONTAINER_multihashmap_size (cp_map),
+ GNUNET_NO);
if (NULL != cp->migration_pth)
{
GSF_peer_transmit_cancel_ (cp->migration_pth);
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h
index 8923513c7..a2cc5232c 100644
--- a/src/fs/gnunet-service-fs_cp.h
+++ b/src/fs/gnunet-service-fs_cp.h
@@ -174,7 +174,7 @@ struct GSF_PeerTransmitHandle;
struct GSF_ConnectedPeer *
GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count);
+ unsigned int atsi_count);
/**
@@ -270,9 +270,8 @@ int
GSF_handle_p2p_migration_stop_ (void *cls,
const struct GNUNET_PeerIdentity *other,
const struct GNUNET_MessageHeader *message,
- const struct GNUNET_ATS_Information
- *atsi,
- unsigned int atsi_count);
+ const struct GNUNET_ATS_Information *atsi,
+ unsigned int atsi_count);
/**
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index 5978e4d66..41a40e125 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -538,13 +538,12 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, uint32_t size,
odb = (const struct OnDemandBlock *) data;
off = GNUNET_ntohll (odb->offset);
fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id);
- if ( (NULL == fn) ||
- (0 != ACCESS (fn, R_OK)) )
+ if ((NULL == fn) || (0 != ACCESS (fn, R_OK)))
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# index blocks removed: original file inaccessible"),
- 1,
- GNUNET_YES);
+ gettext_noop
+ ("# index blocks removed: original file inaccessible"),
+ 1, GNUNET_YES);
GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1,
GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL);
return GNUNET_SYSERR;
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index 9f284ed8f..30a7f57d6 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -375,7 +375,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
ntohl (sm->anonymity_level),
0 /* priority */ ,
0 /* ttl */ ,
- 0 /* sender PID */ , 0 /* origin PID */,
+ 0 /* sender PID */ ,
+ 0 /* origin PID */ ,
(const GNUNET_HashCode *) &sm[1], sc,
&client_response_handler, cr);
return cr->pr;
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c
index 088a3dc11..41dd61a64 100644
--- a/src/fs/gnunet-service-fs_pe.c
+++ b/src/fs/gnunet-service-fs_pe.c
@@ -263,22 +263,25 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
if (rp->transmission_counter < 8)
delay =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- rp->transmission_counter);
+ rp->transmission_counter);
else if (rp->transmission_counter < 32)
delay =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- 8 + (1LL << (rp->transmission_counter - 8)));
+ 8 +
+ (1LL << (rp->transmission_counter - 8)));
else
- delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- 8 + (1LL << 24));
- delay.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- delay.rel_value + 1);
+ delay =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
+ 8 + (1LL << 24));
+ delay.rel_value =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ delay.rel_value + 1);
if (rp->transmission_counter != 0)
delay.rel_value += TTL_DECREMENT;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Considering (re)transmission number %u in %llu ms\n",
- (unsigned int) rp->transmission_counter,
- (unsigned long long) delay.rel_value);
+ "Considering (re)transmission number %u in %llu ms\n",
+ (unsigned int) rp->transmission_counter,
+ (unsigned long long) delay.rel_value);
rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay);
#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -295,9 +298,9 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp,
rp->earliest_transmission.abs_value);
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map,
- get_rp_key (rp),
- rp));
+ GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map,
+ get_rp_key (rp),
+ rp));
if (GNUNET_SCHEDULER_NO_TASK != pp->task)
GNUNET_SCHEDULER_cancel (pp->task);
pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
@@ -351,8 +354,9 @@ transmit_message_callback (void *cls, size_t buf_size, void *buf)
/* failed, try again... */
pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# transmission failed (core has no bandwidth)"), 1,
- GNUNET_NO);
+ gettext_noop
+ ("# transmission failed (core has no bandwidth)"),
+ 1, GNUNET_NO);
return 0;
}
rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap);
@@ -433,22 +437,17 @@ schedule_peer_transmission (void *cls,
#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sleeping for %llu ms before retrying requests on plan %p.\n",
- (unsigned long long)
- delay.rel_value, pp);
+ (unsigned long long) delay.rel_value, pp);
#endif
- GNUNET_STATISTICS_set (GSF_stats,
- gettext_noop ("# delay heap timeout"),
- delay.rel_value,
- GNUNET_NO);
-
+ GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout"),
+ delay.rel_value, GNUNET_NO);
+
pp->task =
- GNUNET_SCHEDULER_add_delayed (delay,
- &schedule_peer_transmission, pp);
+ GNUNET_SCHEDULER_add_delayed (delay, &schedule_peer_transmission, pp);
return;
}
- GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# query plans executed"), 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plans executed"),
+ 1, GNUNET_NO);
/* process from priority heap */
rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap);
#if DEBUG_FS > 1
@@ -488,9 +487,7 @@ struct MergeContext
* GNUNET_NO if not (merge success)
*/
static int
-merge_pr (void *cls,
- const GNUNET_HashCode *query,
- void *element)
+merge_pr (void *cls, const GNUNET_HashCode * query, void *element)
{
struct MergeContext *mpr = cls;
struct GSF_RequestPlan *rp = element;
@@ -550,8 +547,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
if (NULL == pp)
{
pp = GNUNET_malloc (sizeof (struct PeerPlan));
- pp->plan_map =
- GNUNET_CONTAINER_multihashmap_create (128);
+ pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128);
pp->priority_heap =
GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX);
pp->delay_heap =
@@ -563,13 +559,13 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
mpc.merged = GNUNET_NO;
mpc.pr = pr;
GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map,
- &GSF_pending_request_get_data_ (pr)->query,
- &merge_pr, &mpc);
+ &GSF_pending_request_get_data_
+ (pr)->query, &merge_pr, &mpc);
if (mpc.merged != GNUNET_NO)
return;
GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map,
- &GSF_pending_request_get_data_ (pr)->query,
- &merge_pr, &mpc);
+ &GSF_pending_request_get_data_
+ (pr)->query, &merge_pr, &mpc);
if (mpc.merged != GNUNET_NO)
return;
plan_count++;
@@ -592,10 +588,9 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl);
rp->pp = pp;
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_put (pp->plan_map,
- get_rp_key (rp),
- rp,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ GNUNET_CONTAINER_multihashmap_put (pp->plan_map,
+ get_rp_key (rp), rp,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
plan (pp, rp);
}
@@ -632,9 +627,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->priority_heap)))
{
GNUNET_break (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (pp->plan_map,
- get_rp_key (rp),
- rp));
+ GNUNET_CONTAINER_multihashmap_remove (pp->plan_map,
+ get_rp_key (rp), rp));
while (NULL != (prl = rp->prl_head))
{
GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl);
@@ -649,9 +643,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->delay_heap)))
{
GNUNET_break (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (pp->plan_map,
- get_rp_key (rp),
- rp));
+ GNUNET_CONTAINER_multihashmap_remove (pp->plan_map,
+ get_rp_key (rp), rp));
while (NULL != (prl = rp->prl_head))
{
GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl);
@@ -695,9 +688,10 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr)
GNUNET_CONTAINER_heap_remove_node (rp->hn);
plan_count--;
GNUNET_break (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (rp->pp->plan_map,
- &GSF_pending_request_get_data_ (rpr->prl->pr)->query,
- rp));
+ GNUNET_CONTAINER_multihashmap_remove (rp->pp->plan_map,
+ &GSF_pending_request_get_data_
+ (rpr->prl->pr)->query,
+ rp));
GNUNET_free (rp);
}
GNUNET_free (rpr->prl);
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 63ae3a75f..ac183a980 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -216,10 +216,10 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr)
if (pr->bf != NULL)
GNUNET_CONTAINER_bloomfilter_free (pr->bf);
pr->mingle =
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
- pr->bf = GNUNET_BLOCK_construct_bloomfilter (pr->mingle,
- pr->replies_seen,
- pr->replies_seen_count);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
+ pr->bf =
+ GNUNET_BLOCK_construct_bloomfilter (pr->mingle, pr->replies_seen,
+ pr->replies_seen_count);
}
@@ -319,7 +319,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
if (NULL != bf_data)
{
pr->bf =
- GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, GNUNET_CONSTANTS_BLOOMFILTER_K);
+ GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size,
+ GNUNET_CONSTANTS_BLOOMFILTER_K);
pr->mingle = mingle;
}
else if ((replies_seen_count > 0) &&
@@ -433,17 +434,16 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr,
pr->mingle =
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX);
pr->bf =
- GNUNET_BLOCK_construct_bloomfilter (pr->mingle,
- replies_seen,
- replies_seen_count);
- }
+ GNUNET_BLOCK_construct_bloomfilter (pr->mingle, replies_seen,
+ replies_seen_count);
+ }
else
{
for (i = 0; i < pr->replies_seen_count; i++)
- {
- GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash);
- GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash);
- }
+ {
+ GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash);
+ GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash);
+ }
}
}
}
@@ -970,10 +970,10 @@ static void
handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data)
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data)
{
struct GSF_PendingRequest *pr = cls;
struct ProcessReplyClosure prq;
@@ -1051,11 +1051,10 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
pr->gh =
GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL,
pr->public_data.type, &pr->public_data.query,
- 5 /* DEFAULT_GET_REPLICATION */,
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- /* FIXME: can no longer pass pr->bf/pr->mingle... */
- xquery, xquery_size, &handle_dht_reply,
- pr);
+ 5 /* DEFAULT_GET_REPLICATION */ ,
+ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
+ /* FIXME: can no longer pass pr->bf/pr->mingle... */
+ xquery, xquery_size, &handle_dht_reply, pr);
}
@@ -1231,16 +1230,17 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
/* queue priority */ ,
(0 !=
(GSF_PRO_PRIORITY_UNLIMITED &
- pr->public_data.options)) ? UINT_MAX : datastore_queue_size
+ pr->public_data.options)) ? UINT_MAX :
+ datastore_queue_size
/* max queue size */ ,
GNUNET_TIME_UNIT_FOREVER_REL,
&process_local_reply, pr);
if (NULL != pr->qe)
- return; /* we're done */
+ return; /* we're done */
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- ("# Datastore lookups concluded (error queueing)"),
- 1, GNUNET_NO);
+ gettext_noop
+ ("# Datastore lookups concluded (error queueing)"),
+ 1, GNUNET_NO);
goto check_error_and_continue;
}
old_rf = pr->public_data.results_found;
@@ -1270,7 +1270,8 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
/* queue priority */ ,
(0 !=
(GSF_PRO_PRIORITY_UNLIMITED &
- pr->public_data.options)) ? UINT_MAX : datastore_queue_size
+ pr->public_data.options)) ? UINT_MAX :
+ datastore_queue_size
/* max queue size */ ,
GNUNET_TIME_UNIT_FOREVER_REL,
&process_local_reply, pr);
@@ -1329,7 +1330,8 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
/* queue priority */ ,
(0 !=
(GSF_PRO_PRIORITY_UNLIMITED & pr->
- public_data.options)) ? UINT_MAX : datastore_queue_size
+ public_data.options)) ? UINT_MAX :
+ datastore_queue_size
/* max queue size */ ,
GNUNET_TIME_UNIT_FOREVER_REL,
&process_local_reply, pr);
@@ -1353,21 +1355,24 @@ check_error_and_continue:
/**
* Is the given target a legitimate peer for forwarding the given request?
- *
+ *
* @param pr request
* @param target
* @return GNUNET_YES if this request could be forwarded to the given peer
*/
int
GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
- const struct GNUNET_PeerIdentity *target)
+ const struct GNUNET_PeerIdentity *target)
{
struct GNUNET_PeerIdentity pi;
-
+
if (0 == pr->origin_pid)
return GNUNET_YES;
GNUNET_PEER_resolve (pr->origin_pid, &pi);
- return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES;
+ return (0 ==
+ memcmp (&pi, target,
+ sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :
+ GNUNET_YES;
}
@@ -1405,16 +1410,17 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
/* queue priority */ ,
(0 !=
(GSF_PRO_PRIORITY_UNLIMITED & pr->
- public_data.options)) ? UINT_MAX : datastore_queue_size
+ public_data.options)) ? UINT_MAX :
+ datastore_queue_size
/* max queue size */ ,
GNUNET_TIME_UNIT_FOREVER_REL,
&process_local_reply, pr);
if (NULL != pr->qe)
return;
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- ("# Datastore lookups concluded (error queueing)"),
- 1, GNUNET_NO);
+ gettext_noop
+ ("# Datastore lookups concluded (error queueing)"),
+ 1, GNUNET_NO);
GNUNET_SCHEDULER_cancel (pr->warn_task);
pr->warn_task = GNUNET_SCHEDULER_NO_TASK;
pr->llc_cont = NULL;
@@ -1566,10 +1572,8 @@ GSF_pending_request_init_ ()
"MAX_PENDING_REQUESTS");
}
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (GSF_cfg,
- "core",
- "TOTAL_QUOTA_OUT",
- &bps))
+ GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "core", "TOTAL_QUOTA_OUT",
+ &bps))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_
@@ -1578,9 +1582,10 @@ GSF_pending_request_init_ ()
bps = 65536;
}
/* queue size should be #queries we can have pending and satisfy within
- a carry interval: */
- datastore_queue_size = bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE;
-
+ * a carry interval: */
+ datastore_queue_size =
+ bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE;
+
active_to_migration =
GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING");
datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h
index 538a38248..00249afcf 100644
--- a/src/fs/gnunet-service-fs_pr.h
+++ b/src/fs/gnunet-service-fs_pr.h
@@ -359,14 +359,14 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
/**
* Is the given target a legitimate peer for forwarding the given request?
- *
+ *
* @param pr request
* @param target
* @return GNUNET_YES if this request could be forwarded to the given peer
*/
int
GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
- const struct GNUNET_PeerIdentity *target);
+ const struct GNUNET_PeerIdentity *target);
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c
index c029b4141..07d32ef31 100644
--- a/src/fs/gnunet-service-fs_put.c
+++ b/src/fs/gnunet-service-fs_put.c
@@ -161,9 +161,9 @@ process_dht_put_content (void *cls, const GNUNET_HashCode * key, size_t size,
"Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key),
type);
#endif
- GNUNET_DHT_put (GSF_dht, key, 5 /* DEFAULT_PUT_REPLICATION */,
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- type, size, data, expiration, GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_DHT_put (GSF_dht, key, 5 /* DEFAULT_PUT_REPLICATION */ ,
+ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, type, size, data,
+ expiration, GNUNET_TIME_UNIT_FOREVER_REL,
&delay_dht_put_blocks, po);
}
diff --git a/src/hello/hello.c b/src/hello/hello.c
index c7db77a18..a0c26d1ab 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -632,8 +632,8 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
static int
find_min_expire (void *cls, const char *tname,
- struct GNUNET_TIME_Absolute expiration, const void *addr,
- uint16_t addrlen)
+ struct GNUNET_TIME_Absolute expiration, const void *addr,
+ uint16_t addrlen)
{
struct GNUNET_TIME_Absolute *min = cls;
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 2ef807444..b0fb03e29 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -143,7 +143,7 @@ static int
advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
GNUNET_assert (NULL != client_adv_handler);
return (*client_adv_handler) (cls, peer, message, atsi, atsi_count);
@@ -161,7 +161,7 @@ advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
static void
connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
if (0 == memcmp (&me, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index ba5093779..350a0baee 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -1112,7 +1112,7 @@ task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
static void
handler_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
GNUNET_assert (stat_connection_count < UINT_MAX);
stat_connection_count++;
@@ -1152,7 +1152,7 @@ static int
handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
size_t size;
size_t uri_size;
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index a6d9c126c..69d83b4d4 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -367,7 +367,7 @@ adv_transmit_ready (void *cls, size_t size, void *buf)
static void
connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
size_t size;
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index bcb302978..cac2cc67a 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -97,8 +97,7 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*/
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
if (peer == NULL)
return;
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index dfeca8d57..670fecc76 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -299,7 +299,7 @@ static int
ad_arrive_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_ATS_Information *atsi,
- unsigned int atsi_count)
+ unsigned int atsi_count)
{
char *hostname;
char *expected_uri;
@@ -392,8 +392,8 @@ 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,
- GNUNET_NO, NULL, GNUNET_NO, learn_handlers);
+ GNUNET_CORE_connect (p->cfg, 1, 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);
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
index 18757a79e..5dce8df10 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
@@ -108,8 +108,7 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*/
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
{
if (peer == NULL)
return;
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index ed5631a33..ac963ce1d 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -49,14 +49,14 @@ enum GNUNET_ATS_Property
/**
* Actual traffic on this connection from the other peer to this peer.
- *
+ *
* Unit: [bytes/second]
*/
GNUNET_ATS_UTILIZATION_UP,
/**
* Actual traffic on this connection from this peer to the other peer.
- *
+ *
* Unit: [bytes/second]
*/
GNUNET_ATS_UTILIZATION_DOWN,
@@ -74,14 +74,14 @@ enum GNUNET_ATS_Property
* Dialup: 500
*/
GNUNET_ATS_QUALITY_NET_DELAY,
-
+
/**
* Distance on network layer (required for distance-vector routing).
*
* Unit: [DV-hops]
*/
GNUNET_ATS_QUALITY_NET_DISTANCE,
-
+
/**
* Network overhead on WAN (Wide-Area Network)
*
@@ -102,7 +102,7 @@ enum GNUNET_ATS_Property
* UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
*/
GNUNET_ATS_COST_WAN,
-
+
/**
* Network overhead on LAN (Local-Area Network)
*
@@ -123,7 +123,7 @@ enum GNUNET_ATS_Property
* UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
*/
GNUNET_ATS_COST_LAN,
-
+
/**
* Network overhead on WLAN (Wireless Local Area Network)
*
@@ -144,12 +144,8 @@ enum GNUNET_ATS_Property
* UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
*/
GNUNET_ATS_COST_WLAN
-
-
-
- /* Cost related values */
- /* =================== */
-
+ /* Cost related values */
+ /* =================== */
/**
* Volume based cost in financial units to transmit data
*
@@ -166,8 +162,7 @@ enum GNUNET_ATS_Property
* LAN: 0 [cent/MB]
* 2G : 10 [cent/MB]
*/
- // GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
-
+ // GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
/**
* Time based cost in financial units to transmit data
*
@@ -184,8 +179,7 @@ enum GNUNET_ATS_Property
* LAN : 0 [cent/h]
* Dialup: 10 [cent/h]
*/
- // GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
-
+ // GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
/**
* Computational costs
*
@@ -204,8 +198,7 @@ enum GNUNET_ATS_Property
* HTTPS with AES CBC-128: 5,279
* HTTPS with RC4-1024: 2,652
*/
- // GNUNET_ATS_COST_COMPUTATIONAL = 3,
-
+ // GNUNET_ATS_COST_COMPUTATIONAL = 3,
/**
* Energy consumption
*
@@ -233,8 +226,7 @@ enum GNUNET_ATS_Property
* WLAN: 89 (600 mW @ 802.11g /w 54 MBit/s)
* Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
*/
- // GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
-
+ // GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
/**
* Connect cost
* How many bytes are transmitted to initiate a new connection using
@@ -256,8 +248,7 @@ enum GNUNET_ATS_Property
* 2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTPS
*
* */
- // GNUNET_ATS_COST_CONNECT = 5,
-
+ // GNUNET_ATS_COST_CONNECT = 5,
/**
* Bandwidth cost
*
@@ -274,8 +265,7 @@ enum GNUNET_ATS_Property
* Dial-up: 8 (64 Kbit/s)
*
*/
- // GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
-
+ // GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
/**
* Network overhead
*
@@ -295,35 +285,28 @@ enum GNUNET_ATS_Property
* UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb]
* UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
*/
- // GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
-
-
- /* Quality related values */
- /* ====================== */
-
- /* Physical layer quality properties */
-
+ // GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
+ /* Quality related values */
+ /* ====================== */
+ /* Physical layer quality properties */
/**
* Signal strength on physical layer
*
* Unit: [dBm]
*/
- // GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025,
-
+ // GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025,
/**
* Collision rate on physical layer
*
* Unit: [B/s]
*/
- // GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026,
-
+ // GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026,
/**
* Error rate on physical layer
*
* Unit: [B/s]
*/
- // GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027,
-
+ // GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027,
/**
* Jitter
* Time variations of the delay
@@ -331,8 +314,7 @@ enum GNUNET_ATS_Property
*
* Unit: [ms]
*/
- // GNUNET_ATS_QUALITY_NET_JITTER = 1029,
-
+ // GNUNET_ATS_QUALITY_NET_JITTER = 1029,
/**
* Error rate on network layer
*
@@ -346,8 +328,7 @@ enum GNUNET_ATS_Property
* Note: This numbers are just assumptions as an example, not
* measured or somehow determined
*/
- // GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030,
-
+ // GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030,
/**
* Drop rate on network layer
* Bytes actively dismissed by a network component during transmission
@@ -363,8 +344,7 @@ enum GNUNET_ATS_Property
* Note: This numbers are just assumptions as an example, not
* measured or somehow determined
*/
- // GNUNET_ATS_QUALITY_NET_DROPRATE = 1031,
-
+ // GNUNET_ATS_QUALITY_NET_DROPRATE = 1031,
/**
* Loss rate on network layer
* Bytes lost during transmission
@@ -380,8 +360,7 @@ enum GNUNET_ATS_Property
* Note: This numbers are just assumptions as an example, not measured
* or somehow determined
*/
- // GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032,
-
+ // GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032,
/**
* Throughput on network layer
*
@@ -394,21 +373,17 @@ enum GNUNET_ATS_Property
* Dialup: 4
*
*/
- // GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033,
-
-
- /* Availability related values */
- /* =========================== */
-
+ // GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033,
+ /* Availability related values */
+ /* =========================== */
/**
* Is a peer reachable?
*/
- // GNUNET_ATS_AVAILABILITY_REACHABLE = 2048,
-
+ // GNUNET_ATS_AVAILABILITY_REACHABLE = 2048,
/**
* Is there a connection established to a peer using this transport
*/
- // GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
+ // GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
};
@@ -461,7 +436,7 @@ struct Session;
/**
* Signature of a function called by ATS with the current bandwidth
- * and address preferences as determined by ATS.
+ * and address preferences as determined by ATS.
*
* @param cls closure
* @param peer identity of the new peer
@@ -488,10 +463,9 @@ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
struct
GNUNET_BANDWIDTH_Value32NBO
bandwidth_in,
- const struct
- GNUNET_ATS_Information
- * ats,
- uint32_t ats_count);
+ const struct
+ GNUNET_ATS_Information *
+ ats, uint32_t ats_count);
/**
@@ -504,8 +478,8 @@ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
*/
struct GNUNET_ATS_SchedulingHandle *
GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ATS_AddressSuggestionCallback suggest_cb,
- void *suggest_cb_cls);
+ GNUNET_ATS_AddressSuggestionCallback suggest_cb,
+ void *suggest_cb_cls);
/**
@@ -549,9 +523,8 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
void
GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
- struct Session *session,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
const struct GNUNET_ATS_Information *ats,
uint32_t ats_count);
@@ -570,12 +543,10 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
*/
void
GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct Session *session,
- int in_use);
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session,
+ int in_use);
/**
* A session got destroyed, stop including it as a valid address.
@@ -590,10 +561,8 @@ GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
void
GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_PeerIdentity *peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct Session *session);
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, struct Session *session);
/* ******************************** Performance API ***************************** */
@@ -618,22 +587,20 @@ struct GNUNET_ATS_PerformanceHandle;
* @param ats_count number of performance records in 'ats'
*/
typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- const char *plugin_name,
- const void *plugin_addr,
- size_t plugin_addr_len,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_out,
- struct
- GNUNET_BANDWIDTH_Value32NBO
- bandwidth_in,
- const struct
- GNUNET_ATS_Information
- * ats,
- uint32_t ats_count);
+ const struct
+ GNUNET_PeerIdentity * peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ struct
+ GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct
+ GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in,
+ const struct
+ GNUNET_ATS_Information *
+ ats, uint32_t ats_count);
/**
@@ -646,8 +613,8 @@ typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
*/
struct GNUNET_ATS_PerformanceHandle *
GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- GNUNET_ATS_PeerInformationCallback infocb,
- void *infocb_cls);
+ GNUNET_ATS_PeerInformationCallback infocb,
+ void *infocb_cls);
/**
@@ -670,13 +637,10 @@ GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph);
* long should the client wait until re-trying?
*/
typedef void (*GNUNET_ATS_ReservationCallback) (void *cls,
- const struct
- GNUNET_PeerIdentity *
- peer,
- int32_t amount,
- struct
- GNUNET_TIME_Relative
- res_delay);
+ const struct GNUNET_PeerIdentity
+ * peer, int32_t amount,
+ struct GNUNET_TIME_Relative
+ res_delay);
@@ -702,10 +666,10 @@ struct GNUNET_ATS_ReservationContext;
*/
struct GNUNET_ATS_ReservationContext *
GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
- const struct GNUNET_PeerIdentity *peer,
- int32_t amount,
- GNUNET_ATS_ReservationCallback rcb,
- void *rcb_cls);
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount,
+ GNUNET_ATS_ReservationCallback rcb,
+ void *rcb_cls);
/**
@@ -714,8 +678,7 @@ GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
* @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
*/
void
-GNUNET_ATS_reserve_bandwidth_cancel (struct
- GNUNET_ATS_ReservationContext *rc);
+GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc);
@@ -734,7 +697,7 @@ enum GNUNET_ATS_PreferenceKind
* Change the peer's bandwidth value (value per byte of bandwidth in
* the goal function) to the given amount. The argument is followed
* by a double value giving the desired value (can be negative).
- * Preference changes are forgotten if peers disconnect.
+ * Preference changes are forgotten if peers disconnect.
*/
GNUNET_ATS_PREFERENCE_BANDWIDTH,
@@ -746,22 +709,20 @@ enum GNUNET_ATS_PreferenceKind
* the latency preferences.
*/
GNUNET_ATS_PREFERENCE_LATENCY
-
};
-
+
/**
* Change preferences for the given peer. Preference changes are forgotten if peers
* disconnect.
- *
+ *
* @param ph performance handle
* @param peer identifies the peer
* @param ... 0-terminated specification of the desired changes
*/
void
GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
- const struct GNUNET_PeerIdentity *peer,
- ...);
+ const struct GNUNET_PeerIdentity *peer, ...);
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 8e7a59c8b..5e6eca76c 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -238,8 +238,8 @@ GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
*/
struct GNUNET_CONTAINER_BloomFilter *
GNUNET_BLOCK_construct_bloomfilter (int32_t bf_mutator,
- const GNUNET_HashCode *seen_results,
- unsigned int seen_results_count);
+ const GNUNET_HashCode * seen_results,
+ unsigned int seen_results_count);
#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index a46badc74..08c1f96c9 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -167,9 +167,11 @@ typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind,
* Number of log calls to ignore.
*/
extern unsigned int skip_log;
+
#if !defined(GNUNET_CULL_LOGGING)
-int
-GNUNET_get_log_call_status (int caller_level, const char *comp, const char *file, const char *function, int line);
+int
+GNUNET_get_log_call_status (int caller_level, const char *comp,
+ const char *file, const char *function, int line);
#endif
/**
* Main log function.
@@ -214,7 +216,7 @@ GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...);
*/
void
GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
- const char *message, ...);
+ const char *message, ...);
#if !defined(GNUNET_CULL_LOGGING)
#define GNUNET_log_from(kind,comp,...) do { int log_line = __LINE__;\
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 24c9aa598..1f6c0f329 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -63,9 +63,8 @@ typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls,
const struct
GNUNET_PeerIdentity * peer,
const struct
- GNUNET_ATS_Information
- * atsi,
- unsigned int atsi_count);
+ GNUNET_ATS_Information * atsi,
+ unsigned int atsi_count);
/**
@@ -97,10 +96,8 @@ typedef int (*GNUNET_CORE_MessageCallback) (void *cls,
other,
const struct GNUNET_MessageHeader *
message,
- const struct
- GNUNET_ATS_Information *
- atsi,
- unsigned int atsi_count);
+ const struct GNUNET_ATS_Information
+ * atsi, unsigned int atsi_count);
/**
@@ -142,7 +139,8 @@ struct GNUNET_CORE_MessageHandler
*/
typedef void (*GNUNET_CORE_StartupCallback) (void *cls,
struct GNUNET_CORE_Handle * server,
- const struct GNUNET_PeerIdentity *my_identity);
+ const struct GNUNET_PeerIdentity *
+ my_identity);
/**
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index fcbc8df47..f047bd8f8 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -165,10 +165,10 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key,
typedef void (*GNUNET_DHT_GetIterator) (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
+ const struct GNUNET_PeerIdentity *
+ get_path, unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *
+ put_path, unsigned int put_path_length,
enum GNUNET_BLOCK_Type type,
size_t size, const void *data);
@@ -197,8 +197,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
struct GNUNET_TIME_Relative timeout,
enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key,
uint32_t desired_replication_level,
- enum GNUNET_DHT_RouteOption options,
- const void *xquery,
+ enum GNUNET_DHT_RouteOption options, const void *xquery,
size_t xquery_size, GNUNET_DHT_GetIterator iter,
void *iter_cls);
diff --git a/src/include/gnunet_mesh_service.h b/src/include/gnunet_mesh_service.h
index 0497cee2f..b9e95b46d 100644
--- a/src/include/gnunet_mesh_service.h
+++ b/src/include/gnunet_mesh_service.h
@@ -74,9 +74,8 @@ typedef int (*GNUNET_MESH_MessageCallback) (void *cls,
sender,
const struct GNUNET_MessageHeader *
message,
- const struct
- GNUNET_ATS_Information *
- atsi);
+ const struct GNUNET_ATS_Information
+ * atsi);
/**
@@ -208,8 +207,7 @@ typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls,
const struct GNUNET_PeerIdentity
* peer,
const struct
- GNUNET_ATS_Information
- * atsi);
+ GNUNET_ATS_Information * atsi);
diff --git a/src/include/gnunet_plugin_lib.h b/src/include/gnunet_plugin_lib.h
index ff795d975..387ca381c 100644
--- a/src/include/gnunet_plugin_lib.h
+++ b/src/include/gnunet_plugin_lib.h
@@ -89,9 +89,9 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg);
* of the library (same as what 'GNUNET_PLUGIN_load' would
* have returned for the given library name)
*/
-typedef void (*GNUNET_PLUGIN_LoaderCallback)(void *cls,
- const char *library_name,
- void *lib_ret);
+typedef void (*GNUNET_PLUGIN_LoaderCallback) (void *cls,
+ const char *library_name,
+ void *lib_ret);
/**
@@ -106,11 +106,9 @@ typedef void (*GNUNET_PLUGIN_LoaderCallback)(void *cls,
* @param cb function to call for each plugin found
* @param cb_cls closure for 'cb'
*/
-void
-GNUNET_PLUGIN_load_all (const char *basename,
- void *arg,
- GNUNET_PLUGIN_LoaderCallback cb,
- void *cb_cls);
+void
+GNUNET_PLUGIN_load_all (const char *basename, void *arg,
+ GNUNET_PLUGIN_LoaderCallback cb, void *cb_cls);
/**
diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h
index 5289a6270..c39349c92 100644
--- a/src/include/gnunet_server_lib.h
+++ b/src/include/gnunet_server_lib.h
@@ -489,8 +489,7 @@ GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc,
*/
void
GNUNET_SERVER_transmit_context_destroy (struct GNUNET_SERVER_TransmitContext
- *tc,
- int success);
+ *tc, int success);
/**
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 5a4996c3b..4efecc863 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -59,7 +59,7 @@ extern "C"
*/
int
GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
- unsigned long long *size);
+ unsigned long long *size);
/**
@@ -72,7 +72,7 @@ GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
*/
int
GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_size,
- struct GNUNET_TIME_Relative *rtime);
+ struct GNUNET_TIME_Relative *rtime);
/**
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index 2d6e515fa..de764e7a6 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -51,7 +51,7 @@ extern "C"
* @param peer (claimed) identity of the other peer
* @param message the message
* @param ats performance data
- * @param ats_count number of entries in ats
+ * @param ats_count number of entries in ats
*/
typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
const struct
@@ -60,8 +60,8 @@ typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
GNUNET_MessageHeader *
message,
const struct
- GNUNET_ATS_Information
- * ats, uint32_t ats_count);
+ GNUNET_ATS_Information * ats,
+ uint32_t ats_count);
/**
@@ -83,8 +83,8 @@ typedef void (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
const struct GNUNET_PeerIdentity
* peer,
const struct
- GNUNET_ATS_Information
- * ats, uint32_t ats_count);
+ GNUNET_ATS_Information * ats,
+ uint32_t ats_count);
/**
* Function called to notify transport users that another
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index c0a7852e0..a5113e52b 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -342,7 +342,7 @@ struct MeshPathInfo
* Path itself
*/
struct MeshPeerPath *path;
-
+
/**
* Position in peer's transmit queue
*/
@@ -479,7 +479,7 @@ static struct GNUNET_PeerIdentity my_full_id;
/**
* Own private key
*/
-static struct GNUNET_CRYPTO_RsaPrivateKey* my_private_key;
+static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
/**
* Own public key.
@@ -546,12 +546,9 @@ static int
announce_application (void *cls, const GNUNET_HashCode * key, void *value)
{
/* FIXME are hashes in multihash map equal on all aquitectures? */
- GNUNET_DHT_put (dht_handle,
- key,
- 10U,
+ GNUNET_DHT_put (dht_handle, key, 10U,
GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- GNUNET_BLOCK_TYPE_TEST,
+ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_BLOCK_TYPE_TEST,
sizeof (struct GNUNET_PeerIdentity),
(const char *) &my_full_id,
#if MESH_DEBUG
@@ -620,11 +617,10 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_DHT_put (dht_handle, /* DHT handle */
&my_full_id.hashPubKey, /* Key to use */
10U, /* Replication level */
- GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */
+ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */
GNUNET_BLOCK_TYPE_TEST, /* Block type */
- sizeof(my_full_id), /* Size of the data */
- (char *)&my_full_id, /* Data itself */
+ sizeof (my_full_id), /* Size of the data */
+ (char *) &my_full_id, /* Data itself */
GNUNET_TIME_absolute_get_forever (), /* Data expiration */
GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */
#if MESH_DEBUG_DHT
@@ -656,8 +652,8 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
const struct GNUNET_PeerIdentity *get_path,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type, size_t size, const void *data);
+ unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
+ size_t size, const void *data);
/******************************************************************************/
@@ -711,12 +707,12 @@ client_is_subscribed (uint16_t message_type, struct MeshClient *c)
* Allow a client to send more data after transmitting a multicast message
* which some neighbor has not yet accepted altough a reasonable time has
* passed.
- *
+ *
* @param cls Closure (DataDescriptor containing the task identifier)
* @param tc Task Context
*/
static void
-client_allow_send(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+client_allow_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct MeshDataDescriptor *info = cls;
@@ -728,7 +724,7 @@ client_allow_send(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
*(info->copies));
#endif
*(info->timeout_task) = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_SERVER_receive_done(info->client, GNUNET_OK);
+ GNUNET_SERVER_receive_done (info->client, GNUNET_OK);
}
@@ -756,8 +752,7 @@ tunnel_get (struct GNUNET_PeerIdentity *oid, MESH_TunnelNumber tid);
* 0 if the tunnel remained unaffected.
*/
static GNUNET_PEER_Id
-tunnel_notify_connection_broken (struct MeshTunnel *t,
- GNUNET_PEER_Id p1,
+tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1,
GNUNET_PEER_Id p2);
@@ -777,39 +772,39 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
MESH_TunnelNumber *tid;
unsigned int count;
uint16_t type;
- char cbuf[htons(msg->size)];
+ char cbuf[htons (msg->size)];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Sending to clients...\n");
type = ntohs (payload->type);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: message of type %u\n", type);
- memcpy (cbuf, msg, sizeof(cbuf));
- switch (htons(msg->type))
+ memcpy (cbuf, msg, sizeof (cbuf));
+ switch (htons (msg->type))
{
struct GNUNET_MESH_Unicast *uc;
struct GNUNET_MESH_Multicast *mc;
struct GNUNET_MESH_ToOrigin *to;
- case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- uc = (struct GNUNET_MESH_Unicast *) cbuf;
- tid = &uc->tid;
- oid = &uc->oid;
- break;
- case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
- mc = (struct GNUNET_MESH_Multicast *) cbuf;
- tid = &mc->tid;
- oid = &mc->oid;
- break;
- case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- to = (struct GNUNET_MESH_ToOrigin *) cbuf;
- tid = &to->tid;
- oid = &to->oid;
- break;
- default:
- GNUNET_break (0);
- return 0;
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ uc = (struct GNUNET_MESH_Unicast *) cbuf;
+ tid = &uc->tid;
+ oid = &uc->oid;
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
+ mc = (struct GNUNET_MESH_Multicast *) cbuf;
+ tid = &mc->tid;
+ oid = &mc->oid;
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ to = (struct GNUNET_MESH_ToOrigin *) cbuf;
+ tid = &to->tid;
+ oid = &to->oid;
+ break;
+ default:
+ GNUNET_break (0);
+ return 0;
}
- t = tunnel_get (oid, ntohl(*tid));
+ t = tunnel_get (oid, ntohl (*tid));
if (NULL == t)
{
GNUNET_break (0);
@@ -823,11 +818,9 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
{
count++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: sending\n");
- GNUNET_SERVER_notification_context_unicast (
- nc,
- c->handle,
- (struct GNUNET_MessageHeader *) cbuf,
- GNUNET_YES);
+ GNUNET_SERVER_notification_context_unicast (nc, c->handle,
+ (struct GNUNET_MessageHeader
+ *) cbuf, GNUNET_YES);
}
}
return count;
@@ -837,7 +830,7 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
/**
* Notify the client that owns the tunnel that a peer has connected to it
* (the requested path to it has been confirmed).
- *
+ *
* @param t Tunnel whose owner to notify
* @param id Short id of the peer that has connected
*/
@@ -850,26 +843,26 @@ send_client_peer_connected (const struct MeshTunnel *t, const GNUNET_PEER_Id id)
pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl));
pc.tunnel_id = htonl (t->local_tid);
GNUNET_PEER_resolve (id, &pc.peer);
- GNUNET_SERVER_notification_context_unicast (nc, t->client->handle,
- &pc.header, GNUNET_NO);
+ GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, &pc.header,
+ GNUNET_NO);
}
/**
* Notify all clients (not depending on registration status) that the incoming
* tunnel is no longer valid.
- *
+ *
* @param t Tunnel that was destroyed.
*/
static void
send_clients_tunnel_destroy (struct MeshTunnel *t)
{
- struct GNUNET_MESH_TunnelMessage msg;
+ struct GNUNET_MESH_TunnelMessage msg;
- msg.header.size = htons (sizeof (msg));
- msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY);
- msg.tunnel_id = htonl (t->local_tid);
- GNUNET_SERVER_notification_context_broadcast(nc, &msg.header, GNUNET_NO);
+ msg.header.size = htons (sizeof (msg));
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY);
+ msg.tunnel_id = htonl (t->local_tid);
+ GNUNET_SERVER_notification_context_broadcast (nc, &msg.header, GNUNET_NO);
}
@@ -906,7 +899,7 @@ send_core_data_multicast (void *cls, size_t size, void *buf);
/**
* Decrements the reference counter and frees all resources if needed
- *
+ *
* @param dd Data Descriptor used in a multicast message
*/
static void
@@ -922,7 +915,7 @@ data_descriptor_decrement_multicast (struct MeshDataDescriptor *dd)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MESH: cancelling client timeout (%u)...\n",
*(dd->timeout_task));
- GNUNET_SCHEDULER_cancel(*(dd->timeout_task));
+ GNUNET_SCHEDULER_cancel (*(dd->timeout_task));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: notifying client...\n");
GNUNET_SERVER_receive_done (dd->client, GNUNET_OK);
}
@@ -937,12 +930,12 @@ data_descriptor_decrement_multicast (struct MeshDataDescriptor *dd)
/**
* Cancel a core transmission that was already requested and free all resources
* associated to the request.
- *
+ *
* @param peer PeeInfo of the peer whose transmission is cancelled.
* @param i Position of the transmission to be cancelled.
*/
static void
-peer_info_cancel_transmission(struct MeshPeerInfo *peer, unsigned int i)
+peer_info_cancel_transmission (struct MeshPeerInfo *peer, unsigned int i)
{
if (NULL != peer->core_transmit[i])
{
@@ -956,36 +949,34 @@ peer_info_cancel_transmission(struct MeshPeerInfo *peer, unsigned int i)
GNUNET_PEER_resolve (peer->id, &id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MESH: Cancelling data transmission at %s [%u]\n",
- GNUNET_i2s (&id),
- i);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MESH: message type %u\n",
+ GNUNET_i2s (&id), i);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: message type %u\n",
peer->types[i]);
}
#endif
/* TODO: notify that tranmission has failed */
switch (peer->types[i])
{
- case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
- case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type payload\n");
- dd = peer->infos[i];
- data_descriptor_decrement_multicast (dd);
- break;
- case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type create path\n");
- path_info = peer->infos[i];
- path_destroy(path_info->path);
- break;
- default:
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type unknown!\n");
+ case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type payload\n");
+ dd = peer->infos[i];
+ data_descriptor_decrement_multicast (dd);
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type create path\n");
+ path_info = peer->infos[i];
+ path_destroy (path_info->path);
+ break;
+ default:
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type unknown!\n");
}
GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit[i]);
peer->core_transmit[i] = NULL;
GNUNET_free (peer->infos[i]);
- }
+ }
}
@@ -1008,7 +999,7 @@ peer_info_transmit_slot (struct MeshPeerInfo *peer)
{
/* All positions are taken! Overwriting! */
GNUNET_break (0);
- peer_info_cancel_transmission(peer, 0);
+ peer_info_cancel_transmission (peer, 0);
return 0;
}
}
@@ -1056,8 +1047,8 @@ peer_info_get_short (const GNUNET_PEER_Id peer)
{
struct GNUNET_PeerIdentity id;
- GNUNET_PEER_resolve(peer, &id);
- return peer_info_get(&id);
+ GNUNET_PEER_resolve (peer, &id);
+ return peer_info_get (&id);
}
@@ -1072,7 +1063,7 @@ peer_info_get_short (const GNUNET_PEER_Id peer)
* @return always GNUNET_YES, to keep iterating
*/
static int
-peer_info_delete_tunnel (void* cls, const GNUNET_HashCode* key, void* value)
+peer_info_delete_tunnel (void *cls, const GNUNET_HashCode * key, void *value)
{
struct MeshTunnel *t = cls;
struct MeshPeerInfo *peer = value;
@@ -1080,9 +1071,8 @@ peer_info_delete_tunnel (void* cls, const GNUNET_HashCode* key, void* value)
for (i = 0; i < peer->ntunnels; i++)
{
- if (0 == memcmp(&peer->tunnels[i]->id,
- &t->id,
- sizeof(struct MESH_TunnelID)))
+ if (0 ==
+ memcmp (&peer->tunnels[i]->id, &t->id, sizeof (struct MESH_TunnelID)))
{
peer->ntunnels--;
peer->tunnels[i] = peer->tunnels[peer->ntunnels];
@@ -1095,12 +1085,12 @@ peer_info_delete_tunnel (void* cls, const GNUNET_HashCode* key, void* value)
/**
- * Core callback to write a
+ * Core callback to write a
*
* @param cls Closure (MeshDataDescriptor with data in "data" member).
* @param size Number of bytes available in buf.
* @param buf Where the to write the message.
- *
+ *
* @return number of bytes written to buf
*/
static size_t
@@ -1121,15 +1111,10 @@ send_core_data_raw (void *cls, size_t size, void *buf)
GNUNET_PEER_resolve (info->peer->id, &id);
info->peer->core_transmit[info->handler_n] =
- GNUNET_CORE_notify_transmit_ready(core_handle,
- 0,
- 100,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &id,
- size,
- &send_core_data_raw,
- info);
- return 0;
+ GNUNET_CORE_notify_transmit_ready (core_handle, 0, 100,
+ GNUNET_TIME_UNIT_FOREVER_REL, &id,
+ size, &send_core_data_raw, info);
+ return 0;
}
info->peer->core_transmit[info->handler_n] = NULL;
memcpy (buf, msg, total_size);
@@ -1181,14 +1166,9 @@ send_message (const struct GNUNET_MessageHeader *message,
neighbor->types[i] = GNUNET_MESSAGE_TYPE_MESH_UNICAST;
neighbor->infos[i] = info;
neighbor->core_transmit[i] =
- GNUNET_CORE_notify_transmit_ready(core_handle,
- 0,
- 100,
- GNUNET_TIME_UNIT_FOREVER_REL,
- peer,
- size,
- &send_core_data_raw,
- info);
+ GNUNET_CORE_notify_transmit_ready (core_handle, 0, 100,
+ GNUNET_TIME_UNIT_FOREVER_REL, peer,
+ size, &send_core_data_raw, info);
}
@@ -1196,14 +1176,13 @@ send_message (const struct GNUNET_MessageHeader *message,
/**
* Sends a CREATE PATH message for a path to a peer, properly registrating
* all used resources.
- *
+ *
* @param peer PeerInfo of the final peer for whom this path is being created.
* @param p Path itself.
* @param t Tunnel for which the path is created.
*/
static void
-send_create_path (struct MeshPeerInfo *peer,
- struct MeshPeerPath *p,
+send_create_path (struct MeshPeerInfo *peer, struct MeshPeerPath *p,
struct MeshTunnel *t)
{
struct GNUNET_PeerIdentity id;
@@ -1213,7 +1192,7 @@ send_create_path (struct MeshPeerInfo *peer,
if (NULL == p)
{
- p = tree_get_path_to_peer(t->tree, peer->id);
+ p = tree_get_path_to_peer (t->tree, peer->id);
if (NULL == p)
{
GNUNET_break (0);
@@ -1227,37 +1206,34 @@ send_create_path (struct MeshPeerInfo *peer,
}
if (i >= p->length - 1)
{
- path_destroy(p);
+ path_destroy (p);
GNUNET_break (0);
return;
}
- GNUNET_PEER_resolve(p->peers[i + 1], &id);
+ GNUNET_PEER_resolve (p->peers[i + 1], &id);
path_info = GNUNET_malloc (sizeof (struct MeshPathInfo));
path_info->path = p;
path_info->t = t;
- neighbor = peer_info_get(&id);
+ neighbor = peer_info_get (&id);
path_info->peer = neighbor;
- path_info->pos = peer_info_transmit_slot(neighbor);
+ path_info->pos = peer_info_transmit_slot (neighbor);
neighbor->types[path_info->pos] = GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE;
neighbor->infos[path_info->pos] = path_info;
- neighbor->core_transmit[path_info->pos] =
- GNUNET_CORE_notify_transmit_ready (
- core_handle, /* handle */
- 0, /* cork */
- 0, /* priority */
- GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
- &id, /* target */
- sizeof (struct GNUNET_MESH_ManipulatePath)
- + (p->length * sizeof (struct GNUNET_PeerIdentity)), /*size */
- &send_core_create_path, /* callback */
- path_info); /* cls */
+ neighbor->core_transmit[path_info->pos] = GNUNET_CORE_notify_transmit_ready (core_handle, /* handle */
+ 0, /* cork */
+ 0, /* priority */
+ GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
+ &id, /* target */
+ sizeof (struct GNUNET_MESH_ManipulatePath) + (p->length * sizeof (struct GNUNET_PeerIdentity)), /*size */
+ &send_core_create_path, /* callback */
+ path_info); /* cls */
}
/**
* Sends a DESTROY PATH message to free resources for a path in a tunnel
- *
+ *
* @param t Tunnel whose path to destroy.
* @param destination Short ID of the peer to whom the path to destroy.
*/
@@ -1267,7 +1243,7 @@ send_destroy_path (struct MeshTunnel *t, GNUNET_PEER_Id destination)
struct MeshPeerPath *p;
size_t size;
- p = tree_get_path_to_peer(t->tree, destination);
+ p = tree_get_path_to_peer (t->tree, destination);
if (NULL == p)
{
GNUNET_break (0);
@@ -1288,9 +1264,9 @@ send_destroy_path (struct MeshTunnel *t, GNUNET_PEER_Id destination)
pi = (struct GNUNET_PeerIdentity *) &msg[1];
for (i = 0; i < p->length; i++)
{
- GNUNET_PEER_resolve(p->peers[i], &pi[i]);
+ GNUNET_PEER_resolve (p->peers[i], &pi[i]);
}
- send_message (&msg->header, path_get_first_hop(t->tree, destination));
+ send_message (&msg->header, path_get_first_hop (t->tree, destination));
}
path_destroy (p);
}
@@ -1299,7 +1275,7 @@ send_destroy_path (struct MeshTunnel *t, GNUNET_PEER_Id destination)
/**
* Try to establish a new connection to this peer.
* Use the best path for the given tunnel.
- * If the peer doesn't have any path to it yet, try to get one.
+ * If the peer doesn't have any path to it yet, try to get one.
* If the peer already has some path, send a CREATE PATH towards it.
*
* @param peer PeerInfo of the peer.
@@ -1313,7 +1289,7 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
if (NULL != peer->path_head)
{
- p = tree_get_path_to_peer(t->tree, peer->id);
+ p = tree_get_path_to_peer (t->tree, peer->id);
if (NULL == p)
{
GNUNET_break (0);
@@ -1322,38 +1298,33 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
if (p->length > 1)
{
- send_create_path(peer, p, t);
+ send_create_path (peer, p, t);
}
else
{
- path_destroy(p);
- send_client_peer_connected(t, myid);
+ path_destroy (p);
+ send_client_peer_connected (t, myid);
}
}
else if (NULL == peer->dhtget)
{
struct GNUNET_PeerIdentity id;
- GNUNET_PEER_resolve(peer->id, &id);
- path_info = GNUNET_malloc(sizeof(struct MeshPathInfo));
+ GNUNET_PEER_resolve (peer->id, &id);
+ path_info = GNUNET_malloc (sizeof (struct MeshPathInfo));
path_info->peer = peer;
path_info->t = t;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MESH: Starting DHT GET for peer %s\n",
- GNUNET_i2s (&id));
+ "MESH: Starting DHT GET for peer %s\n", GNUNET_i2s (&id));
peer->dhtgetcls = path_info;
- peer->dhtget =
- GNUNET_DHT_get_start(dht_handle, /* handle */
- GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
- GNUNET_BLOCK_TYPE_TEST, /* type */
- &id.hashPubKey, /* key to search */
- 4, /* replication level */
- GNUNET_DHT_RO_RECORD_ROUTE |
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- NULL, /* xquery */
- 0, /* xquery bits */
- &dht_get_id_handler,
- path_info);
+ peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
+ GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
+ GNUNET_BLOCK_TYPE_TEST, /* type */
+ &id.hashPubKey, /* key to search */
+ 4, /* replication level */
+ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, /* xquery */
+ 0, /* xquery bits */
+ &dht_get_id_handler, path_info);
}
/* Otherwise, there is no path but the DHT get is already started. */
}
@@ -1384,9 +1355,9 @@ peer_info_connect_task (void *cls,
/**
* Destroy the peer_info and free any allocated resources linked to it
- *
+ *
* @param pi The peer_info to destroy.
- *
+ *
* @return GNUNET_OK on success
*/
static int
@@ -1401,21 +1372,20 @@ peer_info_destroy (struct MeshPeerInfo *pi)
GNUNET_PEER_change_rc (pi->id, -1);
if (GNUNET_YES !=
- GNUNET_CONTAINER_multihashmap_remove (peers,&id.hashPubKey, pi))
+ GNUNET_CONTAINER_multihashmap_remove (peers, &id.hashPubKey, pi))
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "MESH: removing peer %s, not in hashmap\n",
- GNUNET_i2s (&id));
+ "MESH: removing peer %s, not in hashmap\n", GNUNET_i2s (&id));
}
if (NULL != pi->dhtget)
{
- GNUNET_DHT_get_stop(pi->dhtget);
+ GNUNET_DHT_get_stop (pi->dhtget);
GNUNET_free (pi->dhtgetcls);
}
for (i = 0; i < CORE_QUEUE_SIZE; i++)
{
- peer_info_cancel_transmission(pi, i);
+ peer_info_cancel_transmission (pi, i);
}
p = pi->path_head;
while (NULL != p)
@@ -1442,8 +1412,7 @@ peer_info_destroy (struct MeshPeerInfo *pi)
* TODO: optimize (see below)
*/
static void
-peer_info_remove_path (struct MeshPeerInfo *peer,
- GNUNET_PEER_Id p1,
+peer_info_remove_path (struct MeshPeerInfo *peer, GNUNET_PEER_Id p1,
GNUNET_PEER_Id p2)
{
struct MeshPeerPath *p;
@@ -1486,16 +1455,16 @@ peer_info_remove_path (struct MeshPeerInfo *peer,
* Some of them might already have a path to reach them that does not
* involve p1 and p2. Adding all anew might render in a better tree than
* the trivial immediate fix.
- *
+ *
* Trivial immiediate fix: try to reconnect to the disconnected node. All
* its children will be reachable trough him.
*/
- peer_d = peer_info_get_short(d);
+ peer_d = peer_info_get_short (d);
best = UINT_MAX;
aux = NULL;
for (p = peer_d->path_head; NULL != p; p = p->next)
{
- if ((cost = path_get_cost(peer->tunnels[i]->tree, p)) < best)
+ if ((cost = path_get_cost (peer->tunnels[i]->tree, p)) < best)
{
best = cost;
aux = p;
@@ -1504,7 +1473,7 @@ peer_info_remove_path (struct MeshPeerInfo *peer,
if (NULL != aux)
{
/* No callback, as peer will be already disconnected */
- tree_add_path(peer->tunnels[i]->tree, aux, NULL, NULL);
+ tree_add_path (peer->tunnels[i]->tree, aux, NULL, NULL);
}
else
{
@@ -1524,8 +1493,7 @@ peer_info_remove_path (struct MeshPeerInfo *peer,
* @param trusted Do we trust that this path is real?
*/
void
-peer_info_add_path (struct MeshPeerInfo *peer_info,
- struct MeshPeerPath *path,
+peer_info_add_path (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path,
int trusted)
{
struct MeshPeerPath *aux;
@@ -1549,28 +1517,24 @@ peer_info_add_path (struct MeshPeerInfo *peer_info,
{
if (path->peers[l] == myid)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MESH: shortening path by %u\n",
- l);
- for (l2 = 0; l2 < path->length - l - 1 ; l2++)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: shortening path by %u\n", l);
+ for (l2 = 0; l2 < path->length - l - 1; l2++)
{
path->peers[l2] = path->peers[l + l2];
}
path->length -= l;
l = 1;
- path->peers = GNUNET_realloc (path->peers,
- path->length * sizeof (GNUNET_PEER_Id));
+ path->peers =
+ GNUNET_realloc (path->peers, path->length * sizeof (GNUNET_PEER_Id));