From 1fe79fd553e21a20206301c18568d30158c9dd46 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 14 Sep 2011 11:59:46 +0000 Subject: indentation --- src/datastore/plugin_datastore_sqlite.c | 12 +- src/dht/gnunet-dht-driver.c | 42 +++--- src/dht/gnunet-service-dht.c | 93 ++++++------- src/dht/test_dht_twopeer_get_put.c | 2 +- src/fs/fs_test_lib.c | 7 +- src/fs/fs_test_lib.h | 3 +- src/fs/gnunet-service-fs_cp.c | 11 +- src/fs/test_fs_test_lib.c | 12 +- src/fs/test_gnunet_service_fs_migration.c | 14 +- src/fs/test_gnunet_service_fs_p2p.c | 12 +- src/include/gnunet_mesh_service_new.h | 40 +++--- src/include/gnunet_transport_service.h | 12 +- src/mesh/gnunet-service-mesh.c | 152 ++++++++------------ src/mesh/mesh_api.c | 2 +- src/mesh/mesh_api_new.c | 19 +-- src/mesh/test_mesh_local_1.c | 38 +++-- src/mesh/test_mesh_local_2.c | 44 +++--- src/peerinfo-tool/gnunet-peerinfo.c | 2 +- src/testing/test_testing_connect.c | 4 +- src/testing/test_testing_reconnect.c | 4 +- src/testing/testing.c | 153 ++++++++++----------- src/testing/testing_group.c | 84 ++++++----- src/topology/test_gnunet_daemon_topology.c | 34 +++-- .../gnunet-service-transport_neighbours.c | 6 +- src/transport/gnunet-transport-wlan-helper.c | 1 - src/transport/plugin_transport_wlan.c | 88 ++++++------ src/transport/test_plugin_transport_wlan_dummy.c | 4 +- src/transport/test_transport_api_limited_sockets.c | 23 ++-- src/transport/transport_api_address_lookup.c | 8 +- src/transport/transport_api_peer_address_lookup.c | 9 +- src/transport/wlan/helper_common.c | 4 +- src/vpn/gnunet-daemon-vpn-helper.c | 15 +- src/vpn/gnunet-service-dns.c | 34 +++-- 33 files changed, 478 insertions(+), 510 deletions(-) (limited to 'src') diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index c5952bcb0..2620c3682 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -326,15 +326,12 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, (sq_prepare (plugin->dbh, "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ " - "FROM gn090 INDEXED BY idx_repl_rvalue " - "WHERE repl=?2 AND " + "FROM gn090 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND " " (rvalue>=?1 OR " " NOT EXISTS (SELECT 1 FROM gn090 INDEXED BY idx_repl_rvalue WHERE repl=?2 AND rvalue>=?1 LIMIT 1) ) " - "ORDER BY rvalue ASC LIMIT 1", - &plugin->selRepl) != SQLITE_OK) || + "ORDER BY rvalue ASC LIMIT 1", &plugin->selRepl) != SQLITE_OK) || (sq_prepare - (plugin->dbh, - "SELECT MAX(repl) FROM gn090 INDEXED BY idx_repl_rvalue", + (plugin->dbh, "SELECT MAX(repl) FROM gn090 INDEXED BY idx_repl_rvalue", &plugin->maxRepl) != SQLITE_OK) || (sq_prepare (plugin->dbh, @@ -355,8 +352,7 @@ database_setup (const struct GNUNET_CONFIGURATION_Handle *cfg, "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", &plugin->insertContent) != SQLITE_OK) || (sq_prepare - (plugin->dbh, - "DELETE FROM gn090 WHERE _ROWID_ = ?", + (plugin->dbh, "DELETE FROM gn090 WHERE _ROWID_ = ?", &plugin->delRow) != SQLITE_OK)) { LOG_SQLITE (plugin, NULL, GNUNET_ERROR_TYPE_ERROR, "precompiling"); diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index c0213499c..8fa5199ab 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -1407,23 +1407,12 @@ add_new_connection (struct FindPeerContext *find_peer_context, } static void -did_connect (void *cls, - const struct - GNUNET_PeerIdentity * first, - const struct - GNUNET_PeerIdentity * second, - uint32_t distance, - const struct - GNUNET_CONFIGURATION_Handle * - first_cfg, - const struct - GNUNET_CONFIGURATION_Handle * - second_cfg, - struct GNUNET_TESTING_Daemon * - first_daemon, - struct GNUNET_TESTING_Daemon * - second_daemon, - const char *emsg) +did_connect (void *cls, const struct GNUNET_PeerIdentity *first, + const struct GNUNET_PeerIdentity *second, uint32_t distance, + const struct GNUNET_CONFIGURATION_Handle *first_cfg, + const struct GNUNET_CONFIGURATION_Handle *second_cfg, + struct GNUNET_TESTING_Daemon *first_daemon, + struct GNUNET_TESTING_Daemon *second_daemon, const char *emsg) { struct FindPeerContext *find_peer_context = cls; @@ -1457,7 +1446,8 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, d1 = GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); GNUNET_assert (d1 != NULL); d2 = d1; - while ((d2 == d1) || (GNUNET_YES != GNUNET_TESTING_test_daemon_running (d2))) + while ((d2 == d1) || + (GNUNET_YES != GNUNET_TESTING_test_daemon_running (d2))) { d2 = GNUNET_TESTING_daemon_get (pg, GNUNET_CRYPTO_random_u32 @@ -1479,10 +1469,10 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, } if (NULL != find_peer_context->cc) GNUNET_TESTING_daemons_connect_cancel (find_peer_context->cc); - find_peer_context->cc = GNUNET_TESTING_daemons_connect (d1, d2, timeout, DEFAULT_RECONNECT_ATTEMPTS, - GNUNET_YES, - &did_connect, - find_peer_context); + find_peer_context->cc = + GNUNET_TESTING_daemons_connect (d1, d2, timeout, + DEFAULT_RECONNECT_ATTEMPTS, GNUNET_YES, + &did_connect, find_peer_context); } if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime).rel_value > 0) @@ -1602,7 +1592,7 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, GNUNET_CONTAINER_multihashmap_destroy (find_peer_context->peer_hash); GNUNET_CONTAINER_heap_destroy (find_peer_context->peer_min_heap); if (NULL != find_peer_context->cc) - GNUNET_TESTING_daemons_connect_cancel (find_peer_context->cc); + GNUNET_TESTING_daemons_connect_cancel (find_peer_context->cc); GNUNET_free (find_peer_context); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Churn round %u of %llu finished, scheduling next GET round.\n", @@ -2120,7 +2110,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Set this here in case we are re-running gets */ test_get->succeeded = GNUNET_NO; - if (GNUNET_YES != GNUNET_TESTING_test_daemon_running (test_get->daemon)) /* If the peer has been churned off, don't try issuing request from it! */ + if (GNUNET_YES != GNUNET_TESTING_test_daemon_running (test_get->daemon)) /* If the peer has been churned off, don't try issuing request from it! */ { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue get request from is down, skipping.\n"); @@ -2237,7 +2227,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (test_put == NULL) return; /* End of list */ - if (GNUNET_YES != GNUNET_TESTING_test_daemon_running (test_put->daemon)) /* If the peer has been churned off, don't try issuing request from it! */ + if (GNUNET_YES != GNUNET_TESTING_test_daemon_running (test_put->daemon)) /* If the peer has been churned off, don't try issuing request from it! */ { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer we should issue put request at is down, skipping.\n"); @@ -2357,7 +2347,7 @@ count_peers_cb (void *cls, const struct GNUNET_PeerIdentity *first, GNUNET_CONTAINER_multihashmap_destroy (find_peer_context->peer_hash); GNUNET_CONTAINER_heap_destroy (find_peer_context->peer_min_heap); if (NULL != find_peer_context->cc) - GNUNET_TESTING_daemons_connect_cancel (find_peer_context->cc); + GNUNET_TESTING_daemons_connect_cancel (find_peer_context->cc); GNUNET_free (find_peer_context); fprintf (stderr, "Not sending any more find peer requests.\n"); diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 237db023c..a68ba5563 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -858,10 +858,9 @@ static struct GNUNET_NSE_Handle *nse; * @param std_dev standard deviation for the estimate * */ -static void -update_network_size_estimate (void *cls, - struct GNUNET_TIME_Absolute timestamp, - double logestimate, double std_dev) +static void +update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp, + double logestimate, double std_dev) { log_of_network_size_estimate = logestimate; } @@ -947,7 +946,7 @@ increment_stats (const char *value) { if (stats == NULL) return; - GNUNET_STATISTICS_update (stats, value, 1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, value, 1, GNUNET_NO); } @@ -956,7 +955,7 @@ decrement_stats (const char *value) { if (stats == NULL) return; - GNUNET_STATISTICS_update (stats, value, -1, GNUNET_NO); + GNUNET_STATISTICS_update (stats, value, -1, GNUNET_NO); } @@ -1630,8 +1629,7 @@ forward_message (const struct GNUNET_MessageHeader *msg, struct PeerInfo *peer, static void process_pending_messages (struct ClientList *client) { - if ( (client->pending_head == NULL) || - (client->transmit_handle != NULL) ) + if ((client->pending_head == NULL) || (client->transmit_handle != NULL)) return; client->transmit_handle = GNUNET_SERVER_notify_transmit_ready (client->client_handle, @@ -2659,7 +2657,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, #endif // GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "******************************************************** PUT 1\n"); - record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, &msg_ctx->key); + record = + GNUNET_CONTAINER_multihashmap_get (forward_list.hashmap, &msg_ctx->key); if (NULL != record) { struct DHTRouteSource *pos; @@ -2675,16 +2674,16 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, if (NULL == pos->client) continue; - gsize = data_size + sizeof(struct GNUNET_DHT_GetMessage); - gmsg = GNUNET_malloc(gsize); - gmsg->header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET_RESULT); - gmsg->header.size = htons(gsize); + gsize = data_size + sizeof (struct GNUNET_DHT_GetMessage); + gmsg = GNUNET_malloc (gsize); + gmsg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET_RESULT); + gmsg->header.size = htons (gsize); gmsg->type = put_msg->type; - memcpy(&gmsg[1], &put_msg[1], data_size); + memcpy (&gmsg[1], &put_msg[1], data_size); /* TODO: duplicate and reverse order of path_history? */ send_reply_to_client (pos->client, &gmsg->header, msg_ctx); - GNUNET_free(gmsg); + GNUNET_free (gmsg); } } // GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "******************************************************** PUT END\n"); @@ -2783,20 +2782,20 @@ get_forward_count (unsigned int hop_count, size_t target_replication) { if (hop_count == 0) return kademlia_replication; - if (hop_count < log_of_network_size_estimate * 2.0) + if (hop_count < log_of_network_size_estimate * 2.0) return 1; return 0; } if (hop_count > log_of_network_size_estimate * 2.0) { - if (GNUNET_YES == paper_forwarding) + if (GNUNET_YES == paper_forwarding) { /* Once we have reached our ideal number of hops, don't stop forwarding! */ return 1; } #if DEBUG_DHT - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hop count too high (est %f, lowest %d), NOT Forwarding request\n", log_of_network_size_estimate * 2.0, lowest_bucket); #endif @@ -2893,7 +2892,7 @@ am_closest_peer (const GNUNET_HashCode * target, { if (strict_kademlia != GNUNET_YES) /* Return that we at as close as any other peer */ return GNUNET_YES; - if (distance (&pos->id.hashPubKey, target) < my_distance) /* Check all known peers, only return if we are the true closest */ + if (distance (&pos->id.hashPubKey, target) < my_distance) /* Check all known peers, only return if we are the true closest */ return GNUNET_NO; } pos = pos->next; @@ -2932,8 +2931,7 @@ select_peer (const GNUNET_HashCode * target, struct PeerInfo *chosen; /** If we are doing kademlia routing (saves some cycles) */ - if ( (strict_kademlia == GNUNET_YES) || - (hops >= log_of_network_size_estimate) ) + if ((strict_kademlia == GNUNET_YES) || (hops >= log_of_network_size_estimate)) { /* greedy selection (closest peer that is not in bloomfilter) */ largest_distance = 0; @@ -2964,7 +2962,7 @@ select_peer (const GNUNET_HashCode * target, GNUNET_CONTAINER_bloomfilter_add (bloom, &chosen->id.hashPubKey); return chosen; } - return NULL; /* no peer available or we are the closest */ + return NULL; /* no peer available or we are the closest */ } @@ -2986,14 +2984,13 @@ select_peer (const GNUNET_HashCode * target, pos = pos->next; } } - if (count == 0) /* No peers to select from! */ + if (count == 0) /* No peers to select from! */ { increment_stats ("# failed to select peer"); return NULL; } /* Now actually choose a peer */ - selected = - GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, count); + selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, count); count = 0; for (bc = lowest_bucket; bc < MAX_BUCKETS; bc++) { @@ -3007,7 +3004,7 @@ select_peer (const GNUNET_HashCode * target, continue; /* Ignore bloomfiltered peers */ } if (0 == selected--) - return pos; + return pos; pos = pos->next; } } @@ -3105,10 +3102,10 @@ cache_response (struct DHT_MessageContext *msg_ctx) pos = record->head; while (pos != NULL) { - if ( (NULL != msg_ctx->peer) && - (0 == - memcmp (msg_ctx->peer, &pos->source, - sizeof (struct GNUNET_PeerIdentity))) ) + if ((NULL != msg_ctx->peer) && + (0 == + memcmp (msg_ctx->peer, &pos->source, + sizeof (struct GNUNET_PeerIdentity)))) break; /* Already have this peer in reply list! */ pos = pos->next; } @@ -3280,7 +3277,7 @@ route_message (const struct GNUNET_MessageHeader *msg, recent_req = GNUNET_CONTAINER_heap_peek (recent.minHeap); GNUNET_assert (recent_req != NULL); GNUNET_SCHEDULER_cancel (recent_req->remove_task); - recent_req->remove_task = + recent_req->remove_task = GNUNET_SCHEDULER_add_now (&remove_recent, recent_req); } @@ -3591,8 +3588,8 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, "DHT", GNUNET_h2s (&key)); demultiplex_message (&put_message.header, &msg_ctx); - GNUNET_SCHEDULER_add_delayed (malicious_put_frequency, - &malicious_put_task, NULL); + GNUNET_SCHEDULER_add_delayed (malicious_put_frequency, &malicious_put_task, + NULL); } @@ -3639,8 +3636,8 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "%s:%s Sending malicious GET message with hash %s\n", my_short_id, "DHT", GNUNET_h2s (&key)); demultiplex_message (&get_message.header, &msg_ctx); - GNUNET_SCHEDULER_add_delayed (malicious_get_frequency, - &malicious_get_task, NULL); + GNUNET_SCHEDULER_add_delayed (malicious_get_frequency, &malicious_get_task, + NULL); } #endif @@ -3811,7 +3808,7 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, msg_ctx.path_history_len = 1; } msg_ctx.network_size = log_of_network_size_estimate; - msg_ctx.peer = &my_identity; /* FIXME bart NULL? Fix doxygen? */ + msg_ctx.peer = &my_identity; /* FIXME bart NULL? Fix doxygen? */ msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; @@ -4066,10 +4063,10 @@ handle_dht_p2p_route_request (void *cls, const struct GNUNET_PeerIdentity *peer, ntohl (incoming->outgoing_path_length) * sizeof (struct GNUNET_PeerIdentity); if (ntohs (message->size) != - (sizeof (struct GNUNET_DHT_P2PRouteMessage) + - ntohs (enc_msg->size) + path_size)) + (sizeof (struct GNUNET_DHT_P2PRouteMessage) + ntohs (enc_msg->size) + + path_size)) { - GNUNET_break_op(0); + GNUNET_break_op (0); return GNUNET_YES; } route_path = (char *) &incoming[1]; @@ -4524,8 +4521,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, datacache = GNUNET_DATACACHE_create (cfg, "dhtcache"); GNUNET_SERVER_add_handlers (server, plugin_handlers); GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); - nse = GNUNET_NSE_connect (cfg, - &update_network_size_estimate, NULL); + nse = GNUNET_NSE_connect (cfg, &update_network_size_estimate, NULL); coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */ DEFAULT_CORE_QUEUE_SIZE, /* queue size */ NULL, /* Closure passed to DHT functions */ @@ -4587,8 +4583,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, malicious_getter = GNUNET_YES; if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT", - "MALICIOUS_GET_FREQUENCY", - &malicious_get_frequency)) + "MALICIOUS_GET_FREQUENCY", + &malicious_get_frequency)) malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; } @@ -4598,8 +4594,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, malicious_putter = GNUNET_YES; if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT", - "MALICIOUS_PUT_FREQUENCY", - &malicious_put_frequency)) + "MALICIOUS_PUT_FREQUENCY", + &malicious_put_frequency)) malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; } @@ -4721,7 +4717,8 @@ main (int argc, char *const *argv) int ret; recent.hashmap = GNUNET_CONTAINER_multihashmap_create (DHT_MAX_RECENT / 2); - recent.minHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); + recent.minHeap = + GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); recent_find_peer_requests = GNUNET_CONTAINER_multihashmap_create (MAX_BUCKETS / 8); ret = @@ -4730,12 +4727,12 @@ main (int argc, char *const *argv) NULL)) ? 0 : 1; GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent.hashmap)); GNUNET_CONTAINER_multihashmap_destroy (recent.hashmap); - recent.hashmap = NULL; + recent.hashmap = NULL; GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (recent.minHeap)); GNUNET_CONTAINER_heap_destroy (recent.minHeap); recent.minHeap = NULL; GNUNET_CONTAINER_multihashmap_destroy (recent_find_peer_requests); - recent_find_peer_requests = NULL; + recent_find_peer_requests = NULL; return ret; } diff --git a/src/dht/test_dht_twopeer_get_put.c b/src/dht/test_dht_twopeer_get_put.c index 5ca70943a..ef491031c 100644 --- a/src/dht/test_dht_twopeer_get_put.c +++ b/src/dht/test_dht_twopeer_get_put.c @@ -30,7 +30,7 @@ * "straight line" topology. On notification that all peers have * been properly connected, calls the do_get function which initiates * a GNUNET_DHT_get from the *second* peer. Once the GNUNET_DHT_get - * function starts, runs the do_put function to insert data at the first peer. + * function starts, runs the do_put function to insert data at the first peer. * If the GET is successful, schedules finish_testing * to stop the test and shut down peers. If GET is unsuccessful * after GET_TIMEOUT seconds, prints an error message and shuts down diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 40a9f6276..1c15c6f60 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -445,9 +445,10 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, ncc = GNUNET_malloc (sizeof (struct GNUNET_FS_TEST_ConnectContext)); ncc->cont = cont; ncc->cont_cls = cont_cls; - ncc->cc = GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout, - CONNECT_ATTEMPTS, GNUNET_YES, - ¬ify_connection, ncc); + ncc->cc = + GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout, + CONNECT_ATTEMPTS, GNUNET_YES, + ¬ify_connection, ncc); return ncc; } diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h index 204d5b2ab..81125cafc 100644 --- a/src/fs/fs_test_lib.h +++ b/src/fs/fs_test_lib.h @@ -87,7 +87,8 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, * @param cc operation to cancel */ void -GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext *cc); +GNUNET_FS_TEST_daemons_connect_cancel (struct GNUNET_FS_TEST_ConnectContext + *cc); /** diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index c22f8b20a..69fb75be6 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -336,11 +336,12 @@ get_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi) if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) { static int once; - if (! once) - { - once = 1; - GNUNET_break (0); - } + + if (!once) + { + once = 1; + GNUNET_break (0); + } /* how can we not have latency data? */ return GNUNET_TIME_UNIT_SECONDS; } diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c index 1f2119259..589abb3fb 100644 --- a/src/fs/test_fs_test_lib.c +++ b/src/fs/test_fs_test_lib.c @@ -52,10 +52,10 @@ static void do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { if (NULL != cc) - { - GNUNET_FS_TEST_daemons_connect_cancel (cc); - cc = NULL; - } + { + GNUNET_FS_TEST_daemons_connect_cancel (cc); + cc = NULL; + } if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { GNUNET_break (0); @@ -117,8 +117,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, - NULL); + cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, + &do_publish, NULL); } diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index bbf2534d2..3d6735cc4 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c @@ -59,12 +59,12 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TIME_Relative del; char *fancy; - + if (NULL != cc) - { - GNUNET_FS_TEST_daemons_connect_cancel (cc); - cc = NULL; - } + { + GNUNET_FS_TEST_daemons_connect_cancel (cc); + cc = NULL; + } GNUNET_FS_TEST_daemons_stop (2, daemons); if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { @@ -173,8 +173,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, - NULL); + cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, + &do_publish, NULL); } diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c index 26372cfa8..17b7ec181 100644 --- a/src/fs/test_gnunet_service_fs_p2p.c +++ b/src/fs/test_gnunet_service_fs_p2p.c @@ -57,10 +57,10 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) char *fancy; if (NULL != cc) - { - GNUNET_FS_TEST_daemons_connect_cancel (cc); - cc = NULL; - } + { + GNUNET_FS_TEST_daemons_connect_cancel (cc); + cc = NULL; + } GNUNET_FS_TEST_daemons_stop (NUM_DAEMONS, daemons); if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) { @@ -128,8 +128,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemons started, will now try to connect them\n"); - cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, &do_publish, - NULL); + cc = GNUNET_FS_TEST_daemons_connect (daemons[0], daemons[1], TIMEOUT, + &do_publish, NULL); } diff --git a/src/include/gnunet_mesh_service_new.h b/src/include/gnunet_mesh_service_new.h index f32bf28c5..6db406de3 100644 --- a/src/include/gnunet_mesh_service_new.h +++ b/src/include/gnunet_mesh_service_new.h @@ -116,11 +116,16 @@ struct GNUNET_MESH_MessageHandler * @return initial tunnel context for the tunnel * (can be NULL -- that's not an error) */ -typedef void* (GNUNET_MESH_InboundTunnelNotificationHandler) ( - void *cls, - struct GNUNET_MESH_Tunnel * tunnel, - const struct GNUNET_PeerIdentity * initiator, - const struct GNUNET_TRANSPORT_ATS_Information * atsi); +typedef void *(GNUNET_MESH_InboundTunnelNotificationHandler) (void *cls, + struct + GNUNET_MESH_Tunnel + * tunnel, + const struct + GNUNET_PeerIdentity + * initiator, + const struct + GNUNET_TRANSPORT_ATS_Information + * atsi); /** @@ -164,8 +169,7 @@ typedef uint32_t GNUNET_MESH_ApplicationType; */ struct GNUNET_MESH_Handle * GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - unsigned int queue_size, - void *cls, + unsigned int queue_size, void *cls, GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel, GNUNET_MESH_TunnelEndHandler cleaner, const struct GNUNET_MESH_MessageHandler *handlers, @@ -187,9 +191,9 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle); * @param cls closure * @param peer peer identity the tunnel stopped working with */ -typedef void (*GNUNET_MESH_PeerDisconnectHandler) ( - void *cls, - const struct GNUNET_PeerIdentity * peer); +typedef void (*GNUNET_MESH_PeerDisconnectHandler) (void *cls, + const struct + GNUNET_PeerIdentity * peer); /** @@ -200,10 +204,12 @@ typedef void (*GNUNET_MESH_PeerDisconnectHandler) ( * @param peer peer identity the tunnel was created to, NULL on timeout * @param atsi performance data for the connection */ -typedef void (*GNUNET_MESH_PeerConnectHandler) ( - void *cls, - const struct GNUNET_PeerIdentity * peer, - const struct GNUNET_TRANSPORT_ATS_Information * atsi); +typedef void (*GNUNET_MESH_PeerConnectHandler) (void *cls, + const struct GNUNET_PeerIdentity + * peer, + const struct + GNUNET_TRANSPORT_ATS_Information + * atsi); @@ -218,8 +224,7 @@ typedef void (*GNUNET_MESH_PeerConnectHandler) ( * @param handler_cls closure for connect/disconnect handlers */ struct GNUNET_MESH_Tunnel * -GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, - void *tunnel_ctx, +GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, void *tunnel_ctx, GNUNET_MESH_PeerConnectHandler connect_handler, GNUNET_MESH_PeerDisconnectHandler disconnect_handler, void *handler_cls); @@ -297,8 +302,7 @@ struct GNUNET_MESH_TransmitHandle; * memory); if NULL is returned, "notify" will NOT be called. */ struct GNUNET_MESH_TransmitHandle * -GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, - int cork, +GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, uint32_t priority, struct GNUNET_TIME_Relative maxdelay, const struct GNUNET_PeerIdentity *target, diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index 4f868e526..8b9472cdb 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h @@ -638,7 +638,7 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, /** * Handle to cancel a pending address lookup. - */ + */ struct GNUNET_TRANSPORT_AddressLookupContext; @@ -671,12 +671,14 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param alc handle for the request to cancel */ void -GNUNET_TRANSPORT_address_lookup_cancel (struct GNUNET_TRANSPORT_AddressLookupContext *alc); +GNUNET_TRANSPORT_address_lookup_cancel (struct + GNUNET_TRANSPORT_AddressLookupContext + *alc); /** * Handle to cancel a pending address lookup. - */ + */ struct GNUNET_TRANSPORT_AddressLookupContext; @@ -706,7 +708,9 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle * @param alc handle for the request to cancel */ void -GNUNET_TRANSPORT_peer_address_lookup_cancel (struct GNUNET_TRANSPORT_PeerAddressLookupContext *alc); +GNUNET_TRANSPORT_peer_address_lookup_cancel (struct + GNUNET_TRANSPORT_PeerAddressLookupContext + *alc); /** diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index f31ff63ba..b30289ac0 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -661,8 +661,8 @@ is_client_subscribed (uint16_t message_type, struct MeshClient *c) { GNUNET_HashCode hc; - GNUNET_CRYPTO_hash(&message_type, sizeof(uint16_t), &hc); - return GNUNET_CONTAINER_multihashmap_contains(c->types, &hc); + GNUNET_CRYPTO_hash (&message_type, sizeof (uint16_t), &hc); + return GNUNET_CONTAINER_multihashmap_contains (c->types, &hc); } @@ -817,9 +817,8 @@ static int announce_application (void *cls, const GNUNET_HashCode * key, void *value) { /* FIXME are hashes in multihash map equal on all aquitectures? */ - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "MESH: putting in DHT %s\n", - GNUNET_h2s_full(key)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: putting in DHT %s\n", + GNUNET_h2s_full (key)); GNUNET_DHT_put (dht_handle, key, 10U, GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity), (const char *) &my_full_id, @@ -851,9 +850,8 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Starting PUT for apps\n"); - GNUNET_CONTAINER_multihashmap_iterate(applications, - &announce_application, - NULL); + GNUNET_CONTAINER_multihashmap_iterate (applications, &announce_application, + NULL); announce_applications_task = GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, &announce_applications, cls); @@ -884,7 +882,7 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) &my_full_id.hashPubKey, /* Key to use */ 10U, /* Replication level */ GNUNET_DHT_RO_RECORD_ROUTE, /* DHT options */ - GNUNET_BLOCK_TYPE_TEST, /* Block type */ + GNUNET_BLOCK_TYPE_TEST, /* Block type */ 0, /* Size of the data */ NULL, /* Data itself */ GNUNET_TIME_absolute_get_forever (), /* Data expiration */ @@ -1682,7 +1680,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, } /* Message for us? */ - if (0 == memcmp (&msg->oid, &my_full_id, sizeof(struct GNUNET_PeerIdentity))) + if (0 == memcmp (&msg->oid, &my_full_id, sizeof (struct GNUNET_PeerIdentity))) { struct GNUNET_MESH_PeerControl pc; @@ -1772,7 +1770,7 @@ delete_tunnel_entry (void *cls, const GNUNET_HashCode * key, void *value) static int deregister_app (void *cls, const GNUNET_HashCode * key, void *value) { - GNUNET_CONTAINER_multihashmap_remove(applications, key, value); + GNUNET_CONTAINER_multihashmap_remove (applications, key, value); return GNUNET_OK; } @@ -1880,12 +1878,10 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, GNUNET_DHT_get_stop (peer_info->dhtget); GNUNET_PEER_resolve (peer_info->id, &pi); peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_TEST, /* type */ - &pi.hashPubKey, /*key to search */ - 4, /* replication level */ - GNUNET_DHT_RO_RECORD_ROUTE, - NULL, /* bloom filter */ + GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_BLOCK_TYPE_TEST, /* type */ + &pi.hashPubKey, /*key to search */ + 4, /* replication level */ + GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */ 0, /* mutator */ NULL, /* xquery */ 0, /* xquery bits */ @@ -1966,7 +1962,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, return; } GNUNET_assert (NULL != t->client); - GNUNET_DHT_get_stop(t->client->dht_get_type); + GNUNET_DHT_get_stop (t->client->dht_get_type); t->client->dht_get_type = NULL; peer_info = get_peer_info (pi); GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, @@ -1976,13 +1972,9 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, /* we don't have a route to the peer, let's try a direct lookup */ if (NULL == peer_info->dhtget) { - peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_TEST, - &pi->hashPubKey, - 10U, /* replication level */ - GNUNET_DHT_RO_RECORD_ROUTE, - NULL, /* bloom filter */ + peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ + GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_BLOCK_TYPE_TEST, &pi->hashPubKey, 10U, /* replication level */ + GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */ 0, /* mutator */ NULL, /* xquery */ 0, /* xquery bits */ @@ -2050,8 +2042,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: matching client found\n"); if (NULL != c->tunnels) { - GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, - &delete_tunnel_entry, + GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, &delete_tunnel_entry, c); GNUNET_CONTAINER_multihashmap_destroy (c->tunnels); } @@ -2059,19 +2050,19 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) /* deregister clients applications */ if (NULL != c->apps) { - GNUNET_CONTAINER_multihashmap_iterate(c->apps, &deregister_app, NULL); - GNUNET_CONTAINER_multihashmap_destroy(c->apps); + GNUNET_CONTAINER_multihashmap_iterate (c->apps, &deregister_app, NULL); + GNUNET_CONTAINER_multihashmap_destroy (c->apps); } - if (0 == GNUNET_CONTAINER_multihashmap_size(applications) && + if (0 == GNUNET_CONTAINER_multihashmap_size (applications) && GNUNET_SCHEDULER_NO_TASK != announce_applications_task) { GNUNET_SCHEDULER_cancel (announce_applications_task); announce_applications_task = GNUNET_SCHEDULER_NO_TASK; } if (NULL != c->types) - GNUNET_CONTAINER_multihashmap_destroy(c->types); + GNUNET_CONTAINER_multihashmap_destroy (c->types); if (NULL != c->dht_get_type) - GNUNET_DHT_get_stop(c->dht_get_type); + GNUNET_DHT_get_stop (c->dht_get_type); GNUNET_CONTAINER_DLL_remove (clients, clients_tail, c); next = c->next; GNUNET_free (c); @@ -2126,27 +2117,21 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_MESH_ApplicationType at; GNUNET_HashCode hc; - c->apps = GNUNET_CONTAINER_multihashmap_create(napps); + c->apps = GNUNET_CONTAINER_multihashmap_create (napps); for (i = 0; i < napps; i++) { - at = ntohl(a[i]); - GNUNET_CRYPTO_hash(&at, sizeof(at), &hc); + at = ntohl (a[i]); + GNUNET_CRYPTO_hash (&at, sizeof (at), &hc); /* store in clients hashmap */ - GNUNET_CONTAINER_multihashmap_put( - c->apps, - &hc, - c, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_CONTAINER_multihashmap_put (c->apps, &hc, c, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); /* store in global hashmap, for announcements */ - GNUNET_CONTAINER_multihashmap_put( - applications, - &hc, - c, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_CONTAINER_multihashmap_put (applications, &hc, c, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } if (GNUNET_SCHEDULER_NO_TASK == announce_applications_task) - announce_applications_task = GNUNET_SCHEDULER_add_now ( - &announce_applications, NULL); + announce_applications_task = + GNUNET_SCHEDULER_add_now (&announce_applications, NULL); } if (ntypes > 0) @@ -2154,24 +2139,19 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, uint16_t u16; GNUNET_HashCode hc; - t = (uint16_t *) &a[napps]; - c->types = GNUNET_CONTAINER_multihashmap_create(ntypes); - for (i =0; i < ntypes; i++) + t = (uint16_t *) & a[napps]; + c->types = GNUNET_CONTAINER_multihashmap_create (ntypes); + for (i = 0; i < ntypes; i++) { - u16 = ntohs(t[i]); - GNUNET_CRYPTO_hash(&u16, sizeof(u16), &hc); + u16 = ntohs (t[i]); + GNUNET_CRYPTO_hash (&u16, sizeof (u16), &hc); + /* store in clients hashmap */ - GNUNET_CONTAINER_multihashmap_put( - c->types, - &hc, - c, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_CONTAINER_multihashmap_put (c->types, &hc, c, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); /* store in global hashmap */ - GNUNET_CONTAINER_multihashmap_put( - types, - &hc, - c, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_CONTAINER_multihashmap_put (types, &hc, c, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -2383,9 +2363,7 @@ handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client, /* Start DHT search if needed */ if (MESH_PEER_READY != peer_info->state && NULL == peer_info->dhtget) { - peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_TEST, - &peer_msg->peer.hashPubKey, 4, /* replication level */ + peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_BLOCK_TYPE_TEST, &peer_msg->peer.hashPubKey, 4, /* replication level */ GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */ 0, /* mutator */ NULL, /* xquery */ @@ -2517,26 +2495,27 @@ handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client, type = ntohl (connect_msg->type); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type requested: %u\n", type); GNUNET_CRYPTO_hash (&type, sizeof (GNUNET_MESH_ApplicationType), &hash); - if (GNUNET_CONTAINER_multihashmap_contains(applications, &hash) == GNUNET_YES) + if (GNUNET_CONTAINER_multihashmap_contains (applications, &hash) == + GNUNET_YES) { /* Yes! Fast forward, add ourselves to the tunnel and send the - * good news to the client - */ + * good news to the client + */ struct GNUNET_MESH_PeerControl pc; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: available locally\n"); pc.peer = my_full_id; GNUNET_CONTAINER_multihashmap_put (t->peers, &pc.peer.hashPubKey, - get_peer_info (&pc.peer), - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); + get_peer_info (&pc.peer), + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); pc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD); pc.tunnel_id = htonl (t->local_tid); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: notifying client\n"); - GNUNET_SERVER_notification_context_unicast (nc, /* context */ - client, /* dest */ - &pc.header, /* msg */ - GNUNET_NO); /* can drop? */ + GNUNET_SERVER_notification_context_unicast (nc, /* context */ + client, /* dest */ + &pc.header, /* msg */ + GNUNET_NO); /* can drop? */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Done\n"); GNUNET_SERVER_receive_done (client, GNUNET_OK); return; @@ -2546,22 +2525,13 @@ handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client, { GNUNET_DHT_get_stop (c->dht_get_type); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "MESH: looking in DHT for %s\n", - GNUNET_h2s_full(&hash)); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: looking in DHT for %s\n", + GNUNET_h2s_full (&hash)); c->dht_get_type = - GNUNET_DHT_get_start (dht_handle, - GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_TEST, - &hash, - 10U, - GNUNET_DHT_RO_RECORD_ROUTE, - NULL, - 0, - NULL, - 0, - &dht_get_type_handler, - t); + GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_BLOCK_TYPE_TEST, &hash, 10U, + GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0, NULL, 0, + &dht_get_type_handler, t); GNUNET_SERVER_receive_done (client, GNUNET_OK); return; @@ -2639,7 +2609,7 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client, /* Work around const limitation */ memcpy (©, data_msg, sizeof (struct GNUNET_MESH_Unicast)); copy.oid = my_full_id; - copy.tid = htonl(t->id.tid); + copy.tid = htonl (t->id.tid); handle_mesh_data_unicast (NULL, &my_full_id, ©.header, NULL); return; } @@ -2858,7 +2828,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { for (c = clients; NULL != c; c = c->next) if (NULL != c->dht_get_type) - GNUNET_DHT_get_stop(c->dht_get_type); + GNUNET_DHT_get_stop (c->dht_get_type); GNUNET_DHT_disconnect (dht_handle); dht_handle = NULL; } diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 615593621..8476be396 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -921,4 +921,4 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) GNUNET_free (handle); } -/* end of mesh_api.c */ \ No newline at end of file +/* end of mesh_api.c */ diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index 80228c80a..38efd8eb3 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c @@ -773,7 +773,7 @@ process_peer_event (struct GNUNET_MESH_Handle *h, GNUNET_PEER_Id id; uint16_t size; - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh: processig peer event\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: processig peer event\n"); size = ntohs (msg->header.size); if (size != sizeof (struct GNUNET_MESH_PeerControl)) { @@ -789,9 +789,9 @@ process_peer_event (struct GNUNET_MESH_Handle *h, id = GNUNET_PEER_search (&msg->peer); if ((p = retrieve_peer (t, id)) == NULL) p = add_peer_to_tunnel (t, &msg->peer); - if (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD == ntohs(msg->header.type)) + if (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD == ntohs (msg->header.type)) { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh: adding peer\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: adding peer\n"); if (NULL != t->connect_handler) { atsi.type = 0; @@ -802,7 +802,7 @@ process_peer_event (struct GNUNET_MESH_Handle *h, } else { - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh: removing peer\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: removing peer\n"); if (NULL != t->disconnect_handler && p->connected) { t->disconnect_handler (t->cls, &msg->peer); @@ -810,7 +810,7 @@ process_peer_event (struct GNUNET_MESH_Handle *h, remove_peer_from_tunnel (p); GNUNET_free (p); } - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh: processing peer event END\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: processing peer event END\n"); } @@ -1165,12 +1165,13 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, apps = (GNUNET_MESH_ApplicationType *) &msg[1]; for (napps = 0; napps < h->n_applications; napps++) { - apps[napps] = htonl(h->applications[napps]); - GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "mesh: app %u\n", h->applications[napps]); + apps[napps] = htonl (h->applications[napps]); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: app %u\n", + h->applications[napps]); } - types = (uint16_t *) &apps[napps]; + types = (uint16_t *) & apps[napps]; for (ntypes = 0; ntypes < h->n_handlers; ntypes++) - types[ntypes] = htons(h->message_handlers[ntypes].type); + types[ntypes] = htons (h->message_handlers[ntypes].type); msg->applications = htons (napps); msg->types = htons (ntypes); #if DEBUG diff --git a/src/mesh/test_mesh_local_1.c b/src/mesh/test_mesh_local_1.c index 4e8d0b78e..5c45f2895 100644 --- a/src/mesh/test_mesh_local_1.c +++ b/src/mesh/test_mesh_local_1.c @@ -107,9 +107,9 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ static int data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, - const struct GNUNET_PeerIdentity *sender, - const struct GNUNET_MessageHeader *message, - const struct GNUNET_TRANSPORT_ATS_Information *atsi) + const struct GNUNET_PeerIdentity *sender, + const struct GNUNET_MessageHeader *message, + const struct GNUNET_TRANSPORT_ATS_Information *atsi) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Data callback\n"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply @@ -140,7 +140,7 @@ inbound_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, if (id != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "test: received incoming tunnel on peer 2\n"); + "test: received incoming tunnel on peer 2\n"); result = GNUNET_SYSERR; } return NULL; @@ -157,8 +157,7 @@ inbound_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, * with the tunnel is stored */ static void -inbound_end (void *cls, - const struct GNUNET_MESH_Tunnel * tunnel, +inbound_end (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx) { unsigned int id = *(unsigned int *) cls; @@ -167,7 +166,7 @@ inbound_end (void *cls, if (id != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "test: received closing tunnel on peer 2\n"); + "test: received closing tunnel on peer 2\n"); result = GNUNET_SYSERR; } } @@ -179,13 +178,12 @@ inbound_end (void *cls, * @param cls closure * @param peer peer identity the tunnel stopped working with */ -static void peer_conected ( - void *cls, - const struct GNUNET_PeerIdentity * peer, - const struct GNUNET_TRANSPORT_ATS_Information * atsi) +static void +peer_conected (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_TRANSPORT_ATS_Information *atsi) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer connected\n"); - GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &do_shutdown, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown, NULL); } @@ -196,9 +194,8 @@ static void peer_conected ( * @param peer peer identity the tunnel was created to, NULL on timeout * @param atsi performance data for the connection */ -static void peer_disconnected ( - void *cls, - const struct GNUNET_PeerIdentity * peer) +static void +peer_disconnected (void *cls, const struct GNUNET_PeerIdentity *peer) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer disconnected\n"); } @@ -225,7 +222,7 @@ static struct GNUNET_MESH_MessageHandler handlers2[] = { {NULL, 0, 0} }; static void do_find (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_MESH_peer_request_connect_by_type(t, 1); + GNUNET_MESH_peer_request_connect_by_type (t, 1); } @@ -265,12 +262,9 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: YAY! CONNECTED TO MESH :D\n"); } - t = GNUNET_MESH_tunnel_create (mesh_peer_2, - NULL, - &peer_conected, - &peer_disconnected, - (void *) &two); - GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &do_find, NULL); + t = GNUNET_MESH_tunnel_create (mesh_peer_2, NULL, &peer_conected, + &peer_disconnected, (void *) &two); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_find, NULL); } diff --git a/src/mesh/test_mesh_local_2.c b/src/mesh/test_mesh_local_2.c index 9da611bf4..b29921dd3 100644 --- a/src/mesh/test_mesh_local_2.c +++ b/src/mesh/test_mesh_local_2.c @@ -80,7 +80,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n"); if (0 != test_task) { GNUNET_SCHEDULER_cancel (test_task); @@ -105,9 +105,9 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) */ static int data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, - const struct GNUNET_PeerIdentity *sender, - const struct GNUNET_MessageHeader *message, - const struct GNUNET_TRANSPORT_ATS_Information *atsi) + const struct GNUNET_PeerIdentity *sender, + const struct GNUNET_MessageHeader *message, + const struct GNUNET_TRANSPORT_ATS_Information *atsi) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Data callback\n"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply @@ -138,7 +138,7 @@ inbound_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, if (id != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "test: received incoming tunnel on peer 2\n"); + "test: received incoming tunnel on peer 2\n"); result = GNUNET_SYSERR; } return NULL; @@ -155,8 +155,7 @@ inbound_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, * with the tunnel is stored */ static void -inbound_end (void *cls, - const struct GNUNET_MESH_Tunnel * tunnel, +inbound_end (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx) { unsigned int id = (unsigned int) cls; @@ -165,7 +164,7 @@ inbound_end (void *cls, if (id != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "test: received closing tunnel on peer 2\n"); + "test: received closing tunnel on peer 2\n"); result = GNUNET_SYSERR; } } @@ -177,12 +176,11 @@ inbound_end (void *cls, * @param cls closure * @param peer peer identity the tunnel stopped working with */ -static void peer_conected ( - void *cls, - const struct GNUNET_PeerIdentity * peer) +static void +peer_conected (void *cls, const struct GNUNET_PeerIdentity *peer) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer connected\n"); - GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, &do_shutdown, NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown, NULL); } @@ -193,10 +191,9 @@ static void peer_conected ( * @param peer peer identity the tunnel was created to, NULL on timeout * @param atsi performance data for the connection */ -static void peer_disconnected ( - void *cls, - const struct GNUNET_PeerIdentity * peer, - const struct GNUNET_TRANSPORT_ATS_Information * atsi) +static void +peer_disconnected (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_TRANSPORT_ATS_Information *atsi) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: peer disconnected\n"); } @@ -265,15 +262,12 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: YAY! CONNECTED TO MESH :D\n"); } - t = GNUNET_MESH_tunnel_create (mesh_peer_2, - NULL, - &peer_conected, - &peer_disconnected, - (void *) 2); - GNUNET_MESH_peer_request_connect_by_type(t, 1); - test_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, - &do_connect_peer_1, - cfg); + t = GNUNET_MESH_tunnel_create (mesh_peer_2, NULL, &peer_conected, + &peer_disconnected, (void *) 2); + GNUNET_MESH_peer_request_connect_by_type (t, 1); + test_task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + &do_connect_peer_1, cfg); } diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index eaaac0c38..00ab22993 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c @@ -158,7 +158,7 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_PEERINFO_disconnect (peerinfo); return; } - if ( (be_quiet) || (NULL == hello) ) + if ((be_quiet) || (NULL == hello)) { GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc); printf ("%s\n", (const char *) &enc); diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index fd14f76be..a31449a71 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c @@ -116,8 +116,8 @@ my_cb2 (void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n", GNUNET_i2s (id)); #endif - cc = GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, GNUNET_YES, - &my_connect_complete, NULL); + cc = GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, + GNUNET_YES, &my_connect_complete, NULL); } diff --git a/src/testing/test_testing_reconnect.c b/src/testing/test_testing_reconnect.c index 36675012f..d12e29e78 100644 --- a/src/testing/test_testing_reconnect.c +++ b/src/testing/test_testing_reconnect.c @@ -146,8 +146,8 @@ my_cb2 (void *cls, const struct GNUNET_PeerIdentity *id, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Daemon `%s' started.\n", GNUNET_i2s (id)); #endif - cc = GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, GNUNET_YES, - &my_connect_complete, NULL); + cc = GNUNET_TESTING_daemons_connect (d1, d2, TIMEOUT, CONNECT_ATTEMPTS, + GNUNET_YES, &my_connect_complete, NULL); } diff --git a/src/testing/testing.c b/src/testing/testing.c index 65446eb77..335457dcb 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -88,6 +88,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) { struct GNUNET_TESTING_Daemon *daemon = cls; int msize; + #if EMPTY_HACK int empty; @@ -1870,7 +1871,8 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else if (ctx->connect_attempts > 0) { ctx->d1core_ready = GNUNET_NO; - ctx->timeout_task = GNUNET_SCHEDULER_add_now (&reattempt_daemons_connect, ctx); + ctx->timeout_task = + GNUNET_SCHEDULER_add_now (&reattempt_daemons_connect, ctx); return; } else @@ -1907,12 +1909,12 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, if (0 != memcmp (&ctx->d2->id, peer, sizeof (struct GNUNET_PeerIdentity))) return; ctx->connected = GNUNET_YES; - ctx->distance = 0; /* FIXME: distance */ + ctx->distance = 0; /* FIXME: distance */ if (ctx->hello_send_task != GNUNET_SCHEDULER_NO_TASK) - { - GNUNET_SCHEDULER_cancel (ctx->hello_send_task); - ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; - } + { + GNUNET_SCHEDULER_cancel (ctx->hello_send_task); + ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; + } GNUNET_SCHEDULER_cancel (ctx->timeout_task); ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); } @@ -2130,74 +2132,72 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer, return; } if (peer != NULL) - return; /* ignore other peers */ + return; /* ignore other peers */ /* peer == NULL: End of iteration over peers */ - - GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ctx->timeout_task); - if (ctx->connected == GNUNET_YES) - { - ctx->timeout_task = - GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); - return; - } - /* Peer not already connected, need to schedule connect request! */ - if (ctx->d1core == NULL) - { + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ctx->timeout_task); + if (ctx->connected == GNUNET_YES) + { + ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); + return; + } + + /* Peer not already connected, need to schedule connect request! */ + if (ctx->d1core == NULL) + { #if DEBUG_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peers are NOT connected, connecting to core!\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Peers are NOT connected, connecting to core!\n"); #endif - ctx->d1core = - GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify, - &connect_notify, NULL, NULL, NULL, GNUNET_NO, - NULL, GNUNET_NO, no_handlers); - } + ctx->d1core = + GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify, + &connect_notify, NULL, NULL, NULL, GNUNET_NO, NULL, + GNUNET_NO, no_handlers); + } + + if (ctx->d1core == NULL) + { + ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); + return; + } - if (ctx->d1core == NULL) + if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) /* Do not yet have the second peer's hello, set up a task to get it */ + { + ctx->d2->th = + GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL, + NULL); + if (ctx->d2->th == NULL) { + GNUNET_CORE_disconnect (ctx->d1core); + ctx->d1core = NULL; ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); return; } + ctx->d2->ghh = + GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); + } - if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL)) /* Do not yet have the second peer's hello, set up a task to get it */ - { - ctx->d2->th = - GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, - NULL, NULL); - if (ctx->d2->th == NULL) - { - GNUNET_CORE_disconnect (ctx->d1core); - ctx->d1core = NULL; - ctx->timeout_task = - GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); - return; - } - ctx->d2->ghh = - GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2); - } - - if (ctx->send_hello == GNUNET_YES) + if (ctx->send_hello == GNUNET_YES) + { + ctx->d1th = + GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL, + NULL, NULL); + if (ctx->d1th == NULL) { - ctx->d1th = - GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL, - NULL, NULL); - if (ctx->d1th == NULL) - { - GNUNET_CORE_disconnect (ctx->d1core); - ctx->d1core = NULL; - ctx->timeout_task = + GNUNET_CORE_disconnect (ctx->d1core); + ctx->d1core = NULL; + ctx->timeout_task = GNUNET_SCHEDULER_add_now (¬ify_connect_result, ctx); - return; - } - GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ctx->hello_send_task); - ctx->hello_send_task = GNUNET_SCHEDULER_add_now (&send_hello, ctx); + return; } + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == ctx->hello_send_task); + ctx->hello_send_task = GNUNET_SCHEDULER_add_now (&send_hello, ctx); + } - ctx->timeout_task = - GNUNET_SCHEDULER_add_delayed (ctx->relative_timeout, - ¬ify_connect_result, ctx); + ctx->timeout_task = + GNUNET_SCHEDULER_add_delayed (ctx->relative_timeout, + ¬ify_connect_result, ctx); } @@ -2271,29 +2271,28 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, * @param cc connect context */ void -GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext - *cc) +GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext *cc) { if (GNUNET_SCHEDULER_NO_TASK != cc->timeout_task) - { - GNUNET_SCHEDULER_cancel (cc->timeout_task); - cc->timeout_task = GNUNET_SCHEDULER_NO_TASK; - } + { + GNUNET_SCHEDULER_cancel (cc->timeout_task); + cc->timeout_task = GNUNET_SCHEDULER_NO_TASK; + } if (GNUNET_SCHEDULER_NO_TASK != cc->hello_send_task) - { - GNUNET_SCHEDULER_cancel (cc->hello_send_task); - cc->hello_send_task = GNUNET_SCHEDULER_NO_TASK; - } + { + GNUNET_SCHEDULER_cancel (cc->hello_send_task); + cc->hello_send_task = GNUNET_SCHEDULER_NO_TASK; + } if (NULL != cc->d1core) - { - GNUNET_CORE_disconnect (cc->d1core); - cc->d1core = NULL; - } + { + GNUNET_CORE_disconnect (cc->d1core); + cc->d1core = NULL; + } if (NULL != cc->d1th) - { - GNUNET_TRANSPORT_disconnect (cc->d1th); - cc->d1th = NULL; - } + { + GNUNET_TRANSPORT_disconnect (cc->d1th); + cc->d1th = NULL; + } GNUNET_free (cc); } diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index c81373025..4ace9f055 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -893,7 +893,7 @@ struct ConnectContext /** * Context in 'testing.c', to cancel connection attempt. - */ + */ struct GNUNET_TESTING_ConnectContext *cc; /** @@ -3231,10 +3231,9 @@ preschedule_connect (struct GNUNET_TESTING_PeerGroup *pg) connect_context->first_index = random_peer; connect_context->second_index = connection_iter->index; connect_context->ct_ctx = ct_ctx; - connect_context->task = GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); - GNUNET_CONTAINER_DLL_insert (pg->cc_head, - pg->cc_tail, - connect_context); + connect_context->task = + GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); + GNUNET_CONTAINER_DLL_insert (pg->cc_head, pg->cc_tail, connect_context); GNUNET_CONTAINER_DLL_remove (pg->peers[random_peer].connect_peers_head, pg->peers[random_peer].connect_peers_tail, connection_iter); @@ -3639,9 +3638,7 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first, connect_ctx->cc = NULL; GNUNET_assert (0 < pg->outstanding_connects); pg->outstanding_connects--; - GNUNET_CONTAINER_DLL_remove (pg->cc_head, - pg->cc_tail, - connect_ctx); + GNUNET_CONTAINER_DLL_remove (pg->cc_head, pg->cc_tail, connect_ctx); /* * Check whether the inverse connection has been scheduled yet, * if not, we can remove it from the other peers list and avoid @@ -3719,33 +3716,36 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) _ ("Delaying connect, we have too many outstanding connections!\n")); #endif - connect_context->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_MILLISECONDS, 100), - &schedule_connect, connect_context); + connect_context->task = + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply + (GNUNET_TIME_UNIT_MILLISECONDS, 100), + &schedule_connect, connect_context); return; } #if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("Creating connection, outstanding_connections is %d (max %d)\n"), - pg->outstanding_connects, pg->max_outstanding_connections); -#endif - pg->outstanding_connects++; - pg->total_connects_scheduled++; - GNUNET_assert (NULL == connect_context->cc); - connect_context->cc - = GNUNET_TESTING_daemons_connect (pg-> - peers[connect_context->first_index].daemon, - pg->peers[connect_context-> - second_index].daemon, - connect_context->ct_ctx->connect_timeout, - connect_context->ct_ctx->connect_attempts, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _ + ("Creating connection, outstanding_connections is %d (max %d)\n"), + pg->outstanding_connects, pg->max_outstanding_connections); +#endif + pg->outstanding_connects++; + pg->total_connects_scheduled++; + GNUNET_assert (NULL == connect_context->cc); + connect_context->cc = + GNUNET_TESTING_daemons_connect (pg-> + peers[connect_context-> + first_index].daemon, + pg->peers[connect_context-> + second_index].daemon, + connect_context->ct_ctx->connect_timeout, + connect_context->ct_ctx->connect_attempts, #if USE_SEND_HELLOS - GNUNET_NO, + GNUNET_NO, #else - GNUNET_YES, + GNUNET_YES, #endif - &internal_connect_notify, connect_context); + &internal_connect_notify, + connect_context); } @@ -3772,10 +3772,10 @@ connect_iterator (void *cls, const GNUNET_HashCode * key, void *value) connect_context->first = first->daemon; connect_context->second = second; connect_context->ct_ctx = ct_ctx; - connect_context->task = GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); - GNUNET_CONTAINER_DLL_insert (ct_ctx->pg->cc_head, - ct_ctx->pg->cc_tail, - connect_context); + connect_context->task = + GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context); + GNUNET_CONTAINER_DLL_insert (ct_ctx->pg->cc_head, ct_ctx->pg->cc_tail, + connect_context); return GNUNET_YES; } #endif @@ -7103,16 +7103,14 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_assert (pg->total > 0); while (NULL != (cc = pg->cc_head)) - { - GNUNET_CONTAINER_DLL_remove (pg->cc_head, - pg->cc_tail, - cc); - if (GNUNET_SCHEDULER_NO_TASK != cc->task) - GNUNET_SCHEDULER_cancel (cc->task); - if (NULL != cc->cc) - GNUNET_TESTING_daemons_connect_cancel (cc->cc); - GNUNET_free (cc); - } + { + GNUNET_CONTAINER_DLL_remove (pg->cc_head, pg->cc_tail, cc); + if (GNUNET_SCHEDULER_NO_TASK != cc->task) + GNUNET_SCHEDULER_cancel (cc->task); + if (NULL != cc->cc) + GNUNET_TESTING_daemons_connect_cancel (cc->cc); + GNUNET_free (cc); + } shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext)); shutdown_ctx->delete_files = diff --git a/src/topology/test_gnunet_daemon_topology.c b/src/topology/test_gnunet_daemon_topology.c index 6d3645f01..49990788a 100644 --- a/src/topology/test_gnunet_daemon_topology.c +++ b/src/topology/test_gnunet_daemon_topology.c @@ -81,14 +81,14 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { unsigned int i; - for (i=0;imessage_size); #endif #if DEBUG_wlan_msg_dump - hexdump(msgbuf,GNUNET_MIN(msgbuf_size, 256)); + hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256)); #endif //queue session queue_session (plugin, session); @@ -2239,7 +2239,8 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr) else { GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, - "wlan_data_message_handler got wrong message type: %u\n", ntohs (hdr->size)); + "wlan_data_message_handler got wrong message type: %u\n", + ntohs (hdr->size)); return; } } @@ -2665,12 +2666,11 @@ wlan_process_helper (void *cls, void *client, #if DEBUG_wlan GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Func wlan_process_helper got unknown message with number %u, size %u\n", - ntohs (hdr->type), - ntohs (hdr->size)); + ntohs (hdr->type), ntohs (hdr->size)); #endif #if DEBUG_wlan_msg_dump - hexdump(hdr,GNUNET_MIN(ntohs (hdr->size), 256)); + hexdump (hdr, GNUNET_MIN (ntohs (hdr->size), 256)); #endif GNUNET_break (0); return; @@ -2754,25 +2754,25 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) filenamehw, plugin->interface, testmode); #endif - if (GNUNET_OS_check_helper_binary(filenamehw) == GNUNET_YES) - { + if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES) + { plugin->server_proc = - GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, - filenamehw, filenamehw, plugin->interface, - NULL); - } - else if (GNUNET_OS_check_helper_binary(filenamehw) == GNUNET_NO) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, - "gnunet-transport-wlan-helper is not suid, please change it or look at the doku\n"); - GNUNET_break(0); - } + GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, + filenamehw, filenamehw, plugin->interface, + NULL); + } + else if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_NO) + { + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, + "gnunet-transport-wlan-helper is not suid, please change it or look at the doku\n"); + GNUNET_break (0); + } else - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, - "gnunet-transport-wlan-helper not found, please look if it exists and is the $PATH variable!\n"); - GNUNET_break(0); - } + { + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, + "gnunet-transport-wlan-helper not found, please look if it exists and is the $PATH variable!\n"); + GNUNET_break (0); + } } else if (testmode == 1) @@ -2784,18 +2784,19 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) filenameloopback, plugin->interface, testmode); #endif - if (GNUNET_OS_check_helper_binary(filenameloopback) != GNUNET_SYSERR) - { + if (GNUNET_OS_check_helper_binary (filenameloopback) != GNUNET_SYSERR) + { plugin->server_proc = - GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, - filenameloopback, filenameloopback, "1", NULL); - } + GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, + filenameloopback, filenameloopback, "1", + NULL); + } else - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, - "gnunet-transport-wlan-helper-dummy not found, please look if it exists and is the $PATH variable!\n"); - GNUNET_break(0); - } + { + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, + "gnunet-transport-wlan-helper-dummy not found, please look if it exists and is the $PATH variable!\n"); + GNUNET_break (0); + } } else if (testmode == 2) { @@ -2804,18 +2805,19 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin, int testmode) "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n", filenameloopback, plugin->interface, testmode); #endif - if (GNUNET_OS_check_helper_binary(filenameloopback) != GNUNET_SYSERR) - { - plugin->server_proc = - GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, - filenameloopback, filenameloopback, "2", NULL); - } + if (GNUNET_OS_check_helper_binary (filenameloopback) != GNUNET_SYSERR) + { + plugin->server_proc = + GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, + filenameloopback, filenameloopback, "2", + NULL); + } else - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, - "gnunet-transport-wlan-helper-dummy not found, please look if it exists and is in the $PATH variable!\n"); - GNUNET_break(0); - } + { + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, + "gnunet-transport-wlan-helper-dummy not found, please look if it exists and is in the $PATH variable!\n"); + GNUNET_break (0); + } } if (plugin->server_proc == NULL) { diff --git a/src/transport/test_plugin_transport_wlan_dummy.c b/src/transport/test_plugin_transport_wlan_dummy.c index 077fdac29..c8d9ea21b 100644 --- a/src/transport/test_plugin_transport_wlan_dummy.c +++ b/src/transport/test_plugin_transport_wlan_dummy.c @@ -163,13 +163,13 @@ testmode (int argc, char *argv[]) erg = mkfifo (FIFO_FILE1, 0666); if (0 != erg) { - fprintf (stderr, "Error at mkfifo1: %s\n", strerror(errno)); + fprintf (stderr, "Error at mkfifo1: %s\n", strerror (errno)); //exit(1); } erg = mkfifo (FIFO_FILE2, 0666); if (0 != erg) { - fprintf (stderr, "Error at mkfifo2: %s\n", strerror(errno)); + fprintf (stderr, "Error at mkfifo2: %s\n", strerror (errno)); //exit(1); } diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c index 0dc6c2a86..9e7bdb9b6 100644 --- a/src/transport/test_transport_api_limited_sockets.c +++ b/src/transport/test_transport_api_limited_sockets.c @@ -284,6 +284,7 @@ main (int argc, char *argv[]) { int ret = 0; int nat_res; + test_plugin = NULL; GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); @@ -299,8 +300,9 @@ main (int argc, char *argv[]) #endif NULL); - if ((test_plugin != NULL) && ((strcmp (test_plugin, "tcp_nat") == 0) || - (strcmp (test_plugin, "udp_nat") == 0))) + if ((test_plugin != NULL) && + ((strcmp (test_plugin, "tcp_nat") == 0) || + (strcmp (test_plugin, "udp_nat") == 0))) { nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server"); if (GNUNET_NO == nat_res) @@ -329,13 +331,17 @@ main (int argc, char *argv[]) struct rlimit r_file_old; struct rlimit r_file_new; int res; - res = getrlimit(RLIMIT_NOFILE, &r_file_old); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Maximum number of open files was: %u/%u\n", r_file_old.rlim_cur, r_file_old.rlim_max); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting maximum number of open files to: %u\n", MAX_FILES); + res = getrlimit (RLIMIT_NOFILE, &r_file_old); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Maximum number of open files was: %u/%u\n", r_file_old.rlim_cur, + r_file_old.rlim_max); + + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Setting maximum number of open files to: %u\n", MAX_FILES); r_file_new.rlim_cur = MAX_FILES; r_file_new.rlim_max = r_file_old.rlim_max; - res = setrlimit(RLIMIT_NOFILE, &r_file_new); + res = setrlimit (RLIMIT_NOFILE, &r_file_new); if (res != 0) { @@ -360,8 +366,9 @@ main (int argc, char *argv[]) GNUNET_free (test_name); #if HAVE_SETRLIMIT - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Restoring previous value maximum number of open files\n"); - res = setrlimit(RLIMIT_NOFILE, &r_file_old); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Restoring previous value maximum number of open files\n"); + res = setrlimit (RLIMIT_NOFILE, &r_file_old); if (res != 0) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Restoring limit failed!\n"); diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index a760f4775..968a4324f 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c @@ -140,8 +140,8 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } client = GNUNET_CLIENT_connect ("transport", cfg); - if (client == NULL) - return NULL; + if (client == NULL) + return NULL; msg = GNUNET_malloc (len); msg->header.size = htons (len); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_LOOKUP); @@ -172,7 +172,9 @@ GNUNET_TRANSPORT_address_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param alc handle for the request to cancel */ void -GNUNET_TRANSPORT_address_lookup_cancel (struct GNUNET_TRANSPORT_AddressLookupContext *alc) +GNUNET_TRANSPORT_address_lookup_cancel (struct + GNUNET_TRANSPORT_AddressLookupContext + *alc) { GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); GNUNET_free (alc); diff --git a/src/transport/transport_api_peer_address_lookup.c b/src/transport/transport_api_peer_address_lookup.c index 83ed074a3..a564058ce 100644 --- a/src/transport/transport_api_peer_address_lookup.c +++ b/src/transport/transport_api_peer_address_lookup.c @@ -141,12 +141,13 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle client = GNUNET_CLIENT_connect ("transport", cfg); if (client == NULL) - return NULL; + return NULL; msg.header.size = htons (sizeof (struct PeerAddressLookupMessage)); msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PEER_ADDRESS_LOOKUP); msg.timeout = GNUNET_TIME_relative_hton (timeout); memcpy (&msg.peer, peer, sizeof (struct GNUNET_PeerIdentity)); - alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerAddressLookupContext)); + alc = + GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerAddressLookupContext)); alc->cb = peer_address_callback; alc->cb_cls = peer_address_callback_cls; alc->timeout = GNUNET_TIME_relative_to_absolute (timeout); @@ -166,7 +167,9 @@ GNUNET_TRANSPORT_peer_address_lookup (const struct GNUNET_CONFIGURATION_Handle * @param alc handle for the request to cancel */ void -GNUNET_TRANSPORT_peer_address_lookup_cancel (struct GNUNET_TRANSPORT_PeerAddressLookupContext *alc) +GNUNET_TRANSPORT_peer_address_lookup_cancel (struct + GNUNET_TRANSPORT_PeerAddressLookupContext + *alc) { GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); GNUNET_free (alc); diff --git a/src/transport/wlan/helper_common.c b/src/transport/wlan/helper_common.c index 6a7a5da09..8e1c59421 100644 --- a/src/transport/wlan/helper_common.c +++ b/src/transport/wlan/helper_common.c @@ -34,12 +34,12 @@ * @return number of bytes written */ int -send_mac_to_plugin (char *buffer, struct MacAddress * mac) +send_mac_to_plugin (char *buffer, struct MacAddress *mac) { struct Wlan_Helper_Control_Message macmsg; - memcpy (&macmsg.mac,(char *) mac, sizeof (struct MacAddress)); + memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c index a7ab160ea..29850b446 100644 --- a/src/vpn/gnunet-daemon-vpn-helper.c +++ b/src/vpn/gnunet-daemon-vpn-helper.c @@ -355,9 +355,10 @@ message_token (void *cls __attribute__ ((unused)), void *client app_type = GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY; if (NULL != tcp_tunnel) me->tunnel = tcp_tunnel; - } else + } + else { - GNUNET_assert (0); + GNUNET_assert (0); } if (me->tunnel == NULL && NULL != cls) { @@ -489,17 +490,17 @@ message_token (void *cls __attribute__ ((unused)), void *client /* This is a mapping to a gnunet-service */ memcpy (hc, &me->desc.service_descriptor, sizeof (GNUNET_HashCode)); - if ( (IPPROTO_UDP == pkt->ip_hdr.proto) && - (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)) && - (port_in_ports (me->desc.ports, pkt_udp->udp_hdr.dpt) || - testBit (me->additional_ports, ntohs (pkt_udp->udp_hdr.dpt))) ) + if ((IPPROTO_UDP == pkt->ip_hdr.proto) && + (me->desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_UDP)) && + (port_in_ports (me->desc.ports, pkt_udp->udp_hdr.dpt) || + testBit (me->additional_ports, ntohs (pkt_udp->udp_hdr.dpt)))) { hdr->type = ntohs (GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP); memcpy (hc + 1, &pkt_udp->udp_hdr, ntohs (pkt_udp->udp_hdr.len)); } - else if ( (IPPROTO_TCP == pkt->ip_hdr.proto) && + else if ((IPPROTO_TCP == pkt->ip_hdr.proto) && (me-> desc.service_type & htonl (GNUNET_DNS_SERVICE_TYPE_TCP)) && (port_in_ports (me->desc.ports, pkt_tcp->tcp_hdr.dpt))) diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c index bdbf7e001..271c8a772 100644 --- a/src/vpn/gnunet-service-dns.c +++ b/src/vpn/gnunet-service-dns.c @@ -1265,16 +1265,14 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section) if ((strlen (section) < 8) || (0 != strcmp (".gnunet.", section + (strlen (section) - 8)))) return; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Parsing dns-name %s\n", - section); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing dns-name %s\n", section); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, "UDP_REDIRECTS", - &udp_redirects)) + &udp_redirects)) udp_redirects = NULL; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, "TCP_REDIRECTS", - &tcp_redirects)) + &tcp_redirects)) tcp_redirects = NULL; if (GNUNET_OK != @@ -1307,21 +1305,21 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section) publish_name (section, ports, service_type, my_private_key); if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, section, "ALTERNATIVE_NAMES", - &alternative_names)) + &alternative_names)) + { + for (alternative_name = strtok (alternative_names, " "); + alternative_name != NULL; alternative_name = strtok (NULL, " ")) { - for (alternative_name = strtok (alternative_names, " "); - alternative_name != NULL; alternative_name = strtok (NULL, " ")) - { - char *altname = - alloca (strlen (alternative_name) + strlen (section) + 1 + 1); - strcpy (altname, alternative_name); - strcpy (altname + strlen (alternative_name) + 1, section); - altname[strlen (alternative_name)] = '.'; - - publish_name (altname, ports, service_type, my_private_key); - } - GNUNET_free (alternative_names); + char *altname = + alloca (strlen (alternative_name) + strlen (section) + 1 + 1); + strcpy (altname, alternative_name); + strcpy (altname + strlen (alternative_name) + 1, section); + altname[strlen (alternative_name)] = '.'; + + publish_name (altname, ports, service_type, my_private_key); } + GNUNET_free (alternative_names); + } GNUNET_CRYPTO_rsa_key_free (my_private_key); GNUNET_free_non_null (udp_redirects); GNUNET_free_non_null (tcp_redirects); -- cgit v1.2.3