(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,
"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");
}
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;
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
}
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)
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",
/* 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");
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");
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");
* @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;
}
{
if (stats == NULL)
return;
- GNUNET_STATISTICS_update (stats, value, 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (stats, value, 1, GNUNET_NO);
}
{
if (stats == NULL)
return;
- GNUNET_STATISTICS_update (stats, value, -1, GNUNET_NO);
+ GNUNET_STATISTICS_update (stats, value, -1, GNUNET_NO);
}
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,
#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;
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");
{
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
{
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;
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;
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 */
}
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++)
{
continue; /* Ignore bloomfiltered peers */
}
if (0 == selected--)
- return pos;
+ return pos;
pos = pos->next;
}
}
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;
}
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);
}
"%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);
}
"%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
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;
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];
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 */
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;
}
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;
}
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 =
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;
}
* "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
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;
}
* @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);
/**
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;
}
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);
}
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);
}
{
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))
{
}
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);
}
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))
{
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);
}
* @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);
/**
*/
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,
* @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);
/**
* @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);
* @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);
* 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,
/**
* Handle to cancel a pending address lookup.
- */
+ */
struct GNUNET_TRANSPORT_AddressLookupContext;
* @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;
* @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_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);
}
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,
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);
&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 */
}
/* 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;
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;
}
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 */
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,
/* 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 */
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);
}
/* 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);
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)
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,
/* 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 */
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;
{
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;
/* 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;
}
{
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;
}
GNUNET_free (handle);
}
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c */
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))
{
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;
}
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);
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");
}
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
*/
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
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;
* 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;
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;
}
}
* @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);
}
* @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");
}
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);
}
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);
}
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);
*/
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
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;
* 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;
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;
}
}
* @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);
}
* @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");
}
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);
}
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);
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);
}
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);
}
{
struct GNUNET_TESTING_Daemon *daemon = cls;
int msize;
+
#if EMPTY_HACK
int empty;
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
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);
}
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);
}
* @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);
}
/**
* Context in 'testing.c', to cancel connection attempt.
- */
+ */
struct GNUNET_TESTING_ConnectContext *cc;
/**
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);
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
_
("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);
}
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
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 =
{
unsigned int i;
- for (i=0;i<NUM_PEERS;i++)
+ for (i = 0; i < NUM_PEERS; i++)
+ {
+ if (NULL != cc[i])
{
- if (NULL != cc[i])
- {
- GNUNET_TESTING_daemons_connect_cancel (cc[i]);
- cc[i] = NULL;
- }
+ GNUNET_TESTING_daemons_connect_cancel (cc[i]);
+ cc[i] = NULL;
}
+ }
GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 0;
}
if (NULL != emsg)
{
fprintf (stderr, "Failed to connect two peers: %s\n", emsg);
- for (i=0;i<NUM_PEERS;i++)
+ for (i = 0; i < NUM_PEERS; i++)
if (NULL != cc[i])
- {
- GNUNET_TESTING_daemons_connect_cancel (cc[i]);
- cc[i] = NULL;
- }
+ {
+ GNUNET_TESTING_daemons_connect_cancel (cc[i]);
+ cc[i] = NULL;
+ }
GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
GNUNET_assert (0);
return;
last = d;
return;
}
- cc[peers_left] = GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
- GNUNET_YES, ¬ify_connect_complete, &cc[peers_left]);
+ cc[peers_left] =
+ GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
+ GNUNET_YES, ¬ify_connect_complete,
+ &cc[peers_left]);
if (peers_left == 0)
{
/* close circle */
- cc[NUM_PEERS-1] = GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
- GNUNET_YES, ¬ify_connect_complete, &cc[NUM_PEERS-1]);
+ cc[NUM_PEERS - 1] =
+ GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
+ GNUNET_YES, ¬ify_connect_complete,
+ &cc[NUM_PEERS - 1]);
}
}
GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
&neighbour_timeout_task, n);
connect_msg.header.size = htons (sizeof (struct SessionConnectMessage));
- connect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT);
+ connect_msg.header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT);
connect_msg.reserved = htonl (0);
- connect_msg.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
+ connect_msg.timestamp =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg),
GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
}
session, newmsg->message_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);
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;
}
}
#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;
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)
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)
{
"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)
{
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);
}
{
int ret = 0;
int nat_res;
+
test_plugin = NULL;
GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
#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)
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)
{
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");
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);
* @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);
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);
* @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);
* @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);
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)
{
/* 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)))
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 !=
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);