#include "core.h"
-#define DEBUG_HANDSHAKE GNUNET_NO
+#define DEBUG_HANDSHAKE GNUNET_EXTRA_LOGGING
-#define DEBUG_CORE_QUOTA GNUNET_NO
+#define DEBUG_CORE_QUOTA GNUNET_EXTRA_LOGGING
/**
* Receive and send buffer windows grow over time. For
/**
* After how much time past the "official" expiration time do
- * we discard messages? Should not be zero since we may
+ * we discard messages? Should not be zero since we may
* intentionally defer transmission until close to the deadline
* and then may be slightly past the deadline due to inaccuracy
* in sleep and our own CPU consumption.
/**
- * Record kept for each request for transmission issued by a
+ * Record kept for each request for transmission issued by a
* client that is still pending.
*/
struct ClientActiveRequest;
struct MessageEntry *encrypted_tail;
/**
- * Head of list of requests from clients for transmission to
+ * Head of list of requests from clients for transmission to
* this peer.
*/
struct ClientActiveRequest *active_client_request_head;
/**
- * Tail of list of requests from clients for transmission to
+ * Tail of list of requests from clients for transmission to
* this peer.
*/
struct ClientActiveRequest *active_client_request_tail;
/**
- * Record kept for each request for transmission issued by a
+ * Record kept for each request for transmission issued by a
* client that is still pending.
*/
struct ClientActiveRequest
*/
static void
derive_auth_key (struct GNUNET_CRYPTO_AuthKey *akey,
- const struct GNUNET_CRYPTO_AesSessionKey *skey,
- uint32_t seed, struct GNUNET_TIME_Absolute creation_time)
+ const struct GNUNET_CRYPTO_AesSessionKey *skey, uint32_t seed,
+ struct GNUNET_TIME_Absolute creation_time)
{
static const char ctx[] = "authentication key";
struct GNUNET_TIME_AbsoluteNBO ctbe;
ctbe = GNUNET_TIME_absolute_hton (creation_time);
- GNUNET_CRYPTO_hmac_derive_key (akey,
- skey,
- &seed,
- sizeof (seed),
- &skey->key,
- sizeof (skey->key),
- &ctbe, sizeof (ctbe), ctx, sizeof (ctx), NULL);
+ GNUNET_CRYPTO_hmac_derive_key (akey, skey, &seed, sizeof (seed), &skey->key,
+ sizeof (skey->key), &ctbe, sizeof (ctbe), ctx,
+ sizeof (ctx), NULL);
}
{
static const char ctx[] = "initialization vector";
- GNUNET_CRYPTO_aes_derive_iv (iv,
- skey,
- &seed,
- sizeof (seed),
+ GNUNET_CRYPTO_aes_derive_iv (iv, skey, &seed, sizeof (seed),
&identity->hashPubKey.bits,
- sizeof (identity->hashPubKey.bits),
- ctx, sizeof (ctx), NULL);
+ sizeof (identity->hashPubKey.bits), ctx,
+ sizeof (ctx), NULL);
}
/**
{
static const char ctx[] = "pong initialization vector";
- GNUNET_CRYPTO_aes_derive_iv (iv,
- skey,
- &seed,
- sizeof (seed),
+ GNUNET_CRYPTO_aes_derive_iv (iv, skey, &seed, sizeof (seed),
&identity->hashPubKey.bits,
- sizeof (identity->hashPubKey.bits),
- &challenge,
+ sizeof (identity->hashPubKey.bits), &challenge,
sizeof (challenge), ctx, sizeof (ctx), NULL);
}
return; /* done! */
/* overflow! compensate by cutting all values in half! */
preference_sum = 0;
- GNUNET_CONTAINER_multihashmap_iterate (neighbours,
- &update_preference, &preference_sum);
+ GNUNET_CONTAINER_multihashmap_iterate (neighbours, &update_preference,
+ &preference_sum);
GNUNET_STATISTICS_set (stats, gettext_noop ("# total peer preference"),
preference_sum, GNUNET_NO);
}
* client's queue is getting too large?
*/
static void
-send_to_client (struct Client *client,
- const struct GNUNET_MessageHeader *msg, int can_drop)
+send_to_client (struct Client *client, const struct GNUNET_MessageHeader *msg,
+ int can_drop)
{
#if DEBUG_CORE_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
(unsigned int) ntohs (msg->size),
(unsigned int) ntohs (msg->type));
#endif
- GNUNET_SERVER_notification_context_unicast (notifier,
- client->client_handle,
+ GNUNET_SERVER_notification_context_unicast (notifier, client->client_handle,
msg, can_drop);
}
/**
* Send a message to all of our current clients that have
* the right options set.
- *
+ *
* @param msg message to multicast
* @param can_drop can this message be discarded if the queue is too long
- * @param options mask to use
+ * @param options mask to use
*/
static void
-send_to_all_clients (const struct GNUNET_MessageHeader *msg,
- int can_drop, int options)
+send_to_all_clients (const struct GNUNET_MessageHeader *msg, int can_drop,
+ int options)
{
struct Client *c;
if ((!n->is_connected) || (n->status != PEER_STATE_KEY_CONFIRMED))
return;
#if DEBUG_CORE > 1
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer `%4s' changed status\n", GNUNET_i2s (&n->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' changed status\n",
+ GNUNET_i2s (&n->peer));
#endif
- size = sizeof (struct PeerStatusNotifyMessage) +
+ size =
+ sizeof (struct PeerStatusNotifyMessage) +
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
/* recovery strategy: throw away performance data */
GNUNET_array_grow (n->ats, n->ats_count, 0);
- size = sizeof (struct PeerStatusNotifyMessage) +
+ size =
+ sizeof (struct PeerStatusNotifyMessage) +
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
}
psnm = (struct PeerStatusNotifyMessage *) buf;
psnm->peer = n->peer;
psnm->ats_count = htonl (n->ats_count);
ats = &psnm->ats;
- memcpy (ats,
- n->ats,
+ memcpy (ats, n->ats,
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
ats[n->ats_count].type = htonl (0);
ats[n->ats_count].value = htonl (0);
- send_to_all_clients (&psnm->header,
- GNUNET_YES, GNUNET_CORE_OPTION_SEND_STATUS_CHANGE);
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# peer status changes"),
- 1, GNUNET_NO);
+ send_to_all_clients (&psnm->header, GNUNET_YES,
+ GNUNET_CORE_OPTION_SEND_STATUS_CHANGE);
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# peer status changes"), 1,
+ GNUNET_NO);
}
hdr = GNUNET_malloc (dlen + sizeof (struct GNUNET_MessageHeader));
hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader));
tmp = (char *) &hdr[1];
- if ((Z_OK != compress2 ((Bytef *) tmp,
- &dlen, (const Bytef *) my_type_map,
- sizeof (my_type_map), 9)) ||
- (dlen >= sizeof (my_type_map)))
+ if ((Z_OK !=
+ compress2 ((Bytef *) tmp, &dlen, (const Bytef *) my_type_map,
+ sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map)))
{
dlen = sizeof (my_type_map);
memcpy (tmp, my_type_map, sizeof (my_type_map));
* Handle CORE_SEND_REQUEST message.
*/
static void
-handle_client_send_request (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct SendMessageRequest *req;
struct ClientActiveRequest *car;
req = (const struct SendMessageRequest *) message;
- if (0 == memcmp (&req->peer,
- &my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 ==
+ memcmp (&req->peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
n = &self;
else
n = find_neighbour (&req->peer);
- if ((n == NULL) ||
- (GNUNET_YES != n->is_connected) ||
+ if ((n == NULL) || (GNUNET_YES != n->is_connected) ||
(n->status != PEER_STATE_KEY_CONFIRMED))
{
/* neighbour must have disconnected since request was issued,
- * ignore (client will realize it once it processes the
+ * ignore (client will realize it once it processes the
* disconnect notification) */
#if DEBUG_CORE_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
* Notify client about an existing connection to one of our neighbours.
*/
static int
-notify_client_about_neighbour (void *cls,
- const GNUNET_HashCode * key, void *value)
+notify_client_about_neighbour (void *cls, const GNUNET_HashCode * key,
+ void *value)
{
struct Client *c = cls;
struct Neighbour *n = value;
struct GNUNET_TRANSPORT_ATS_Information *ats;
struct ConnectNotifyMessage *cnm;
- size = sizeof (struct ConnectNotifyMessage) +
+ size =
+ sizeof (struct ConnectNotifyMessage) +
(n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
/* recovery strategy: throw away performance data */
GNUNET_array_grow (n->ats, n->ats_count, 0);
- size = sizeof (struct ConnectNotifyMessage) +
+ size =
+ sizeof (struct ConnectNotifyMessage) +
(n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
}
cnm = (struct ConnectNotifyMessage *) buf;
cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
cnm->ats_count = htonl (n->ats_count);
ats = &cnm->ats;
- memcpy (ats,
- n->ats,
+ memcpy (ats, n->ats,
sizeof (struct GNUNET_TRANSPORT_ATS_Information) * n->ats_count);
ats[n->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
ats[n->ats_count].value = htonl (0);
if (n->status == PEER_STATE_KEY_CONFIRMED)
{
#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message to client.\n", "NOTIFY_CONNECT");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
+ "NOTIFY_CONNECT");
#endif
cnm->peer = n->peer;
send_to_client (c, &cnm->header, GNUNET_NO);
* Handle CORE_INIT request.
*/
static void
-handle_client_init (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_client_init (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct InitMessage *im;
c->options = ntohl (im->options);
#if DEBUG_CORE_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %p is interested in %u message types\n",
- c, (unsigned int) c->tcnt);
+ "Client %p is interested in %u message types\n", c,
+ (unsigned int) c->tcnt);
#endif
/* send init reply message */
irm.header.size = htons (sizeof (struct InitReplyMessage));
irm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY);
irm.reserved = htonl (0);
- memcpy (&irm.publicKey,
- &my_public_key,
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
+ irm.my_identity = my_identity;
#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message to client.\n", "INIT_REPLY");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
+ "INIT_REPLY");
#endif
send_to_client (c, &irm.header, GNUNET_NO);
if (0 != (c->options & GNUNET_CORE_OPTION_SEND_CONNECT))
* @return GNUNET_YES (continue iteration)
*/
static int
-destroy_active_client_request (void *cls,
- const GNUNET_HashCode * key, void *value)
+destroy_active_client_request (void *cls, const GNUNET_HashCode * key,
+ void *value)
{
struct ClientActiveRequest *car = value;
struct Neighbour *n;
cnm = (struct ConnectNotifyMessage *) buf;
if (n->status != PEER_STATE_KEY_CONFIRMED)
return GNUNET_OK;
- size = sizeof (struct ConnectNotifyMessage) +
+ size =
+ sizeof (struct ConnectNotifyMessage) +
(n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
/* recovery strategy: throw away performance data */
GNUNET_array_grow (n->ats, n->ats_count, 0);
- size = sizeof (struct PeerStatusNotifyMessage) +
+ size =
+ sizeof (struct PeerStatusNotifyMessage) +
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
}
cnm = (struct ConnectNotifyMessage *) buf;
cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
cnm->ats_count = htonl (n->ats_count);
ats = &cnm->ats;
- memcpy (ats,
- n->ats,
+ memcpy (ats, n->ats,
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
ats[n->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
ats[n->ats_count].value = htonl (0);
#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message to client.\n", "NOTIFY_CONNECT");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
+ "NOTIFY_CONNECT");
#endif
cnm->peer = n->peer;
GNUNET_SERVER_transmit_context_append_message (tc, &cnm->header);
* @param message iteration request message
*/
static void
-handle_client_iterate_peers (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MessageHeader done_msg;
* @param message iteration request message
*/
static void
-handle_client_have_peer (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MessageHeader done_msg;
tc = GNUNET_SERVER_transmit_context_create (client);
peer = (struct GNUNET_PeerIdentity *) &message[1];
- GNUNET_CONTAINER_multihashmap_get_multiple (neighbours,
- &peer->hashPubKey,
+ GNUNET_CONTAINER_multihashmap_get_multiple (neighbours, &peer->hashPubKey,
&queue_connect_message, tc);
done_msg.size = htons (sizeof (struct GNUNET_MessageHeader));
done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS_END);
* @param message iteration request message
*/
static void
-handle_client_request_info (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct RequestInfoMessage *rcm;
rdelay = GNUNET_TIME_relative_get_zero ();
#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service receives `%s' request.\n", "REQUEST_INFO");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service receives `%s' request.\n",
+ "REQUEST_INFO");
#endif
pos = clients;
while (pos != NULL)
GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
n->bw_out_external_limit).value__)
{
- n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
- n->bw_out_external_limit);
+ n->bw_out =
+ GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit,
+ n->bw_out_external_limit);
GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window,
n->bw_out);
GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out);
}
else if (want_reserv > 0)
{
- rdelay = GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
- want_reserv);
+ rdelay =
+ GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window,
+ want_reserv);
if (rdelay.rel_value == 0)
got_reserv = want_reserv;
else
#if DEBUG_CORE_QUOTA
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n",
- (int) want_reserv,
- GNUNET_i2s (&rcm->peer),
- (int) got_reserv, (unsigned long long) rdelay.rel_value);
+ (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv,
+ (unsigned long long) rdelay.rel_value);
#endif
cim.reserved_amount = htonl (got_reserv);
cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay);
else
{
/* Technically, this COULD happen (due to asynchronous behavior),
- * but it should be rare, so we should generate an info event
+ * but it should be rare, so we should generate an info event
* to help diagnosis of serious errors that might be masked by this */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_
cim.peer = rcm->peer;
cim.rim_id = rcm->rim_id;
#if DEBUG_CORE_CLIENT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message to client.\n", "CONFIGURATION_INFO");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
+ "CONFIGURATION_INFO");
#endif
send_to_client (pos, &cim.header, GNUNET_NO);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->keep_alive_task);
if (n->status == PEER_STATE_KEY_CONFIRMED)
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# established sessions"),
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"),
-1, GNUNET_NO);
GNUNET_array_grow (n->ats, n->ats_count, 0);
GNUNET_free_non_null (n->public_key);
*
* @param n neighbour to check.
*/
-static void process_encrypted_neighbour_queue (struct Neighbour *n);
+static void
+process_encrypted_neighbour_queue (struct Neighbour *n);
/**
return GNUNET_NO;
}
GNUNET_assert (size ==
- GNUNET_CRYPTO_aes_encrypt (in,
- (uint16_t) size,
+ GNUNET_CRYPTO_aes_encrypt (in, (uint16_t) size,
&n->encrypt_key, iv, out));
GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes encrypted"), size,
GNUNET_NO);
#if DEBUG_CORE > 2
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypted %u bytes for `%4s' using key %u, IV %u\n",
- (unsigned int) size,
- GNUNET_i2s (&n->peer),
- (unsigned int) n->encrypt_key.crc32,
- GNUNET_CRYPTO_crc32_n (iv, sizeof (iv)));
+ (unsigned int) size, GNUNET_i2s (&n->peer),
+ (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (iv,
+ sizeof
+ (iv)));
#endif
return GNUNET_OK;
}
*
* @param n neighbour to consider discarding
*/
-static void consider_free_neighbour (struct Neighbour *n);
+static void
+consider_free_neighbour (struct Neighbour *n);
/**
- * Task triggered when a neighbour entry is about to time out
+ * Task triggered when a neighbour entry is about to time out
* (and we should prevent this by sending a PING).
*
* @param cls the 'struct Neighbour'
me->deadline = GNUNET_TIME_relative_to_absolute (MAX_PING_DELAY);
me->priority = PING_PRIORITY;
me->size = sizeof (struct PingMessage);
- GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head,
- n->encrypted_tail, n->encrypted_tail, me);
+ GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail,
+ n->encrypted_tail, me);
pm = (struct PingMessage *) &me[1];
pm->header.size = htons (sizeof (struct PingMessage));
pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING);
- pm->iv_seed = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
- UINT32_MAX);
+ pm->iv_seed =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
derive_iv (&iv, &n->encrypt_key, pm->iv_seed, &n->peer);
pp.challenge = n->ping_challenge;
pp.target = n->peer;
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypting `%s' message with challenge %u for `%4s' using key %u, IV %u (salt %u).\n",
- "PING",
- (unsigned int) n->ping_challenge,
- GNUNET_i2s (&n->peer),
- (unsigned int) n->encrypt_key.crc32,
- GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), pm->iv_seed);
+ "PING", (unsigned int) n->ping_challenge, GNUNET_i2s (&n->peer),
+ (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv,
+ sizeof
+ (iv)),
+ pm->iv_seed);
#endif
- do_encrypt (n,
- &iv,
- &pp.target,
- &pm->target,
- sizeof (struct PingMessage) -
- ((void *) &pm->target - (void *) pm));
+ do_encrypt (n, &iv, &pp.target, &pm->target,
+ sizeof (struct PingMessage) - ((void *) &pm->target -
+ (void *) pm));
process_encrypted_neighbour_queue (n);
/* reschedule PING job */
left = GNUNET_TIME_absolute_get_remaining (get_neighbour_timeout (n));
- retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
- MIN_PING_FREQUENCY);
- n->keep_alive_task
- = GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, n);
+ retry =
+ GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
+ MIN_PING_FREQUENCY);
+ n->keep_alive_task =
+ GNUNET_SCHEDULER_add_delayed (retry, &send_keep_alive, n);
}
{
if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->dead_clean_task);
- n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (left,
- &consider_free_task, n);
+ n->dead_clean_task =
+ GNUNET_SCHEDULER_add_delayed (left, &consider_free_task, n);
return;
}
/* actually free the neighbour... */
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (neighbours,
&n->peer.hashPubKey, n));
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# neighbour entries allocated"),
+ GNUNET_STATISTICS_set (stats, gettext_noop ("# neighbour entries allocated"),
GNUNET_CONTAINER_multihashmap_size (neighbours),
GNUNET_NO);
free_neighbour (n);
*
* @param n neighbour to check.
*/
-static void process_plaintext_neighbour_queue (struct Neighbour *n);
+static void
+process_plaintext_neighbour_queue (struct Neighbour *n);
/**
#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n",
- (unsigned int) m->size,
- GNUNET_i2s (&n->peer),
+ (unsigned int) m->size, GNUNET_i2s (&n->peer),
(unsigned long long)
GNUNET_TIME_absolute_get_remaining (m->deadline).rel_value);
#endif
n->th =
- GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer,
- m->size,
+ GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size,
m->priority,
GNUNET_TIME_absolute_get_remaining
(m->deadline),
GNUNET_break (0);
return GNUNET_SYSERR;
}
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# bytes decrypted"),
- size, GNUNET_NO);
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes decrypted"), size,
+ GNUNET_NO);
#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted %u bytes from `%4s' using key %u, IV %u\n",
- (unsigned int) size,
- GNUNET_i2s (&n->peer),
- (unsigned int) n->decrypt_key.crc32,
- GNUNET_CRYPTO_crc32_n (iv, sizeof (*iv)));
+ (unsigned int) size, GNUNET_i2s (&n->peer),
+ (unsigned int) n->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (iv,
+ sizeof
+ (*iv)));
#endif
return GNUNET_OK;
}
* defer scheduling overall; in that case, retry_time is set.
*/
static size_t
-select_messages (struct Neighbour *n,
- size_t size, struct GNUNET_TIME_Relative *retry_time)
+select_messages (struct Neighbour *n, size_t size,
+ struct GNUNET_TIME_Relative *retry_time)
{
struct MessageEntry *pos;
struct MessageEntry *min;
{
// FIXME: HUH? Check!
t = pos->deadline;
- avail += GNUNET_BANDWIDTH_value_get_available_until (n->bw_out,
- delta);
+ avail +=
+ GNUNET_BANDWIDTH_value_get_available_until (n->bw_out, delta);
}
if (avail < pos->size)
{
/* update slack, considering both its absolute deadline
* and relative deadlines caused by other messages
* with their respective load */
- slack = GNUNET_TIME_relative_min (slack,
- GNUNET_BANDWIDTH_value_get_delay_for
- (n->bw_out, avail));
+ slack =
+ GNUNET_TIME_relative_min (slack,
+ GNUNET_BANDWIDTH_value_get_delay_for
+ (n->bw_out, avail));
if (pos->deadline.abs_value <= now.abs_value)
{
/* now or never */
else if (GNUNET_YES == pos->got_slack)
{
/* should be soon now! */
- slack = GNUNET_TIME_relative_min (slack,
- GNUNET_TIME_absolute_get_remaining
- (pos->slack_deadline));
+ slack =
+ GNUNET_TIME_relative_min (slack,
+ GNUNET_TIME_absolute_get_remaining
+ (pos->slack_deadline));
}
else
{
GNUNET_TIME_absolute_get_difference
(now, pos->deadline));
pos->got_slack = GNUNET_YES;
- pos->slack_deadline = GNUNET_TIME_absolute_min (pos->deadline,
- GNUNET_TIME_relative_to_absolute
- (GNUNET_CONSTANTS_MAX_CORK_DELAY));
+ pos->slack_deadline =
+ GNUNET_TIME_absolute_min (pos->deadline,
+ GNUNET_TIME_relative_to_absolute
+ (GNUNET_CONSTANTS_MAX_CORK_DELAY));
}
}
}
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deferring transmission for %llums due to underfull message buffer size (%u/%u)\n",
- (unsigned long long) retry_time->rel_value,
- (unsigned int) off, (unsigned int) size);
+ (unsigned long long) retry_time->rel_value, (unsigned int) off,
+ (unsigned int) size);
#endif
return 0;
}
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Selected %llu/%llu bytes of %u/%u plaintext messages for transmission to `%4s'.\n",
- (unsigned long long) off, (unsigned long long) tsize,
- queue_size, (unsigned int) MAX_PEER_QUEUE_SIZE,
- GNUNET_i2s (&n->peer));
+ (unsigned long long) off, (unsigned long long) tsize, queue_size,
+ (unsigned int) MAX_PEER_QUEUE_SIZE, GNUNET_i2s (&n->peer));
#endif
return off;
}
* @return number of bytes written to buf (can be zero)
*/
static size_t
-batch_message (struct Neighbour *n,
- char *buf,
- size_t size,
+batch_message (struct Neighbour *n, char *buf, size_t size,
struct GNUNET_TIME_Absolute *deadline,
struct GNUNET_TIME_Relative *retry_time, unsigned int *priority)
{
GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct NotifyTrafficMessage))
{
memcpy (&ntm[1], &pos[1], pos->size);
- ntm->header.size = htons (sizeof (struct NotifyTrafficMessage) +
- sizeof (struct GNUNET_MessageHeader));
- send_to_all_clients (&ntm->header,
- GNUNET_YES, GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
+ ntm->header.size =
+ htons (sizeof (struct NotifyTrafficMessage) +
+ sizeof (struct GNUNET_MessageHeader));
+ send_to_all_clients (&ntm->header, GNUNET_YES,
+ GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
}
else
{
* least the 'hdr' type */
memcpy (&ntm[1], &pos[1], sizeof (struct GNUNET_MessageHeader));
}
- ntm->header.size = htons (sizeof (struct NotifyTrafficMessage) +
- pos->size);
- send_to_all_clients (&ntm->header,
- GNUNET_YES, GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
+ ntm->header.size =
+ htons (sizeof (struct NotifyTrafficMessage) + pos->size);
+ send_to_all_clients (&ntm->header, GNUNET_YES,
+ GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypting %u bytes with message of type %u and size %u\n",
struct GNUNET_TIME_Absolute now;
struct GNUNET_TIME_Relative delta;
int disc;
+ unsigned int queue_length;
disc = GNUNET_NO;
now = GNUNET_TIME_absolute_get ();
prev = NULL;
+ queue_length = 0;
pos = n->messages;
while (pos != NULL)
{
+ queue_length++;
next = pos->next;
delta = GNUNET_TIME_absolute_get_difference (pos->deadline, now);
if (delta.rel_value > PAST_EXPIRATION_DISCARD_TIME.rel_value)
prev = pos;
pos = next;
}
- if (GNUNET_YES == disc)
+ if ( (GNUNET_YES == disc) &&
+ (queue_length == MAX_PEER_QUEUE_SIZE) )
schedule_peer_messages (n);
}
*
* @param n the other peer
*/
-static void send_key (struct Neighbour *n);
+static void
+send_key (struct Neighbour *n);
/**
* Task that will retry "send_key" if our previous attempt failed
struct Neighbour *n = cls;
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Retrying key transmission to `%4s'\n", GNUNET_i2s (&n->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Retrying key transmission to `%4s'\n",
+ GNUNET_i2s (&n->peer));
#endif
n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
n->set_key_retry_frequency =
return;
case PEER_STATE_KEY_SENT:
if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
- n->retry_set_key_task
- = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
- &set_key_retry_task, n);
+ n->retry_set_key_task =
+ GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
+ &set_key_retry_task, n);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Not yet connected to `%4s', deferring processing of plaintext messages.\n",
return;
case PEER_STATE_KEY_RECEIVED:
if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
- n->retry_set_key_task
- = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
- &set_key_retry_task, n);
+ n->retry_set_key_task =
+ GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
+ &set_key_retry_task, n);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Not yet connected to `%4s', deferring processing of plaintext messages.\n",
deadline = GNUNET_TIME_UNIT_FOREVER_ABS;
priority = 0;
used = sizeof (struct EncryptedMessage);
- used += batch_message (n,
- &pbuf[used],
- GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE,
- &deadline, &retry_time, &priority);
+ used +=
+ batch_message (n, &pbuf[used],
+ GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE, &deadline,
+ &retry_time, &priority);
if (used == sizeof (struct EncryptedMessage))
{
#if DEBUG_CORE > 1
#endif
/* no messages selected for sending, try again later... */
n->retry_plaintext_task =
- GNUNET_SCHEDULER_add_delayed (retry_time,
- &retry_plaintext_processing, n);
+ GNUNET_SCHEDULER_add_delayed (retry_time, &retry_plaintext_processing,
+ n);
return;
}
#if DEBUG_CORE_QUOTA
GNUNET_TIME_absolute_get_remaining (deadline).rel_value);
#endif
GNUNET_assert (GNUNET_OK ==
- do_encrypt (n,
- &iv,
- &ph->sequence_number,
- &em->sequence_number,
+ do_encrypt (n, &iv, &ph->sequence_number, &em->sequence_number,
used - ENCRYPTED_HEADER_SIZE));
derive_auth_key (&auth_key, &n->encrypt_key, ph->iv_seed,
n->encrypt_key_created);
GNUNET_h2s (&em->hmac));
#endif
/* append to transmission list */
- GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head,
- n->encrypted_tail, n->encrypted_tail, me);
+ GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail,
+ n->encrypted_tail, me);
process_encrypted_neighbour_queue (n);
schedule_peer_messages (n);
}
/**
* Function that recalculates the bandwidth quota for the
* given neighbour and transmits it to the transport service.
- *
+ *
* @param cls neighbour for the quota update
* @param tc context
*/
schedule_quota_update (struct Neighbour *n)
{
GNUNET_assert (n->quota_update_task == GNUNET_SCHEDULER_NO_TASK);
- n->quota_update_task
- = GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY,
- &neighbour_quota_update, n);
+ n->quota_update_task =
+ GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY,
+ &neighbour_quota_update, n);
}
n->bw_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
n->bw_out_internal_limit = GNUNET_BANDWIDTH_value_init (UINT32_MAX);
n->bw_out_external_limit = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
- n->ping_challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
- UINT32_MAX);
+ n->ping_challenge =
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (neighbours,
- &n->peer.hashPubKey,
- n,
+ &n->peer.hashPubKey, n,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
GNUNET_STATISTICS_set (stats, gettext_noop ("# neighbour entries allocated"),
GNUNET_CONTAINER_multihashmap_size (neighbours),
* @param message the "struct SendMessage"
*/
static void
-handle_client_send (void *cls,
- struct GNUNET_SERVER_Client *client,
+handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct SendMessage *sm;
sizeof (struct SendMessage) + sizeof (struct GNUNET_MessageHeader))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "msize is %u, should be at least %u (in %s:%d)\n",
- msize,
+ "msize is %u, should be at least %u (in %s:%d)\n", msize,
sizeof (struct SendMessage) +
sizeof (struct GNUNET_MessageHeader), __FILE__, __LINE__);
GNUNET_break (0);
memcmp (&sm->peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
/* loopback */
- GNUNET_SERVER_mst_receive (mst,
- &self,
- (const char *) &sm[1],
- msize, GNUNET_YES, GNUNET_NO);
+ GNUNET_SERVER_mst_receive (mst, &self, (const char *) &sm[1], msize,
+ GNUNET_YES, GNUNET_NO);
if (client != NULL)
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
n = find_neighbour (&sm->peer);
- if ((n == NULL) ||
- (GNUNET_YES != n->is_connected) ||
+ if ((n == NULL) || (GNUNET_YES != n->is_connected) ||
(n->status != PEER_STATE_KEY_CONFIRMED))
{
- /* attempt to send message to peer that is not connected anymore
+ /* attempt to send message to peer that is not connected anymore
* (can happen due to asynchrony) */
GNUNET_STATISTICS_update (stats,
gettext_noop
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queue full (%u/%u), discarding new request (%u bytes of type %u)\n",
- queue_size,
- (unsigned int) MAX_PEER_QUEUE_SIZE,
+ queue_size, (unsigned int) MAX_PEER_QUEUE_SIZE,
(unsigned int) msize, (unsigned int) ntohs (message->type));
#endif
GNUNET_STATISTICS_update (stats,
}
-/**
- * Handle CORE_REQUEST_CONNECT request.
- *
- * @param cls unused
- * @param client the client issuing the request
- * @param message the "struct ConnectMessage"
- */
-static void
-handle_client_request_connect (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- const struct ConnectMessage *cm = (const struct ConnectMessage *) message;
- struct Neighbour *n;
-
- if (0 == memcmp (&cm->peer,
- &my_identity, sizeof (struct GNUNET_PeerIdentity)))
- {
- /* In this case a client has asked us to connect to ourselves, not really an error! */
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- return;
- }
- GNUNET_break (ntohl (cm->reserved) == 0);
-#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core received `%s' request for `%4s', will try to establish connection\n",
- "REQUEST_CONNECT", GNUNET_i2s (&cm->peer));
-#endif
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# connection requests received"),
- 1, GNUNET_NO);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- n = find_neighbour (&cm->peer);
- if ((n == NULL) || (GNUNET_YES != n->is_connected))
- {
- GNUNET_TRANSPORT_try_connect (transport, &cm->peer);
- }
- else
- {
- GNUNET_STATISTICS_update (stats,
- gettext_noop
- ("# connection requests ignored (already connected)"),
- 1, GNUNET_NO);
- }
-}
-
-
/**
* PEERINFO is giving us a HELLO for a peer. Add the public key to
* the neighbour's struct and retry send_key. Or, if we did not get a
* @param err_msg NULL if successful, otherwise contains error message
*/
static void
-process_hello_retry_send_key (void *cls,
- const struct GNUNET_PeerIdentity *peer,
+process_hello_retry_send_key (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_HELLO_Message *hello,
const char *err_msg)
{
if (peer == NULL)
{
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Entered `%s' and `%s' is NULL!\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered `%s' and `%s' is NULL!\n",
"process_hello_retry_send_key", "peer");
#endif
n->pitr = NULL;
("# Delayed connecting due to lack of public key"),
1, GNUNET_NO);
if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task)
- n->retry_set_key_task
- = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
- &set_key_retry_task, n);
+ n->retry_set_key_task =
+ GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
+ &set_key_retry_task, n);
}
return;
}
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Entered `%s' for peer `%4s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered `%s' for peer `%4s'\n",
"process_hello_retry_send_key", GNUNET_i2s (peer));
#endif
if (n->public_key != NULL)
GNUNET_i2s (&n->peer));
#endif
GNUNET_assert (n->pitr == NULL);
- n->pitr = GNUNET_PEERINFO_iterate (peerinfo,
- &n->peer,
- GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 20),
- &process_hello_retry_send_key, n);
+ n->pitr =
+ GNUNET_PEERINFO_iterate (peerinfo, &n->peer,
+ GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, 20),
+ &process_hello_retry_send_key, n);
return;
}
pos = n->encrypted_head;
{
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "`%s' message for `%4s' queued already\n",
- "SET_KEY", GNUNET_i2s (&n->peer));
+ "`%s' message for `%4s' queued already\n", "SET_KEY",
+ GNUNET_i2s (&n->peer));
#endif
goto trigger_processing;
}
me->is_setkey = GNUNET_YES;
me->got_slack = GNUNET_YES; /* do not defer this one! */
me->sender_status = n->status;
- GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head,
- n->encrypted_tail, n->encrypted_tail, me);
+ GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail,
+ n->encrypted_tail, me);
sm = (struct SetKeyMessage *) &me[1];
sm->header.size = htons (sizeof (struct SetKeyMessage));
sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SET_KEY);
- sm->sender_status = htonl ((int32_t) ((n->status == PEER_STATE_DOWN) ?
- PEER_STATE_KEY_SENT : n->status));
+ sm->sender_status =
+ htonl ((int32_t)
+ ((n->status ==
+ PEER_STATE_DOWN) ? PEER_STATE_KEY_SENT : n->status));
sm->purpose.size =
htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
sizeof (struct GNUNET_TIME_AbsoluteNBO) +
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypting `%s' and `%s' messages with challenge %u for `%4s' using key %u, IV %u (salt %u).\n",
- "SET_KEY", "PING",
- (unsigned int) n->ping_challenge,
- GNUNET_i2s (&n->peer),
- (unsigned int) n->encrypt_key.crc32,
+ "SET_KEY", "PING", (unsigned int) n->ping_challenge,
+ GNUNET_i2s (&n->peer), (unsigned int) n->encrypt_key.crc32,
GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), pm->iv_seed);
#endif
- do_encrypt (n,
- &iv,
- &pp.target,
- &pm->target,
- sizeof (struct PingMessage) -
- ((void *) &pm->target - (void *) pm));
+ do_encrypt (n, &iv, &pp.target, &pm->target,
+ sizeof (struct PingMessage) - ((void *) &pm->target -
+ (void *) pm));
GNUNET_STATISTICS_update (stats,
gettext_noop
("# SET_KEY and PING messages created"), 1,
process_encrypted_neighbour_queue (n);
if ((n->status != PEER_STATE_KEY_CONFIRMED) &&
(GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task))
- n->retry_set_key_task
- = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
- &set_key_retry_task, n);
+ n->retry_set_key_task =
+ GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
+ &set_key_retry_task, n);
}
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-handle_set_key (struct Neighbour *n,
- const struct SetKeyMessage *m,
+handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count);
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-handle_ping (struct Neighbour *n,
- const struct PingMessage *m,
+handle_ping (struct Neighbour *n, const struct PingMessage *m,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service receives `%s' request from `%4s'.\n",
- "PING", GNUNET_i2s (&n->peer));
+ "Core service receives `%s' request from `%4s'.\n", "PING",
+ GNUNET_i2s (&n->peer));
#endif
derive_iv (&iv, &n->decrypt_key, m->iv_seed, &my_identity);
if (GNUNET_OK !=
- do_decrypt (n,
- &iv,
- &m->target,
- &t.target,
- sizeof (struct PingMessage) -
- ((void *) &m->target - (void *) m)))
+ do_decrypt (n, &iv, &m->target, &t.target,
+ sizeof (struct PingMessage) - ((void *) &m->target -
+ (void *) m)))
return;
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted `%s' to `%4s' with challenge %u decrypted using key %u, IV %u (salt %u)\n",
- "PING",
- GNUNET_i2s (&t.target),
- (unsigned int) t.challenge,
- (unsigned int) n->decrypt_key.crc32,
- GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), m->iv_seed);
+ "PING", GNUNET_i2s (&t.target), (unsigned int) t.challenge,
+ (unsigned int) n->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv,
+ sizeof
+ (iv)),
+ m->iv_seed);
#endif
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# PING messages decrypted"),
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# PING messages decrypted"),
1, GNUNET_NO);
- if (0 != memcmp (&t.target,
- &my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 !=
+ memcmp (&t.target, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
char sender[9];
char peer[9];
update_neighbour_performance (n, ats, ats_count);
me = GNUNET_malloc (sizeof (struct MessageEntry) +
sizeof (struct PongMessage));
- GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head,
- n->encrypted_tail, n->encrypted_tail, me);
+ GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, n->encrypted_tail,
+ n->encrypted_tail, me);
me->deadline = GNUNET_TIME_relative_to_absolute (MAX_PONG_DELAY);
me->priority = PONG_PRIORITY;
me->size = sizeof (struct PongMessage);
tp->iv_seed =
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
derive_pong_iv (&iv, &n->encrypt_key, tp->iv_seed, t.challenge, &n->peer);
- do_encrypt (n,
- &iv,
- &tx.challenge,
- &tp->challenge,
- sizeof (struct PongMessage) -
- ((void *) &tp->challenge - (void *) tp));
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# PONG messages created"),
- 1, GNUNET_NO);
+ do_encrypt (n, &iv, &tx.challenge, &tp->challenge,
+ sizeof (struct PongMessage) - ((void *) &tp->challenge -
+ (void *) tp));
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages created"), 1,
+ GNUNET_NO);
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Encrypting `%s' with challenge %u using key %u, IV %u (salt %u)\n",
- "PONG",
- (unsigned int) t.challenge,
- (unsigned int) n->encrypt_key.crc32,
- GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), tp->iv_seed);
+ "PONG", (unsigned int) t.challenge,
+ (unsigned int) n->encrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv,
+ sizeof
+ (iv)),
+ tp->iv_seed);
#endif
/* trigger queue processing */
process_encrypted_neighbour_queue (n);
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-handle_pong (struct Neighbour *n,
- const struct PongMessage *m,
+handle_pong (struct Neighbour *n, const struct PongMessage *m,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service receives `%s' response from `%4s'.\n",
- "PONG", GNUNET_i2s (&n->peer));
+ "Core service receives `%s' response from `%4s'.\n", "PONG",
+ GNUNET_i2s (&n->peer));
#endif
/* mark as garbage, just to be sure */
memset (&t, 255, sizeof (t));
derive_pong_iv (&iv, &n->decrypt_key, m->iv_seed, n->ping_challenge,
&my_identity);
if (GNUNET_OK !=
- do_decrypt (n,
- &iv,
- &m->challenge,
- &t.challenge,
- sizeof (struct PongMessage) -
- ((void *) &m->challenge - (void *) m)))
+ do_decrypt (n, &iv, &m->challenge, &t.challenge,
+ sizeof (struct PongMessage) - ((void *) &m->challenge -
+ (void *) m)))
{
GNUNET_break_op (0);
return;
}
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# PONG messages decrypted"),
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# PONG messages decrypted"),
1, GNUNET_NO);
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted `%s' from `%4s' with challenge %u using key %u, IV %u (salt %u)\n",
- "PONG",
- GNUNET_i2s (&t.target),
- (unsigned int) t.challenge,
- (unsigned int) n->decrypt_key.crc32,
- GNUNET_CRYPTO_crc32_n (&iv, sizeof (iv)), m->iv_seed);
+ "PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge,
+ (unsigned int) n->decrypt_key.crc32, GNUNET_CRYPTO_crc32_n (&iv,
+ sizeof
+ (iv)),
+ m->iv_seed);
#endif
- if ((0 != memcmp (&t.target,
- &n->peer,
- sizeof (struct GNUNET_PeerIdentity))) ||
- (n->ping_challenge != t.challenge))
+ if ((0 != memcmp (&t.target, &n->peer, sizeof (struct GNUNET_PeerIdentity)))
+ || (n->ping_challenge != t.challenge))
{
/* PONG malformed */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received malformed `%s' wanted sender `%4s' with challenge %u\n",
- "PONG",
- GNUNET_i2s (&n->peer), (unsigned int) n->ping_challenge);
+ "PONG", GNUNET_i2s (&n->peer),
+ (unsigned int) n->ping_challenge);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received malformed `%s' received from `%4s' with challenge %u\n",
"PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge);
if (n->bw_out_external_limit.value__ != t.inbound_bw_limit.value__)
{
n->bw_out_external_limit = t.inbound_bw_limit;
- n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit,
- n->bw_out_internal_limit);
+ n->bw_out =
+ GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit,
+ n->bw_out_internal_limit);
GNUNET_BANDWIDTH_tracker_update_quota (&n->available_send_window,
n->bw_out);
GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out);
}
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Confirmed key via `%s' message for peer `%4s'\n",
- "PONG", GNUNET_i2s (&n->peer));
+ "Confirmed key via `%s' message for peer `%4s'\n", "PONG",
+ GNUNET_i2s (&n->peer));
#endif
if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
{
n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
}
update_neighbour_performance (n, ats, ats_count);
- size = sizeof (struct ConnectNotifyMessage) +
+ size =
+ sizeof (struct ConnectNotifyMessage) +
(n->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
/* recovery strategy: throw away performance data */
GNUNET_array_grow (n->ats, n->ats_count, 0);
- size = sizeof (struct PeerStatusNotifyMessage) +
+ size =
+ sizeof (struct PeerStatusNotifyMessage) +
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
}
cnm = (struct ConnectNotifyMessage *) buf;
cnm->ats_count = htonl (n->ats_count);
cnm->peer = n->peer;
mats = &cnm->ats;
- memcpy (mats,
- n->ats,
+ memcpy (mats, n->ats,
n->ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
mats[n->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
mats[n->ats_count].value = htonl (0);
- send_to_all_clients (&cnm->header,
- GNUNET_NO, GNUNET_CORE_OPTION_SEND_CONNECT);
+ send_to_all_clients (&cnm->header, GNUNET_NO,
+ GNUNET_CORE_OPTION_SEND_CONNECT);
process_encrypted_neighbour_queue (n);
/* fall-through! */
case PEER_STATE_KEY_CONFIRMED:
n->last_activity = GNUNET_TIME_absolute_get ();
if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->keep_alive_task);
- n->keep_alive_task
- =
+ n->keep_alive_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2), &send_keep_alive, n);
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-handle_set_key (struct Neighbour *n,
- const struct SetKeyMessage *m,
+handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core service receives `%s' request from `%4s'.\n",
- "SET_KEY", GNUNET_i2s (&n->peer));
+ "Core service receives `%s' request from `%4s'.\n", "SET_KEY",
+ GNUNET_i2s (&n->peer));
#endif
if (n->public_key == NULL)
{
/* lookup n's public key, then try again */
GNUNET_assert (n->skm == NULL);
n->skm = m_cpy;
- n->pitr = GNUNET_PEERINFO_iterate (peerinfo,
- &n->peer,
- GNUNET_TIME_UNIT_MINUTES,
- &process_hello_retry_handle_set_key, n);
+ n->pitr =
+ GNUNET_PEERINFO_iterate (peerinfo, &n->peer, GNUNET_TIME_UNIT_MINUTES,
+ &process_hello_retry_handle_set_key, n);
GNUNET_STATISTICS_update (stats,
gettext_noop
("# SET_KEY messages deferred (need public key)"),
1, GNUNET_NO);
return;
}
- if (0 != memcmp (&m->target,
- &my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 !=
+ memcmp (&m->target, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_
sizeof (struct GNUNET_CRYPTO_RsaEncryptedData) +
sizeof (struct GNUNET_PeerIdentity)) ||
(GNUNET_OK !=
- GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_SET_KEY,
- &m->purpose, &m->signature, n->public_key)))
+ GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_SET_KEY, &m->purpose,
+ &m->signature, n->public_key)))
{
/* invalid signature */
GNUNET_break_op (0);
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypting key material.\n");
#endif
- if ((GNUNET_CRYPTO_rsa_decrypt (my_private_key,
- &m->encrypted_key,
- &k,
- sizeof (struct GNUNET_CRYPTO_AesSessionKey))
- != sizeof (struct GNUNET_CRYPTO_AesSessionKey)) ||
+ if ((GNUNET_CRYPTO_rsa_decrypt
+ (my_private_key, &m->encrypted_key, &k,
+ sizeof (struct GNUNET_CRYPTO_AesSessionKey)) !=
+ sizeof (struct GNUNET_CRYPTO_AesSessionKey)) ||
(GNUNET_OK != GNUNET_CRYPTO_aes_check_session_key (&k)))
{
/* failed to decrypt !? */
return;
}
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# SET_KEY messages decrypted"),
- 1, GNUNET_NO);
+ gettext_noop ("# SET_KEY messages decrypted"), 1,
+ GNUNET_NO);
n->decrypt_key = k;
if (n->decrypt_key_created.abs_value != t.abs_value)
{
* @param msize number of bytes in buf to transmit
*/
static void
-send_p2p_message_to_client (struct Neighbour *sender,
- struct Client *client, const void *m, size_t msize)
+send_p2p_message_to_client (struct Neighbour *sender, struct Client *client,
+ const void *m, size_t msize)
{
- size_t size = msize + sizeof (struct NotifyTrafficMessage) +
+ size_t size =
+ msize + sizeof (struct NotifyTrafficMessage) +
(sender->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
char buf[size];
struct NotifyTrafficMessage *ntm;
struct GNUNET_TRANSPORT_ATS_Information *ats;
GNUNET_assert (GNUNET_YES == sender->is_connected);
+ GNUNET_break (sender->status == PEER_STATE_KEY_CONFIRMED);
if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
{
GNUNET_break (0);
/* recovery strategy: throw performance data away... */
GNUNET_array_grow (sender->ats, sender->ats_count, 0);
- size = msize + sizeof (struct NotifyTrafficMessage) +
+ size =
+ msize + sizeof (struct NotifyTrafficMessage) +
(sender->ats_count) * sizeof (struct GNUNET_TRANSPORT_ATS_Information);
}
#if DEBUG_CORE
ntm->ats_count = htonl (sender->ats_count);
ntm->peer = sender->peer;
ats = &ntm->ats;
- memcpy (ats,
- sender->ats,
+ memcpy (ats, sender->ats,
sizeof (struct GNUNET_TRANSPORT_ATS_Information) * sender->ats_count);
ats[sender->ats_count].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
ats[sender->ats_count].value = htonl (0);
int deliver_full;
int dropped;
+ GNUNET_break (sender->status == PEER_STATE_KEY_CONFIRMED);
type = ntohs (m->type);
#if DEBUG_CORE > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received encapsulated message of type %u and size %u from `%4s'\n",
(unsigned int) type, ntohs (m->size), GNUNET_i2s (&sender->peer));
#endif
- GNUNET_snprintf (buf,
- sizeof (buf),
+ GNUNET_snprintf (buf, sizeof (buf),
gettext_noop ("# bytes of messages of type %u received"),
(unsigned int) type);
GNUNET_STATISTICS_update (stats, buf, msize, GNUNET_NO);
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-handle_encrypted_message (struct Neighbour *n,
- const struct EncryptedMessage *m,
+handle_encrypted_message (struct Neighbour *n, const struct EncryptedMessage *m,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
"ENCRYPTED_MESSAGE", GNUNET_i2s (&n->peer));
#endif
/* validate hash */
- derive_auth_key (&auth_key,
- &n->decrypt_key, m->iv_seed, n->decrypt_key_created);
- GNUNET_CRYPTO_hmac (&auth_key,
- &m->sequence_number, size - ENCRYPTED_HEADER_SIZE, &ph);
+ derive_auth_key (&auth_key, &n->decrypt_key, m->iv_seed,
+ n->decrypt_key_created);
+ GNUNET_CRYPTO_hmac (&auth_key, &m->sequence_number,
+ size - ENCRYPTED_HEADER_SIZE, &ph);
#if DEBUG_HANDSHAKE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Re-Authenticated %u bytes of ciphertext (`%u'): `%s'\n",
derive_iv (&iv, &n->decrypt_key, m->iv_seed, &my_identity);
/* decrypt */
if (GNUNET_OK !=
- do_decrypt (n,
- &iv,
- &m->sequence_number,
- &buf[ENCRYPTED_HEADER_SIZE], size - ENCRYPTED_HEADER_SIZE))
+ do_decrypt (n, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE],
+ size - ENCRYPTED_HEADER_SIZE))
return;
pt = (struct EncryptedMessage *) buf;
MAX_MESSAGE_AGE.rel_value)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _
- ("Message received far too old (%llu ms). Content ignored.\n"),
+ _("Message received far too old (%llu ms). Content ignored.\n"),
GNUNET_TIME_absolute_get_duration (t).rel_value);
GNUNET_STATISTICS_update (stats,
gettext_noop
GNUNET_i2s (&n->peer));
#endif
n->bw_out_external_limit = pt->inbound_bw_limit;
- n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit,
- n->bw_out_internal_limit);
+ n->bw_out =
+ GNUNET_BANDWIDTH_value_min (n->bw_out_external_limit,
+ n->bw_out_internal_limit);
GNUNET_BANDWIDTH_tracker_update_quota (&n->available_send_window,
n->bw_out);
GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out);
n->last_activity = GNUNET_TIME_absolute_get ();
if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->keep_alive_task);
- n->keep_alive_task
- =
+ n->keep_alive_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2), &send_keep_alive, n);
size - sizeof (struct EncryptedMessage), GNUNET_NO);
handle_peer_status_change (n);
update_neighbour_performance (n, ats, ats_count);
- if (GNUNET_OK != GNUNET_SERVER_mst_receive (mst,
- n,
- &buf[sizeof
- (struct EncryptedMessage)],
- size -
- sizeof (struct EncryptedMessage),
- GNUNET_YES, GNUNET_NO))
+ if (GNUNET_OK !=
+ GNUNET_SERVER_mst_receive (mst, n, &buf[sizeof (struct EncryptedMessage)],
+ size - sizeof (struct EncryptedMessage),
+ GNUNET_YES, GNUNET_NO))
GNUNET_break_op (0);
}
* @param ats_count number of entries in ats (excluding 0-termination)
*/
static void
-handle_transport_receive (void *cls,
- const struct GNUNET_PeerIdentity *peer,
+handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
GNUNET_break_op (0);
return;
}
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# session keys received"),
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# session keys received"),
1, GNUNET_NO);
handle_set_key (n, (const struct SetKeyMessage *) message, ats, ats_count);
break;
case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
- if (size < sizeof (struct EncryptedMessage) +
- sizeof (struct GNUNET_MessageHeader))
+ if (size <
+ sizeof (struct EncryptedMessage) + sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
return;
send_key (n);
return;
}
- handle_encrypted_message (n,
- (const struct EncryptedMessage *) message,
- ats, ats_count);
+ handle_encrypted_message (n, (const struct EncryptedMessage *) message, ats,
+ ats_count);
break;
case GNUNET_MESSAGE_TYPE_CORE_PING:
if (size != sizeof (struct PingMessage))
changed = GNUNET_YES;
if (!up)
{
- GNUNET_STATISTICS_update (stats,
- gettext_noop ("# established sessions"),
+ GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"),
1, GNUNET_NO);
n->time_established = now;
}
if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->keep_alive_task);
- n->keep_alive_task
- =
+ n->keep_alive_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
2), &send_keep_alive, n);
/**
* Function that recalculates the bandwidth quota for the
* given neighbour and transmits it to the transport service.
- *
+ *
* @param cls neighbour for the quota update
* @param tc context
*/
n->quota_update_task = GNUNET_SCHEDULER_NO_TASK;
/* calculate relative preference among all neighbours;
* divides by a bit more to avoid division by zero AND to
- * account for possibility of new neighbours joining any time
+ * account for possibility of new neighbours joining any time
* AND to convert to double... */
neighbour_count = GNUNET_CONTAINER_multihashmap_size (neighbours);
if (neighbour_count == 0)
"Forcing disconnect of `%4s' due to inactivity\n",
GNUNET_i2s (&n->peer));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# peers disconnected due to inactivity"), 1,
+ GNUNET_NO);
q_in = GNUNET_BANDWIDTH_value_init (0); /* force disconnect */
}
#if DEBUG_CORE_QUOTA
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Current quota for `%4s' is %u/%llu b/s in (old: %u b/s) / %u out (%u internal)\n",
- GNUNET_i2s (&n->peer),
- (unsigned int) ntohl (q_in.value__),
- bandwidth_target_out_bps,
- (unsigned int) ntohl (n->bw_in.value__),
+ GNUNET_i2s (&n->peer), (unsigned int) ntohl (q_in.value__),
+ bandwidth_target_out_bps, (unsigned int) ntohl (n->bw_in.value__),
(unsigned int) ntohl (n->bw_out.value__),
(unsigned int) ntohl (n->bw_out_internal_limit.value__));
#endif
n = create_neighbour (peer);
}
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# peers connected (transport)"),
- 1, GNUNET_NO);
+ gettext_noop ("# peers connected (transport)"), 1,
+ GNUNET_NO);
n->is_connected = GNUNET_YES;
update_neighbour_performance (n, ats, ats_count);
- GNUNET_BANDWIDTH_tracker_init (&n->available_send_window,
- n->bw_out, MAX_WINDOW_TIME_S);
- GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window,
- n->bw_in, MAX_WINDOW_TIME_S);
+ GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, n->bw_out,
+ MAX_WINDOW_TIME_S);
+ GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window, n->bw_in,
+ MAX_WINDOW_TIME_S);
#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received connection from `%4s'.\n", GNUNET_i2s (&n->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n",
+ GNUNET_i2s (&n->peer));
#endif
GNUNET_TRANSPORT_set_quota (transport, &n->peer, n->bw_in, n->bw_out);
send_key (n);
GNUNET_break (n->is_connected == GNUNET_YES);
if (n->status == PEER_STATE_KEY_CONFIRMED)
{
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# peers disconnected due to transport disconnect"), 1,
+ GNUNET_NO);
cnm.header.size = htons (sizeof (struct DisconnectNotifyMessage));
cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
cnm.reserved = htonl (0);
}
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# peers connected (transport)"),
- -1, GNUNET_NO);
+ gettext_noop ("# peers connected (transport)"), -1,
+ GNUNET_NO);
if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (n->dead_clean_task);
left =
GNUNET_assert (transport != NULL);
GNUNET_TRANSPORT_disconnect (transport);
transport = NULL;
- GNUNET_CONTAINER_multihashmap_iterate (neighbours,
- &free_neighbour_helper, NULL);
+ GNUNET_CONTAINER_multihashmap_iterate (neighbours, &free_neighbour_helper,
+ NULL);
GNUNET_CONTAINER_multihashmap_destroy (neighbours);
neighbours = NULL;
GNUNET_STATISTICS_set (stats, gettext_noop ("# neighbour entries allocated"),
* @param c configuration to use
*/
static void
-run (void *cls,
- struct GNUNET_SERVER_Handle *server,
+run (void *cls, struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
sizeof (struct SendMessageRequest)},
{&handle_client_send, NULL,
GNUNET_MESSAGE_TYPE_CORE_SEND, 0},
- {&handle_client_request_connect, NULL,
- GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT,
- sizeof (struct ConnectMessage)},
{NULL, NULL, 0, 0}
};
char *keyfile;
cfg = c;
/* parse configuration */
if ((GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (c,
- "CORE",
- "TOTAL_QUOTA_IN",
+ GNUNET_CONFIGURATION_get_value_number (c, "CORE", "TOTAL_QUOTA_IN",
&bandwidth_target_in_bps)) ||
(GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (c,
- "CORE",
- "TOTAL_QUOTA_OUT",
+ GNUNET_CONFIGURATION_get_value_number (c, "CORE", "TOTAL_QUOTA_OUT",
&bandwidth_target_out_bps)) ||
(GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (c,
- "GNUNETD",
- "HOSTKEY", &keyfile)))
+ GNUNET_CONFIGURATION_get_value_filename (c, "GNUNETD", "HOSTKEY",
+ &keyfile)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_
}
neighbours = GNUNET_CONTAINER_multihashmap_create (128);
GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
- GNUNET_CRYPTO_hash (&my_public_key,
- sizeof (my_public_key), &my_identity.hashPubKey);
+ GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key),
+ &my_identity.hashPubKey);
self.public_key = &my_public_key;
self.peer = my_identity;
self.last_activity = GNUNET_TIME_UNIT_FOREVER_ABS;
self.status = PEER_STATE_KEY_CONFIRMED;
self.is_connected = GNUNET_YES;
/* setup notification */
- notifier = GNUNET_SERVER_notification_context_create (server,
- MAX_NOTIFY_QUEUE);
+ notifier =
+ GNUNET_SERVER_notification_context_create (server, MAX_NOTIFY_QUEUE);
GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
/* setup transport connection */
- transport = GNUNET_TRANSPORT_connect (cfg,
- &my_identity,
- NULL,
- &handle_transport_receive,
- &handle_transport_notify_connect,
- &handle_transport_notify_disconnect);
+ transport =
+ GNUNET_TRANSPORT_connect (cfg, &my_identity, NULL,
+ &handle_transport_receive,
+ &handle_transport_notify_connect,
+ &handle_transport_notify_disconnect);
GNUNET_assert (NULL != transport);
stats = GNUNET_STATISTICS_create ("core", cfg);
-
- GNUNET_STATISTICS_set (stats,
- gettext_noop ("# discarded CORE_SEND requests"),
- 0, GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- gettext_noop
- ("# discarded lower priority CORE_SEND requests"), 0,
- GNUNET_NO);
-
mst = GNUNET_SERVER_mst_create (&deliver_message, NULL);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &cleaning_task, NULL);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task,
+ NULL);
/* process client requests */
GNUNET_SERVER_add_handlers (server, handlers);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Core service of `%4s' ready.\n"), GNUNET_i2s (&my_identity));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Core service of `%4s' ready.\n"),
+ GNUNET_i2s (&my_identity));
}
main (int argc, char *const *argv)
{
return (GNUNET_OK ==
- GNUNET_SERVICE_run (argc,
- argv,
- "core",
- GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
+ GNUNET_SERVICE_run (argc, argv, "core", GNUNET_SERVICE_OPTION_NONE,
+ &run, NULL)) ? 0 : 1;
}
/* end of gnunet-service-core.c */