summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-tng.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-04-18 17:49:27 +0200
committerChristian Grothoff <christian@grothoff.org>2019-04-18 18:44:13 +0200
commit03da5328a30f9e4367e3f5912d02a8472bfaa766 (patch)
tree74ff1965913e865902039cb093efbbf8dfa7ffc5 /src/transport/gnunet-service-tng.c
parent6ea190f42924f74736fe21ec5bd38df105e39562 (diff)
apply clang format to gnunet-service-tng.c
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r--src/transport/gnunet-service-tng.c2118
1 files changed, 907 insertions, 1211 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 27c97860e..ccce8bbbc 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -156,47 +156,55 @@
* of seconds we log a warning. Note: this is for testing,
* the value chosen here might be too aggressively low!
*/
-#define DELAY_WARN_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define DELAY_WARN_THRESHOLD \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
/**
* We only consider queues as "quality" connections when
* suppressing the generation of DV initiation messages if
* the latency of the queue is below this threshold.
*/
-#define DV_QUALITY_RTT_THRESHOLD GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+#define DV_QUALITY_RTT_THRESHOLD \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
/**
* How long do we consider a DV path valid if we see no
* further updates on it? Note: the value chosen here might be too low!
*/
-#define DV_PATH_VALIDITY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+#define DV_PATH_VALIDITY_TIMEOUT \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
/**
* How long before paths expire would we like to (re)discover DV paths? Should
* be below #DV_PATH_VALIDITY_TIMEOUT.
*/
-#define DV_PATH_DISCOVERY_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
+#define DV_PATH_DISCOVERY_FREQUENCY \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
/**
* How long are ephemeral keys valid?
*/
-#define EPHEMERAL_VALIDITY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
+#define EPHEMERAL_VALIDITY \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
/**
* How long do we keep partially reassembled messages around before giving up?
*/
-#define REASSEMBLY_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
+#define REASSEMBLY_EXPIRATION \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
/**
* What is the fastest rate at which we send challenges *if* we keep learning
* an address (gossip, DHT, etc.)?
*/
-#define FAST_VALIDATION_CHALLENGE_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
+#define FAST_VALIDATION_CHALLENGE_FREQ \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
/**
* What is the slowest rate at which we send challenges?
*/
-#define MAX_VALIDATION_CHALLENGE_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
+#define MAX_VALIDATION_CHALLENGE_FREQ \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
/**
* What is the non-randomized base frequency at which we
@@ -213,11 +221,13 @@
/**
* When do we forget an invalid address for sure?
*/
-#define MAX_ADDRESS_VALID_UNTIL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
+#define MAX_ADDRESS_VALID_UNTIL \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
/**
* How long do we consider an address valid if we just checked?
*/
-#define ADDRESS_VALIDATION_LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
+#define ADDRESS_VALIDATION_LIFETIME \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
/**
* What is the maximum frequency at which we do address validation?
@@ -337,7 +347,6 @@ struct EphemeralConfirmation
* to encrypt the payload.
*/
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
-
};
@@ -392,7 +401,6 @@ struct TransportBackchannelRequestPayload
/* Followed by a 0-termianted string specifying the name of
the communicator which is to receive the message */
-
};
@@ -491,7 +499,6 @@ struct TransportFragmentBox
* Total size of the message that is being fragmented.
*/
uint16_t msg_size GNUNET_PACKED;
-
};
@@ -585,7 +592,6 @@ struct DvInitPS
* Challenge value used by the initiator to re-identify the path.
*/
struct GNUNET_ShortHashCode challenge;
-
};
@@ -626,7 +632,6 @@ struct DvHopPS
* Challenge value used by the initiator to re-identify the path.
*/
struct GNUNET_ShortHashCode challenge;
-
};
@@ -646,7 +651,6 @@ struct DVPathEntryP
* #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP
*/
struct GNUNET_CRYPTO_EddsaSignature hop_sig;
-
};
@@ -712,7 +716,6 @@ struct TransportDVLearn
/* Followed by @e num_hops `struct DVPathEntryP` values,
excluding the initiator of the DV trace; the last entry is the
current sender; the current peer must not be included. */
-
};
@@ -817,7 +820,6 @@ struct TransportValidationPS
* Challenge signed by the receiving peer.
*/
struct GNUNET_ShortHashCode challenge;
-
};
@@ -863,7 +865,6 @@ struct TransportValidationResponse
};
-
GNUNET_NETWORK_STRUCT_END
@@ -925,7 +926,6 @@ struct LearnLaunchEntry
* determine freshness of paths learned via this operation.
*/
struct GNUNET_TIME_Absolute launch_time;
-
};
@@ -1050,8 +1050,9 @@ struct DistanceVectorHop
struct GNUNET_TIME_Absolute freshness;
/**
- * How many hops in total to the `target` (excluding @e next_hop and `target` itself),
- * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)?
+ * How many hops in total to the `target` (excluding @e next_hop and `target`
+ * itself), thus 0 still means a distance of 2 hops (to @e next_hop and then
+ * to `target`)?
*/
unsigned int distance;
};
@@ -1353,7 +1354,8 @@ struct ReassemblyContext
*/
uint16_t msg_missing;
- /* Followed by @e msg_size bytes of the (partially) defragmented original message */
+ /* Followed by @e msg_size bytes of the (partially) defragmented original
+ * message */
/* Followed by @e bitfield data */
};
@@ -1480,7 +1482,6 @@ struct PeerRequest
* How much bandwidth would this @e tc like to see?
*/
struct GNUNET_BANDWIDTH_Value32NBO bw;
-
};
@@ -1567,17 +1568,20 @@ struct PendingMessage
struct PendingMessage *prev_client;
/**
- * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx)
+ * Kept in a MDLL of messages from this @a cpm (if @e pmt is
+ * #PMT_FRAGMENT_BOx)
*/
struct PendingMessage *next_frag;
/**
- * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX)
+ * Kept in a MDLL of messages from this @a cpm (if @e pmt is
+ * #PMT_FRAGMENT_BOX)
*/
struct PendingMessage *prev_frag;
/**
- * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE.
+ * This message, reliability boxed. Only possibly available if @e pmt is
+ * #PMT_CORE.
*/
struct PendingMessage *bpm;
@@ -1702,7 +1706,6 @@ struct AddressListEntry
* Network type offered by this address.
*/
enum GNUNET_NetworkType nt;
-
};
@@ -1743,7 +1746,8 @@ struct TransportClient
/**
* Information for @e type #CT_CORE.
*/
- struct {
+ struct
+ {
/**
* Head of list of messages pending for this client, sorted by
@@ -1761,7 +1765,8 @@ struct TransportClient
/**
* Information for @e type #CT_MONITOR.
*/
- struct {
+ struct
+ {
/**
* Peer identity to monitor the addresses of.
@@ -1781,7 +1786,8 @@ struct TransportClient
/**
* Information for @e type #CT_COMMUNICATOR.
*/
- struct {
+ struct
+ {
/**
* If @e type is #CT_COMMUNICATOR, this communicator
* supports communicating using these addresses.
@@ -1799,12 +1805,14 @@ struct TransportClient
struct Queue *queue_tail;
/**
- * Head of list of the addresses of this peer offered by this communicator.
+ * Head of list of the addresses of this peer offered by this
+ * communicator.
*/
struct AddressListEntry *addr_head;
/**
- * Tail of list of the addresses of this peer offered by this communicator.
+ * Tail of list of the addresses of this peer offered by this
+ * communicator.
*/
struct AddressListEntry *addr_tail;
@@ -1825,7 +1833,8 @@ struct TransportClient
/**
* Information for @e type #CT_APPLICATION
*/
- struct {
+ struct
+ {
/**
* Map of requests for peers the given client application would like to
@@ -1836,7 +1845,6 @@ struct TransportClient
} application;
} details;
-
};
@@ -1940,7 +1948,6 @@ struct ValidationState
* the respective queue to become available for transmission.
*/
int awaiting_queue;
-
};
@@ -2058,9 +2065,7 @@ static struct GNUNET_SCHEDULER_Task *validation_task;
static void
free_ephemeral (struct EphemeralCacheEntry *ece)
{
- GNUNET_CONTAINER_multipeermap_remove (ephemeral_map,
- &ece->target,
- ece);
+ GNUNET_CONTAINER_multipeermap_remove (ephemeral_map, &ece->target, ece);
GNUNET_CONTAINER_heap_remove_node (ece->hn);
GNUNET_free (ece);
}
@@ -2074,9 +2079,7 @@ free_ephemeral (struct EphemeralCacheEntry *ece)
static void
free_validation_state (struct ValidationState *vs)
{
- GNUNET_CONTAINER_multipeermap_remove (validation_map,
- &vs->pid,
- vs);
+ GNUNET_CONTAINER_multipeermap_remove (validation_map, &vs->pid, vs);
GNUNET_CONTAINER_heap_remove_node (vs->hn);
vs->hn = NULL;
if (NULL != vs->sc)
@@ -2098,8 +2101,7 @@ free_validation_state (struct ValidationState *vs)
static struct Neighbour *
lookup_neighbour (const struct GNUNET_PeerIdentity *pid)
{
- return GNUNET_CONTAINER_multipeermap_get (neighbours,
- pid);
+ return GNUNET_CONTAINER_multipeermap_get (neighbours, pid);
}
@@ -2134,8 +2136,6 @@ struct MonitorEvent
* Bytes pending.
*/
uint32_t num_bytes_pending;
-
-
};
@@ -2153,14 +2153,8 @@ free_distance_vector_hop (struct DistanceVectorHop *dvh)
struct Neighbour *n = dvh->next_hop;
struct DistanceVector *dv = dvh->dv;
- GNUNET_CONTAINER_MDLL_remove (neighbour,
- n->dv_head,
- n->dv_tail,
- dvh);
- GNUNET_CONTAINER_MDLL_remove (dv,
- dv->dv_head,
- dv->dv_tail,
- dvh);
+ GNUNET_CONTAINER_MDLL_remove (neighbour, n->dv_head, n->dv_tail, dvh);
+ GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, dvh);
GNUNET_free (dvh);
}
@@ -2180,10 +2174,9 @@ free_dv_route (struct DistanceVector *dv)
free_distance_vector_hop (dvh);
if (NULL == dv->dv_head)
{
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (dv_routes,
- &dv->target,
- dv));
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (dv_routes, &dv->target, dv));
if (NULL != dv->timeout_task)
GNUNET_SCHEDULER_cancel (dv->timeout_task);
GNUNET_free (dv);
@@ -2227,11 +2220,8 @@ notify_monitor (struct TransportClient *tc,
md->cs = htonl ((uint32_t) me->cs);
md->num_msg_pending = htonl (me->num_msg_pending);
md->num_bytes_pending = htonl (me->num_bytes_pending);
- memcpy (&md[1],
- address,
- addr_len);
- GNUNET_MQ_send (tc->mq,
- env);
+ memcpy (&md[1], address, addr_len);
+ GNUNET_MQ_send (tc->mq, env);
}
@@ -2250,23 +2240,16 @@ notify_monitors (const struct GNUNET_PeerIdentity *peer,
enum GNUNET_NetworkType nt,
const struct MonitorEvent *me)
{
- for (struct TransportClient *tc = clients_head;
- NULL != tc;
- tc = tc->next)
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
{
if (CT_MONITOR != tc->type)
continue;
if (tc->details.monitor.one_shot)
continue;
- if ( (0 != GNUNET_is_zero (&tc->details.monitor.peer)) &&
- (0 != GNUNET_memcmp (&tc->details.monitor.peer,
- peer)) )
+ if ((0 != GNUNET_is_zero (&tc->details.monitor.peer)) &&
+ (0 != GNUNET_memcmp (&tc->details.monitor.peer, peer)))
continue;
- notify_monitor (tc,
- peer,
- address,
- nt,
- me);
+ notify_monitor (tc, peer, address, nt, me);
}
}
@@ -2291,12 +2274,8 @@ client_connect_cb (void *cls,
tc = GNUNET_new (struct TransportClient);
tc->client = client;
tc->mq = mq;
- GNUNET_CONTAINER_DLL_insert (clients_head,
- clients_tail,
- tc);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %p connected\n",
- tc);
+ GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
return tc;
}
@@ -2311,8 +2290,7 @@ free_reassembly_context (struct ReassemblyContext *rc)
{
struct Neighbour *n = rc->neighbour;
- GNUNET_assert (rc ==
- GNUNET_CONTAINER_heap_remove_node (rc->hn));
+ GNUNET_assert (rc == GNUNET_CONTAINER_heap_remove_node (rc->hn));
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multishortmap_remove (n->reassembly_map,
&rc->msg_uuid,
@@ -2335,15 +2313,17 @@ reassembly_cleanup_task (void *cls)
n->reassembly_timeout_task = NULL;
while (NULL != (rc = GNUNET_CONTAINER_heap_peek (n->reassembly_heap)))
{
- if (0 == GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout).rel_value_us)
+ if (0 == GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout)
+ .rel_value_us)
{
free_reassembly_context (rc);
continue;
}
GNUNET_assert (NULL == n->reassembly_timeout_task);
- n->reassembly_timeout_task = GNUNET_SCHEDULER_add_at (rc->reassembly_timeout,
- &reassembly_cleanup_task,
- n);
+ n->reassembly_timeout_task =
+ GNUNET_SCHEDULER_add_at (rc->reassembly_timeout,
+ &reassembly_cleanup_task,
+ n);
return;
}
}
@@ -2363,9 +2343,9 @@ free_reassembly_cb (void *cls,
void *value)
{
struct ReassemblyContext *rc = value;
+
(void) cls;
(void) key;
-
free_reassembly_context (rc);
return GNUNET_OK;
}
@@ -2428,12 +2408,10 @@ core_send_connect_info (struct TransportClient *tc,
struct ConnectInfoMessage *cim;
GNUNET_assert (CT_CORE == tc->type);
- env = GNUNET_MQ_msg (cim,
- GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
+ env = GNUNET_MQ_msg (cim, GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
cim->quota_out = quota_out;
cim->id = *pid;
- GNUNET_MQ_send (tc->mq,
- env);
+ GNUNET_MQ_send (tc->mq, env);
}
@@ -2447,15 +2425,11 @@ static void
cores_send_connect_info (const struct GNUNET_PeerIdentity *pid,
struct GNUNET_BANDWIDTH_Value32NBO quota_out)
{
- for (struct TransportClient *tc = clients_head;
- NULL != tc;
- tc = tc->next)
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
{
if (CT_CORE != tc->type)
continue;
- core_send_connect_info (tc,
- pid,
- quota_out);
+ core_send_connect_info (tc, pid, quota_out);
}
}
@@ -2468,20 +2442,16 @@ cores_send_connect_info (const struct GNUNET_PeerIdentity *pid,
static void
cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid)
{
- for (struct TransportClient *tc = clients_head;
- NULL != tc;
- tc = tc->next)
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
{
struct GNUNET_MQ_Envelope *env;
struct DisconnectInfoMessage *dim;
if (CT_CORE != tc->type)
continue;
- env = GNUNET_MQ_msg (dim,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
+ env = GNUNET_MQ_msg (dim, GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
dim->peer = *pid;
- GNUNET_MQ_send (tc->mq,
- env);
+ GNUNET_MQ_send (tc->mq, env);
}
}
@@ -2519,10 +2489,11 @@ schedule_transmit_on_queue (struct Queue *queue)
if (queue->tc->details.communicator.total_queue_length >=
COMMUNICATOR_TOTAL_QUEUE_LIMIT)
{
- GNUNET_STATISTICS_update (GST_stats,
- "# Transmission throttled due to communicator queue limit",
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ GST_stats,
+ "# Transmission throttled due to communicator queue limit",
+ 1,
+ GNUNET_NO);
return;
}
if (queue->queue_length >= QUEUE_LENGTH_LIMIT)
@@ -2534,32 +2505,27 @@ schedule_transmit_on_queue (struct Queue *queue)
return;
}
- wsize = (0 == queue->mtu)
- ? pm->bytes_msg /* FIXME: add overheads? */
- : queue->mtu;
- out_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_out,
- wsize);
- out_delay = GNUNET_TIME_relative_max (GNUNET_TIME_absolute_get_remaining (pm->next_attempt),
+ wsize = (0 == queue->mtu) ? pm->bytes_msg /* FIXME: add overheads? */
+ : queue->mtu;
+ out_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_out, wsize);
+ out_delay = GNUNET_TIME_relative_max (GNUNET_TIME_absolute_get_remaining (
+ pm->next_attempt),
out_delay);
if (0 == out_delay.rel_value_us)
return; /* we should run immediately! */
/* queue has changed since we were scheduled, reschedule again */
- queue->transmit_task
- = GNUNET_SCHEDULER_add_delayed (out_delay,
- &transmit_on_queue,
- queue);
+ queue->transmit_task =
+ GNUNET_SCHEDULER_add_delayed (out_delay, &transmit_on_queue, queue);
if (out_delay.rel_value_us > DELAY_WARN_THRESHOLD.rel_value_us)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Next transmission on queue `%s' in %s (high delay)\n",
queue->address,
- GNUNET_STRINGS_relative_time_to_string (out_delay,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (out_delay, GNUNET_YES));
else
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Next transmission on queue `%s' in %s\n",
queue->address,
- GNUNET_STRINGS_relative_time_to_string (out_delay,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (out_delay, GNUNET_YES));
}
@@ -2583,10 +2549,8 @@ free_queue (struct Queue *queue)
{
struct Neighbour *neighbour = queue->neighbour;
struct TransportClient *tc = queue->tc;
- struct MonitorEvent me = {
- .cs = GNUNET_TRANSPORT_CS_DOWN,
- .rtt = GNUNET_TIME_UNIT_FOREVER_REL
- };
+ struct MonitorEvent me = {.cs = GNUNET_TRANSPORT_CS_DOWN,
+ .rtt = GNUNET_TIME_UNIT_FOREVER_REL};
struct QueueEntry *qe;
int maxxed;
@@ -2608,40 +2572,36 @@ free_queue (struct Queue *queue)
tc->details.communicator.queue_head,
tc->details.communicator.queue_tail,
queue);
- maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >= tc->details.communicator.total_queue_length);
+ maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >=
+ tc->details.communicator.total_queue_length);
while (NULL != (qe = queue->queue_head))
{
- GNUNET_CONTAINER_DLL_remove (queue->queue_head,
- queue->queue_tail,
- qe);
+ GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe);
queue->queue_length--;
tc->details.communicator.total_queue_length--;
GNUNET_free (qe);
}
GNUNET_assert (0 == queue->queue_length);
- if ( (maxxed) &&
- (COMMUNICATOR_TOTAL_QUEUE_LIMIT < tc->details.communicator.total_queue_length) )
+ if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT <
+ tc->details.communicator.total_queue_length))
{
/* Communicator dropped below threshold, resume all queues */
- GNUNET_STATISTICS_update (GST_stats,
- "# Transmission throttled due to communicator queue limit",
- -1,
- GNUNET_NO);
- for (struct Queue *s = tc->details.communicator.queue_head;
- NULL != s;
+ GNUNET_STATISTICS_update (
+ GST_stats,
+ "# Transmission throttled due to communicator queue limit",
+ -1,
+ GNUNET_NO);
+ for (struct Queue *s = tc->details.communicator.queue_head; NULL != s;
s = s->next_client)
schedule_transmit_on_queue (s);
}
- notify_monitors (&neighbour->pid,
- queue->address,
- queue->nt,
- &me);
+ notify_monitors (&neighbour->pid, queue->address, queue->nt, &me);
GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in);
GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out);
GNUNET_free (queue);
update_neighbour_core_visibility (neighbour);
- cores_send_disconnect_info (&neighbour->pid);
+ cores_send_disconnect_info (&neighbour->pid);
if (NULL == neighbour->queue_head)
{
@@ -2694,10 +2654,11 @@ stop_peer_request (void *cls,
struct PeerRequest *pr = value;
GNUNET_PEERSTORE_watch_cancel (pr->wc);
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests,
- pid,
- pr));
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (tc->details.application.requests,
+ pid,
+ pr));
GNUNET_free (pr);
return GNUNET_OK;
@@ -2723,41 +2684,37 @@ client_disconnect_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p disconnected, cleaning up.\n",
tc);
- GNUNET_CONTAINER_DLL_remove (clients_head,
- clients_tail,
- tc);
+ GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc);
switch (tc->type)
{
case CT_NONE:
break;
- case CT_CORE:
- {
- struct PendingMessage *pm;
+ case CT_CORE: {
+ struct PendingMessage *pm;
- while (NULL != (pm = tc->details.core.pending_msg_head))
- {
- GNUNET_CONTAINER_MDLL_remove (client,
- tc->details.core.pending_msg_head,
- tc->details.core.pending_msg_tail,
- pm);
- pm->client = NULL;
- }
- }
- break;
- case CT_MONITOR:
- break;
- case CT_COMMUNICATOR:
+ while (NULL != (pm = tc->details.core.pending_msg_head))
{
- struct Queue *q;
- struct AddressListEntry *ale;
-
- while (NULL != (q = tc->details.communicator.queue_head))
- free_queue (q);
- while (NULL != (ale = tc->details.communicator.addr_head))
- free_address_list_entry (ale);
- GNUNET_free (tc->details.communicator.address_prefix);
+ GNUNET_CONTAINER_MDLL_remove (client,
+ tc->details.core.pending_msg_head,
+ tc->details.core.pending_msg_tail,
+ pm);
+ pm->client = NULL;
}
+ }
+ break;
+ case CT_MONITOR:
break;
+ case CT_COMMUNICATOR: {
+ struct Queue *q;
+ struct AddressListEntry *ale;
+
+ while (NULL != (q = tc->details.communicator.queue_head))
+ free_queue (q);
+ while (NULL != (ale = tc->details.communicator.addr_head))
+ free_address_list_entry (ale);
+ GNUNET_free (tc->details.communicator.address_prefix);
+ }
+ break;
case CT_APPLICATION:
GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
&stop_peer_request,
@@ -2786,9 +2743,7 @@ notify_client_connect_info (void *cls,
struct TransportClient *tc = cls;
struct Neighbour *neighbour = value;
- core_send_connect_info (tc,
- pid,
- neighbour->quota_out);
+ core_send_connect_info (tc, pid, neighbour->quota_out);
return GNUNET_OK;
}
@@ -2802,17 +2757,14 @@ notify_client_connect_info (void *cls,
* @param start the start message that was sent
*/
static void
-handle_client_start (void *cls,
- const struct StartMessage *start)
+handle_client_start (void *cls, const struct StartMessage *start)
{
struct TransportClient *tc = cls;
uint32_t options;
options = ntohl (start->options);
- if ( (0 != (1 & options)) &&
- (0 !=
- GNUNET_memcmp (&start->self,
- &GST_my_identity)) )
+ if ((0 != (1 & options)) &&
+ (0 != GNUNET_memcmp (&start->self, &GST_my_identity)))
{
/* client thinks this is a different peer, reject */
GNUNET_break (0);
@@ -2840,8 +2792,7 @@ handle_client_start (void *cls,
* @param obm the send message that was sent
*/
static int
-check_client_send (void *cls,
- const struct OutboundMessage *obm)
+check_client_send (void *cls, const struct OutboundMessage *obm)
{
struct TransportClient *tc = cls;
uint16_t size;
@@ -2881,10 +2832,7 @@ free_fragment_tree (struct PendingMessage *root)
while (NULL != (frag = root->head_frag))
{
free_fragment_tree (frag);
- GNUNET_CONTAINER_MDLL_remove (frag,
- root->head_frag,
- root->tail_frag,
- frag);
+ GNUNET_CONTAINER_MDLL_remove (frag, root->head_frag, root->tail_frag, frag);
GNUNET_free (frag);
}
}
@@ -2944,14 +2892,12 @@ client_send_response (struct PendingMessage *pm,
if (NULL != tc)
{
- env = GNUNET_MQ_msg (som,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
+ env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
som->success = htonl ((uint32_t) success);
som->bytes_msg = htons (pm->bytes_msg);
som->bytes_physical = htonl (bytes_physical);
som->peer = target->pid;
- GNUNET_MQ_send (tc->mq,
- env);
+ GNUNET_MQ_send (tc->mq, env);
}
free_pending_message (pm);
}
@@ -2974,9 +2920,7 @@ check_queue_timeouts (void *cls)
n->timeout_task = NULL;
earliest_timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
now = GNUNET_TIME_absolute_get ();
- for (struct PendingMessage *pos = n->pending_msg_head;
- NULL != pos;
- pos = pm)
+ for (struct PendingMessage *pos = n->pending_msg_head; NULL != pos; pos = pm)
{
pm = pos->next_neighbour;
if (pos->timeout.abs_value_us <= now.abs_value_us)
@@ -2985,19 +2929,16 @@ check_queue_timeouts (void *cls)
"# messages dropped (timeout before confirmation)",
1,
GNUNET_NO);
- client_send_response (pm,
- GNUNET_NO,
- 0);
+ client_send_response (pm, GNUNET_NO, 0);
continue;
}
- earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout,
- pos->timeout);
+ earliest_timeout =
+ GNUNET_TIME_absolute_min (earliest_timeout, pos->timeout);
}
n->earliest_timeout = earliest_timeout;
if (NULL != n->pending_msg_head)
- n->timeout_task = GNUNET_SCHEDULER_add_at (earliest_timeout,
- &check_queue_timeouts,
- n);
+ n->timeout_task =
+ GNUNET_SCHEDULER_add_at (earliest_timeout, &check_queue_timeouts, n);
}
@@ -3008,8 +2949,7 @@ check_queue_timeouts (void *cls)
* @param obm the send message that was sent
*/
static void
-handle_client_send (void *cls,
- const struct OutboundMessage *obm)
+handle_client_send (void *cls, const struct OutboundMessage *obm)
{
struct TransportClient *tc = cls;
struct PendingMessage *pm;
@@ -3031,14 +2971,12 @@ handle_client_send (void *cls,
struct GNUNET_MQ_Envelope *env;
struct SendOkMessage *som;
- env = GNUNET_MQ_msg (som,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
+ env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
som->success = htonl (GNUNET_SYSERR);
som->bytes_msg = htonl (bytes_msg);
som->bytes_physical = htonl (0);
som->peer = obm->peer;
- GNUNET_MQ_send (tc->mq,
- env);
+ GNUNET_MQ_send (tc->mq, env);
GNUNET_SERVICE_client_continue (tc->client);
GNUNET_STATISTICS_update (GST_stats,
"# messages dropped (neighbour unknown)",
@@ -3051,10 +2989,9 @@ handle_client_send (void *cls,
pm->client = tc;
pm->target = target;
pm->bytes_msg = bytes_msg;
- pm->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (obm->timeout));
- memcpy (&pm[1],
- &obm[1],
- bytes_msg);
+ pm->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (obm->timeout));
+ memcpy (&pm[1], &obm[1], bytes_msg);
GNUNET_CONTAINER_MDLL_insert (neighbour,
target->pending_msg_head,
target->pending_msg_tail,
@@ -3068,21 +3005,19 @@ handle_client_send (void *cls,
target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us;
if (NULL != target->timeout_task)
GNUNET_SCHEDULER_cancel (target->timeout_task);
- target->timeout_task
- = GNUNET_SCHEDULER_add_at (target->earliest_timeout,
- &check_queue_timeouts,
- target);
+ target->timeout_task = GNUNET_SCHEDULER_add_at (target->earliest_timeout,
+ &check_queue_timeouts,
+ target);
}
if (! was_empty)
return; /* all queues must already be busy */
- for (struct Queue *queue = target->queue_head;
- NULL != queue;
+ for (struct Queue *queue = target->queue_head; NULL != queue;
queue = queue->next_neighbour)
{
/* try transmission on any queue that is idle */
if (NULL == queue->transmit_task)
- queue->transmit_task = GNUNET_SCHEDULER_add_now (&transmit_on_queue,
- queue);
+ queue->transmit_task =
+ GNUNET_SCHEDULER_add_now (&transmit_on_queue, queue);
}
}
@@ -3094,8 +3029,9 @@ handle_client_send (void *cls,
* @param cam the send message that was sent
*/
static int
-check_communicator_available (void *cls,
- const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
+check_communicator_available (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
{
struct TransportClient *tc = cls;
uint16_t size;
@@ -3121,8 +3057,9 @@ check_communicator_available (void *cls,
* @param cam the send message that was sent
*/
static void
-handle_communicator_available (void *cls,
- const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
+handle_communicator_available (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam)
{
struct TransportClient *tc = cls;
uint16_t size;
@@ -3130,10 +3067,10 @@ handle_communicator_available (void *cls,
size = ntohs (cam->header.size) - sizeof (*cam);
if (0 == size)
return; /* receive-only communicator */
- tc->details.communicator.address_prefix
- = GNUNET_strdup ((const char *) &cam[1]);
- tc->details.communicator.cc
- = (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc);
+ tc->details.communicator.address_prefix =
+ GNUNET_strdup ((const char *) &cam[1]);
+ tc->details.communicator.cc =
+ (enum GNUNET_TRANSPORT_CommunicatorCharacteristics) ntohl (cam->cc);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -3146,8 +3083,9 @@ handle_communicator_available (void *cls,
* @return #GNUNET_OK if message is well-formed
*/
static int
-check_communicator_backchannel (void *cls,
- const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
+check_communicator_backchannel (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
{
const struct GNUNET_MessageHeader *inbox;
const char *is;
@@ -3158,7 +3096,7 @@ check_communicator_backchannel (void *cls,
msize = ntohs (cb->header.size) - sizeof (*cb);
if (UINT16_MAX - msize >
sizeof (struct TransportBackchannelEncapsulationMessage) +
- sizeof (struct TransportBackchannelRequestPayload) )
+ sizeof (struct TransportBackchannelRequestPayload))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -3174,7 +3112,7 @@ check_communicator_backchannel (void *cls,
is += isize;
msize -= isize;
GNUNET_assert (msize > 0);
- if ('\0' != is[msize-1])
+ if ('\0' != is[msize - 1])
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -3197,7 +3135,8 @@ expire_ephemerals (void *cls)
ephemeral_task = NULL;
while (NULL != (ece = GNUNET_CONTAINER_heap_peek (ephemeral_heap)))
{
- if (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity).rel_value_us)
+ if (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity)
+ .rel_value_us)
{
free_ephemeral (ece);
continue;
@@ -3230,10 +3169,10 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid,
struct EphemeralCacheEntry *ece;
struct EphemeralConfirmation ec;
- ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map,
- pid);
- if ( (NULL != ece) &&
- (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity).rel_value_us) )
+ ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, pid);
+ if ((NULL != ece) &&
+ (0 == GNUNET_TIME_absolute_get_remaining (ece->ephemeral_validity)
+ .rel_value_us))
{
free_ephemeral (ece);
ece = NULL;
@@ -3242,28 +3181,29 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid,
{
ece = GNUNET_new (struct EphemeralCacheEntry);
ece->target = *pid;
- ece->ephemeral_validity = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get_monotonic (GST_cfg),
- EPHEMERAL_VALIDITY);
+ ece->ephemeral_validity =
+ GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get_monotonic (GST_cfg),
+ EPHEMERAL_VALIDITY);
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_ecdhe_key_create2 (&ece->private_key));
- GNUNET_CRYPTO_ecdhe_key_get_public (&ece->private_key,
- &ece->ephemeral_key);
+ GNUNET_CRYPTO_ecdhe_key_get_public (&ece->private_key, &ece->ephemeral_key);
ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
ec.purpose.size = htonl (sizeof (ec));
ec.target = *pid;
ec.ephemeral_key = ece->ephemeral_key;
+ GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &ec.purpose,
+ &ece->sender_sig));
+ ece->hn =
+ GNUNET_CONTAINER_heap_insert (ephemeral_heap,
+ ece,
+ ece->ephemeral_validity.abs_value_us);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
- &ec.purpose,
- &ece->sender_sig));
- ece->hn = GNUNET_CONTAINER_heap_insert (ephemeral_heap,
- ece,
- ece->ephemeral_validity.abs_value_us);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (ephemeral_map,
- &ece->target,
- ece,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multipeermap_put (
+ ephemeral_map,
+ &ece->target,
+ ece,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
if (NULL == ephemeral_task)
ephemeral_task = GNUNET_SCHEDULER_add_at (ece->ephemeral_validity,
&expire_ephemerals,
@@ -3301,9 +3241,7 @@ queue_send_msg (struct Queue *queue,
smt->qid = queue->qid;
smt->mid = queue->mid_gen;
smt->receiver = n->pid;
- memcpy (&smt[1],
- payload,
- payload_size);
+ memcpy (&smt[1], payload, payload_size);
{
/* Pass the env to the communicator of queue for transmission. */
struct QueueEntry *qe;
@@ -3313,14 +3251,11 @@ queue_send_msg (struct Queue *queue,
qe->queue = queue;
// qe->pm = pm; // FIXME: not so easy, reference management on 'free(s)'!
// (also, note that pm may be NULL!)
- GNUNET_CONTAINER_DLL_insert (queue->queue_head,
- queue->queue_tail,
- qe);
+ GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe);
GNUNET_assert (CT_COMMUNICATOR == queue->tc->type);
queue->queue_length++;
queue->tc->details.communicator.total_queue_length++;
- GNUNET_MQ_send (queue->tc->mq,
- env);
+ GNUNET_MQ_send (queue->tc->mq, env);
}
}
@@ -3329,7 +3264,8 @@ queue_send_msg (struct Queue *queue,
* Which transmission options are allowable for transmission?
* Interpreted bit-wise!
*/
-enum RouteMessageOptions {
+enum RouteMessageOptions
+{
/**
* Only confirmed, non-DV direct neighbours.
*/
@@ -3414,25 +3350,20 @@ route_message (const struct GNUNET_PeerIdentity *target,
struct Neighbour *n;
struct DistanceVector *dv;
- n = GNUNET_CONTAINER_multipeermap_get (neighbours,
- target);
+ n = GNUNET_CONTAINER_multipeermap_get (neighbours, target);
dv = (0 != (options & RMO_DV_ALLOWED))
- ? GNUNET_CONTAINER_multipeermap_get (dv_routes,
- target)
- : NULL;
+ ? GNUNET_CONTAINER_multipeermap_get (dv_routes, target)
+ : NULL;
if (0 == (options & RMO_UNCONFIRMED_ALLOWED))
{
/* if confirmed is required, and we do not have anything
confirmed, drop respective options */
- if ( (NULL != n) &&
- (GNUNET_NO == n->core_visible) )
+ if ((NULL != n) && (GNUNET_NO == n->core_visible))
n = NULL;
- if ( (NULL != dv) &&
- (GNUNET_NO == dv->core_visible) )
+ if ((NULL != dv) && (GNUNET_NO == dv->core_visible))
dv = NULL;
}
- if ( (NULL == n) &&
- (NULL == dv) )
+ if ((NULL == n) && (NULL == dv))
{
GNUNET_STATISTICS_update (GST_stats,
"# Messages dropped in routing: no acceptable method",
@@ -3443,30 +3374,23 @@ route_message (const struct GNUNET_PeerIdentity *target,
}
/* If both dv and n are possible and we must choose:
flip a coin for the choice between the two; for now 50/50 */
- if ( (NULL != n) &&
- (NULL != dv) &&
- (0 == (options & RMO_REDUNDANT)) )
+ if ((NULL != n) && (NULL != dv) && (0 == (options & RMO_REDUNDANT)))
{
if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2))
n = NULL;
else
dv = NULL;
}
- if ( (NULL != n) &&
- (NULL != dv) )
+ if ((NULL != n) && (NULL != dv))
options &= ~RMO_REDUNDANT; /* We will do one DV and one direct, that's
enough for redunancy, so clear the flag. */
if (NULL != n)
{
- route_via_neighbour (n,
- hdr,
- options);
+ route_via_neighbour (n, hdr, options);
}
if (NULL != dv)
{
- route_via_dv (dv,
- hdr,
- options);
+ route_via_dv (dv, hdr, options);
}
GNUNET_free (hdr);
}
@@ -3485,7 +3409,8 @@ struct BackchannelKeyState
/**
* Actual key material.
*/
- struct {
+ struct
+ {
/**
* Key used for HMAC calculations (via #GNUNET_CRYPTO_hmac()).
@@ -3495,12 +3420,12 @@ struct BackchannelKeyState
/**
* Symmetric key to use for encryption.
*/
- char aes_key[256/8];
+ char aes_key[256 / 8];
/**
* Counter value to use during setup.
*/
- char aes_ctr[128/8];
+ char aes_ctr[128 / 8];
} material;
};
@@ -3544,20 +3469,18 @@ bc_setup_key_state_from_km (const struct GNUNET_HashCode *km,
* @param key[out] set to the key material
*/
static void
-dh_key_derive_eph_pid (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral,
- const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_ShortHashCode *iv,
- struct BackchannelKeyState *key)
+dh_key_derive_eph_pid (
+ const struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ephemeral,
+ const struct GNUNET_PeerIdentity *target,
+ const struct GNUNET_ShortHashCode *iv,
+ struct BackchannelKeyState *key)
{
struct GNUNET_HashCode km;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CRYPTO_ecdh_eddsa (priv_ephemeral,
- &target->public_key,
- &km));
- bc_setup_key_state_from_km (&km,
- iv,
- key);
+ GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_ecdh_eddsa (priv_ephemeral,
+ &target->public_key,
+ &km));
+ bc_setup_key_state_from_km (&km, iv, key);
}
@@ -3577,13 +3500,10 @@ dh_key_derive_eph_pub (const struct GNUNET_CRYPTO_EcdhePublicKey *pub_ephemeral,
{
struct GNUNET_HashCode km;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CRYPTO_eddsa_ecdh (GST_my_private_key,
- pub_ephemeral,
- &km));
- bc_setup_key_state_from_km (&km,
- iv,
- key);
+ GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_eddsa_ecdh (GST_my_private_key,
+ pub_ephemeral,
+ &km));
+ bc_setup_key_state_from_km (&km, iv, key);
}
@@ -3602,10 +3522,7 @@ bc_hmac (const struct BackchannelKeyState *key,
const void *data,
size_t data_size)
{
- GNUNET_CRYPTO_hmac (&key->material.hmac_key,
- data,
- data_size,
- hmac);
+ GNUNET_CRYPTO_hmac (&key->material.hmac_key, data, data_size, hmac);
}
@@ -3625,11 +3542,7 @@ bc_encrypt (struct BackchannelKeyState *key,
size_t in_size)
{
GNUNET_assert (0 ==
- gcry_cipher_encrypt (key->cipher,
- dst,
- in_size,
- in,
- in_size));
+ gcry_cipher_encrypt (key->cipher, dst, in_size, in, in_size));
}
@@ -3648,12 +3561,8 @@ bc_decrypt (struct BackchannelKeyState *key,
const void *ciph,
size_t out_size)
{
- GNUNET_assert (0 ==
- gcry_cipher_decrypt (key->cipher,
- out,
- out_size,
- ciph,
- out_size));
+ GNUNET_assert (
+ 0 == gcry_cipher_decrypt (key->cipher, out, out_size, ciph, out_size));
}
@@ -3666,8 +3575,7 @@ static void
bc_key_clean (struct BackchannelKeyState *key)
{
gcry_cipher_close (key->cipher);
- GNUNET_CRYPTO_zero_keys (&key->material,
- sizeof (key->material));
+ GNUNET_CRYPTO_zero_keys (&key->material, sizeof (key->material));
}
@@ -3678,8 +3586,9 @@ bc_key_clean (struct BackchannelKeyState *key)
* @param cb the send message that was sent
*/
static void
-handle_communicator_backchannel (void *cls,
- const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
+handle_communicator_backchannel (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
{
struct TransportClient *tc = cls;
struct GNUNET_CRYPTO_EcdhePrivateKey private_key;
@@ -3691,9 +3600,11 @@ handle_communicator_backchannel (void *cls,
uint16_t msize;
/* encapsulate and encrypt message */
- msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload);
+ msize = ntohs (cb->header.size) - sizeof (*cb) +
+ sizeof (struct TransportBackchannelRequestPayload);
enc = GNUNET_malloc (sizeof (*enc) + msize);
- enc->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION);
+ enc->header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION);
enc->header.size = htons (sizeof (*enc) + msize);
enc->target = cb->pid;
lookup_ephemeral (&cb->pid,
@@ -3704,17 +3615,12 @@ handle_communicator_backchannel (void *cls,
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&enc->iv,
sizeof (enc->iv));
- dh_key_derive_eph_pid (&private_key,
- &cb->pid,
- &enc->iv,
- &key);
+ dh_key_derive_eph_pid (&private_key, &cb->pid, &enc->iv, &key);
ppay.ephemeral_validity = GNUNET_TIME_absolute_hton (ephemeral_validity);
- ppay.monotonic_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg));
+ ppay.monotonic_time =
+ GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg));
mpos = (char *) &enc[1];
- bc_encrypt (&key,
- &ppay,
- mpos,
- sizeof (ppay));
+ bc_encrypt (&key, &ppay, mpos, sizeof (ppay));
bc_encrypt (&key,
&cb[1],
&mpos[sizeof (ppay)],
@@ -3724,9 +3630,7 @@ handle_communicator_backchannel (void *cls,
mpos,
sizeof (ppay) + ntohs (cb->header.size) - sizeof (*cb));
bc_key_clean (&key);
- route_message (&cb->pid,
- &enc->header,
- RMO_DV_ALLOWED);
+ route_message (&cb->pid, &enc->header, RMO_DV_ALLOWED);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -3770,8 +3674,7 @@ store_pi (void *cls);
* @param success #GNUNET_YES if peerstore was successful
*/
static void
-peerstore_store_own_cb (void *cls,
- int success)
+peerstore_store_own_cb (void *cls, int success)
{
struct AddressListEntry *ale = cls;
@@ -3782,10 +3685,11 @@ peerstore_store_own_cb (void *cls,
ale->address);
/* refresh period is 1/4 of expiration time, that should be plenty
without being excessive. */
- ale->st = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (ale->expiration,
- 4ULL),
- &store_pi,
- ale);
+ ale->st =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (ale->expiration,
+ 4ULL),
+ &store_pi,
+ ale);
}
@@ -3826,9 +3730,8 @@ store_pi (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to store our address `%s' with peerstore\n",
ale->address);
- ale->st = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &store_pi,
- ale);
+ ale->st =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &store_pi, ale);
}
}
@@ -3854,14 +3757,11 @@ handle_add_address (void *cls,
ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration);
ale->aid = aam->aid;
ale->nt = (enum GNUNET_NetworkType) ntohl (aam->nt);
- memcpy (&ale[1],
- &aam[1],
- slen);
+ memcpy (&ale[1], &aam[1], slen);
GNUNET_CONTAINER_DLL_insert (tc->details.communicator.addr_head,
tc->details.communicator.addr_tail,
ale);
- ale->st = GNUNET_SCHEDULER_add_now (&store_pi,
- ale);
+ ale->st = GNUNET_SCHEDULER_add_now (&store_pi, ale);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -3949,13 +3849,11 @@ finish_cmc_handling (struct CommunicatorMessageContext *cmc)
struct GNUNET_MQ_Envelope *env;
struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
- env = GNUNET_MQ_msg (ack,
- GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK);
+ env = GNUNET_MQ_msg (ack, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK);
ack->reserved = htonl (0);
ack->fc_id = cmc->im.fc_id;
ack->sender = cmc->im.sender;
- GNUNET_MQ_send (cmc->tc->mq,
- env);
+ GNUNET_MQ_send (cmc->tc->mq, env);
}
GNUNET_SERVICE_client_continue (cmc->tc->client);
GNUNET_free (cmc);
@@ -3966,18 +3864,18 @@ finish_cmc_handling (struct CommunicatorMessageContext *cmc)
* Communicator gave us an unencapsulated message to pass as-is to
* CORE. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param mh the message that was received
*/
static void
-handle_raw_message (void *cls,
- const struct GNUNET_MessageHeader *mh)
+handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
{
struct CommunicatorMessageContext *cmc = cls;
uint16_t size = ntohs (mh->size);
- if ( (size > UINT16_MAX - sizeof (struct InboundMessage)) ||
- (size < sizeof (struct GNUNET_MessageHeader)) )
+ if ((size > UINT16_MAX - sizeof (struct InboundMessage)) ||
+ (size < sizeof (struct GNUNET_MessageHeader)))
{
struct GNUNET_SERVICE_Client *client = cmc->tc->client;
@@ -3987,24 +3885,17 @@ handle_raw_message (void *cls,
return;
}
/* Forward to all CORE clients */
- for (struct TransportClient *tc = clients_head;
- NULL != tc;
- tc = tc->next)
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
{
struct GNUNET_MQ_Envelope *env;
struct InboundMessage *im;
if (CT_CORE != tc->type)
continue;
- env = GNUNET_MQ_msg_extra (im,
- size,
- GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
+ env = GNUNET_MQ_msg_extra (im, size, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
im->peer = cmc->im.sender;
- memcpy (&im[1],
- mh,
- size);
- GNUNET_MQ_send (tc->mq,
- env);
+ memcpy (&im[1], mh, size);
+ GNUNET_MQ_send (tc->mq, env);
}
/* FIXME: consider doing this _only_ once the message
was drained from the CORE MQs to extend flow control to CORE!
@@ -4021,8 +3912,7 @@ handle_raw_message (void *cls,
* @return #GNUNET_YES if message is well-formed
*/
static int
-check_fragment_box (void *cls,
- const struct TransportFragmentBox *fb)
+check_fragment_box (void *cls, const struct TransportFragmentBox *fb)
{
uint16_t size = ntohs (fb->header.size);
uint16_t bsize = size - sizeof (*fb);
@@ -4064,14 +3954,12 @@ send_fragment_ack (struct ReassemblyContext *rc)
ack->msg_uuid = rc->msg_uuid;
ack->avg_ack_delay = GNUNET_TIME_relative_hton (rc->avg_ack_delay);
if (0 == rc->msg_missing)
- ack->reassembly_timeout
- = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_FOREVER_REL); /* signal completion */
+ ack->reassembly_timeout = GNUNET_TIME_relative_hton (
+ GNUNET_TIME_UNIT_FOREVER_REL); /* signal completion */
else
- ack->reassembly_timeout
- = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout));
- route_message (&rc->neighbour->pid,
- &ack->header,
- RMO_DV_ALLOWED);
+ ack->reassembly_timeout = GNUNET_TIME_relative_hton (
+ GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout));
+ route_message (&rc->neighbour->pid, &ack->header, RMO_DV_ALLOWED);
rc->avg_ack_delay = GNUNET_TIME_UNIT_ZERO;
rc->num_acks = 0;
rc->extra_acks = 0LLU;
@@ -4081,12 +3969,12 @@ send_fragment_ack (struct ReassemblyContext *rc)
/**
* Communicator gave us a fragment. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param fb the message that was received
*/
static void
-handle_fragment_box (void *cls,
- const struct TransportFragmentBox *fb)
+handle_fragment_box (void *cls, const struct TransportFragmentBox *fb)
{
struct CommunicatorMessageContext *cmc = cls;
struct Neighbour *n;
@@ -4100,8 +3988,7 @@ handle_fragment_box (void *cls,
struct GNUNET_TIME_Relative cdelay;
int ack_now;
- n = GNUNET_CONTAINER_multipeermap_get (neighbours,
- &cmc->im.sender);
+ n = GNUNET_CONTAINER_multipeermap_get (neighbours, &cmc->im.sender);
if (NULL == n)
{
struct GNUNET_SERVICE_Client *client = cmc->tc->client;
@@ -4113,34 +4000,35 @@ handle_fragment_box (void *cls,
}
if (NULL == n->reassembly_map)
{
- n->reassembly_map = GNUNET_CONTAINER_multishortmap_create (8,
- GNUNET_YES);
- n->reassembly_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- n->reassembly_timeout_task = GNUNET_SCHEDULER_add_delayed (REASSEMBLY_EXPIRATION,
- &reassembly_cleanup_task,
- n);
+ n->reassembly_map = GNUNET_CONTAINER_multishortmap_create (8, GNUNET_YES);
+ n->reassembly_heap =
+ GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ n->reassembly_timeout_task =
+ GNUNET_SCHEDULER_add_delayed (REASSEMBLY_EXPIRATION,
+ &reassembly_cleanup_task,
+ n);
}
msize = ntohs (fb->msg_size);
- rc = GNUNET_CONTAINER_multishortmap_get (n->reassembly_map,
- &fb->msg_uuid);
+ rc = GNUNET_CONTAINER_multishortmap_get (n->reassembly_map, &fb->msg_uuid);
if (NULL == rc)
{
- rc = GNUNET_malloc (sizeof (*rc) +
- msize + /* reassembly payload buffer */
- (msize + 7) / 8 * sizeof (uint8_t) /* bitfield */);
+ rc = GNUNET_malloc (sizeof (*rc) + msize + /* reassembly payload buffer */
+ (msize + 7) / 8 * sizeof (uint8_t) /* bitfield */);
rc->msg_uuid = fb->msg_uuid;
rc->neighbour = n;
rc->msg_size = msize;
- rc->reassembly_timeout = GNUNET_TIME_relative_to_absolute (REASSEMBLY_EXPIRATION);
+ rc->reassembly_timeout =
+ GNUNET_TIME_relative_to_absolute (REASSEMBLY_EXPIRATION);
rc->last_frag = GNUNET_TIME_absolute_get ();
rc->hn = GNUNET_CONTAINER_heap_insert (n->reassembly_heap,
rc,
rc->reassembly_timeout.abs_value_us);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multishortmap_put (n->reassembly_map,
- &rc->msg_uuid,
- rc,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multishortmap_put (
+ n->reassembly_map,
+ &rc->msg_uuid,
+ rc,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
target = (char *) &rc[1];
rc->bitfield = (uint8_t *) (target + rc->msg_size);
rc->msg_missing = rc->msg_size;
@@ -4159,11 +4047,9 @@ handle_fragment_box (void *cls,
/* reassemble */
fsize = ntohs (fb->header.size) - sizeof (*fb);
frag_off = ntohs (fb->frag_off);
- memcpy (&target[frag_off],
- &fb[1],
- fsize);
+ memcpy (&target[frag_off], &fb[1], fsize);
/* update bitfield and msg_missing */
- for (unsigned int i=frag_off;i<frag_off+fsize;i++)
+ for (unsigned int i = frag_off; i < frag_off + fsize; i++)
{
if (0 == (rc->bitfield[i / 8] & (1 << (i % 8))))
{
@@ -4175,11 +4061,9 @@ handle_fragment_box (void *cls,
/* Compute cummulative ACK */
frag_uuid = ntohl (fb->frag_uuid);
cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag);
- cdelay = GNUNET_TIME_relative_multiply (cdelay,
- rc->num_acks);
+ cdelay = GNUNET_TIME_relative_multiply (cdelay, rc->num_acks);
rc->last_frag = GNUNET_TIME_absolute_get ();
- rc->avg_ack_delay = GNUNET_TIME_relative_add (rc->avg_ack_delay,
- cdelay);
+ rc->avg_ack_delay = GNUNET_TIME_relative_add (rc->avg_ack_delay, cdelay);
ack_now = GNUNET_NO;
if (0 == rc->num_acks)
{
@@ -4188,12 +4072,11 @@ handle_fragment_box (void *cls,
rc->extra_acks = 0LLU;
rc->num_acks = 1;
}
- else if ( (frag_uuid >= rc->frag_uuid) &&
- (frag_uuid <= rc->frag_uuid + 64) )
+ else if ((frag_uuid >= rc->frag_uuid) && (frag_uuid <= rc->frag_uuid + 64))
{
/* case two: ack fits after existing min UUID */
- if ( (frag_uuid == rc->frag_uuid) ||
- (0 != (rc->extra_acks & (1LLU << (frag_uuid - rc->frag_uuid - 1)))) )
+ if ((frag_uuid == rc->frag_uuid) ||
+ (0 != (rc->extra_acks & (1LLU << (frag_uuid - rc->frag_uuid - 1)))))
{
/* duplicate fragment, ack now! */
ack_now = GNUNET_YES;
@@ -4204,11 +4087,12 @@ handle_fragment_box (void *cls,
rc->num_acks++;
}
}
- else if ( (rc->frag_uuid > frag_uuid) &&
- ( ( (rc->frag_uuid == frag_uuid + 64) &&
- (0 == rc->extra_acks) ) ||
- ( (rc->frag_uuid < frag_uuid + 64) &&
- (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) )
+ else if ((rc->frag_uuid > frag_uuid) &&
+ (((rc->frag_uuid == frag_uuid + 64) && (0 == rc->extra_acks)) ||
+ ((rc->frag_uuid < frag_uuid + 64) &&
+ (rc->extra_acks ==
+ (rc->extra_acks &
+ ~((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))))))
{
/* can fit ack by shifting extra acks and starting at
frag_uid, test above esured that the bits we will
@@ -4218,7 +4102,8 @@ handle_fragment_box (void *cls,
rc->frag_uuid = frag_uuid;
rc->num_acks++;
}
- if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */
+ if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very
+ aggressive. */
ack_now = GNUNET_YES; /* maximum acks received */
// FIXME: possibly also ACK based on RTT (but for that we'd need to
// determine the queue used for the ACK first!)
@@ -4242,8 +4127,7 @@ handle_fragment_box (void *cls,
}
/* successful reassembly */
send_fragment_ack (rc);
- demultiplex_with_cmc (cmc,
- msg);
+ demultiplex_with_cmc (cmc, msg);
/* FIXME: really free here? Might be bad if fragments are still
en-route and we forget that we finished this reassembly immediately!
-> keep around until timeout?
@@ -4271,21 +4155,17 @@ check_ack_against_pm (struct PendingMessage *pm,
uint64_t xtra = GNUNET_ntohll (fa->extra_acks);
match = GNUNET_NO;
- for (struct PendingMessage *frag = pm->head_frag;
- NULL != frag;
- frag = nxt)
+ for (struct PendingMessage *frag = pm->head_frag; NULL != frag; frag = nxt)
{
- const struct TransportFragmentBox *tfb
- = (const struct TransportFragmentBox *) &pm[1];
+ const struct TransportFragmentBox *tfb =
+ (const struct TransportFragmentBox *) &pm[1];
uint32_t fu = ntohl (tfb->frag_uuid);
GNUNET_assert (PMT_FRAGMENT_BOX == frag->pmt);
nxt = frag->next_frag;
/* Check for exact match or match in the 'xtra' bitmask */
- if ( (fu == fs) ||
- ( (fu > fs) &&
- (fu <= fs + 64) &&
- (0 != (1LLU << (fu - fs - 1) & xtra)) ) )
+ if ((fu == fs) ||
+ ((fu > fs) && (fu <= fs + 64) && (0 != (1LLU << (fu - fs - 1) & xtra))))
{
match = GNUNET_YES;
free_fragment_tree (frag);
@@ -4298,19 +4178,18 @@ check_ack_against_pm (struct PendingMessage *pm,
/**
* Communicator gave us a fragment acknowledgement. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param fa the message that was received
*/
static void
-handle_fragment_ack (void *cls,
- const struct TransportFragmentAckMessage *fa)
+handle_fragment_ack (void *cls, const struct TransportFragmentAckMessage *fa)
{
struct CommunicatorMessageContext *cmc = cls;
struct Neighbour *n;
int matched;
- n = GNUNET_CONTAINER_multipeermap_get (neighbours,
- &cmc->im.sender);
+ n = GNUNET_CONTAINER_multipeermap_get (neighbours, &cmc->im.sender);
if (NULL == n)
{
struct GNUNET_SERVICE_Client *client = cmc->tc->client;
@@ -4322,21 +4201,16 @@ handle_fragment_ack (void *cls,
}
/* FIXME-OPTIMIZE: maybe use another hash map here? */
matched = GNUNET_NO;
- for (struct PendingMessage *pm = n->pending_msg_head;
- NULL != pm;
+ for (struct PendingMessage *pm = n->pending_msg_head; NULL != pm;
pm = pm->prev_neighbour)
{
- if (0 !=
- GNUNET_memcmp (&fa->msg_uuid,
- &pm->msg_uuid))
+ if (0 != GNUNET_memcmp (&fa->msg_uuid, &pm->msg_uuid))
continue;
matched = GNUNET_YES;
- if (GNUNET_YES ==
- check_ack_against_pm (pm,
- fa))
+ if (GNUNET_YES == check_ack_against_pm (pm, fa))
{
- struct GNUNET_TIME_Relative avg_ack_delay
- = GNUNET_TIME_relative_ntoh (fa->avg_ack_delay);
+ struct GNUNET_TIME_Relative avg_ack_delay =
+ GNUNET_TIME_relative_ntoh (fa->avg_ack_delay);
// FIXME: update RTT and other reliability data!
// ISSUE: we don't know which of n's queues the message(s)
// took (and in fact the different messages might have gone
@@ -4365,9 +4239,10 @@ handle_fragment_ack (void *cls,
}
else
{
- struct GNUNET_TIME_Relative reassembly_timeout
- = GNUNET_TIME_relative_ntoh (fa->reassembly_timeout);
- // OPTIMIZE-FIXME: adjust retransmission strategy based on reassembly_timeout!
+ struct GNUNET_TIME_Relative reassembly_timeout =
+ GNUNET_TIME_relative_ntoh (fa->reassembly_timeout);
+ // OPTIMIZE-FIXME: adjust retransmission strategy based on
+ // reassembly_timeout!
(void) reassembly_timeout;
}
break;
@@ -4391,8 +4266,7 @@ handle_fragment_ack (void *cls,
* @return #GNUNET_YES if message is well-formed
*/
static int
-check_reliability_box (void *cls,
- const struct TransportReliabilityBox *rb)
+check_reliability_box (void *cls, const struct TransportReliabilityBox *rb)
{
GNUNET_MQ_check_boxed_message (rb);
return GNUNET_YES;
@@ -4402,15 +4276,16 @@ check_reliability_box (void *cls,
/**
* Communicator gave us a reliability box. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param rb the message that was received
*/
static void
-handle_reliability_box (void *cls,
- const struct TransportReliabilityBox *rb)
+handle_reliability_box (void *cls, const struct TransportReliabilityBox *rb)
{
struct CommunicatorMessageContext *cmc = cls;
- const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &rb[1];
+ const struct GNUNET_MessageHeader *inbox =
+ (const struct GNUNET_MessageHeader *) &rb[1];
if (0 == ntohl (rb->ack_countdown))
{
@@ -4418,28 +4293,23 @@ handle_reliability_box (void *cls,
/* FIXME: implement cummulative ACKs and ack_countdown,
then setting the avg_ack_delay field below: */
- ack = GNUNET_malloc (sizeof (*ack) +
- sizeof (struct GNUNET_ShortHashCode));
+ ack = GNUNET_malloc (sizeof (*ack) + sizeof (struct GNUNET_ShortHashCode));
ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK);
- ack->header.size = htons (sizeof (*ack) +
- sizeof (struct GNUNET_ShortHashCode));
- memcpy (&ack[1],
- &rb->msg_uuid,
- sizeof (struct GNUNET_ShortHashCode));
- route_message (&cmc->im.sender,
- &ack->header,
- RMO_DV_ALLOWED);
+ ack->header.size =
+ htons (sizeof (*ack) + sizeof (struct GNUNET_ShortHashCode));
+ memcpy (&ack[1], &rb->msg_uuid, sizeof (struct GNUNET_ShortHashCode));
+ route_message (&cmc->im.sender, &ack->header, RMO_DV_ALLOWED);
}
/* continue with inner message */
- demultiplex_with_cmc (cmc,
- inbox);
+ demultiplex_with_cmc (cmc, inbox);
}
/**
* Communicator gave us a reliability ack. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param ra the message that was received
*/
static void
@@ -4453,8 +4323,7 @@ handle_reliability_ack (void *cls,
struct PendingMessage *nxt;
int matched;
- n = GNUNET_CONTAINER_multipeermap_get (neighbours,
- &cmc->im.sender);
+ n = GNUNET_CONTAINER_multipeermap_get (neighbours, &cmc->im.sender);
if (NULL == n)
{
struct GNUNET_SERVICE_Client *client = cmc->tc->client;
@@ -4464,25 +4333,21 @@ handle_reliability_ack (void *cls,
GNUNET_SERVICE_client_drop (client);
return;
}
- n_acks = (ntohs (ra->header.size) - sizeof (*ra))
- / sizeof (struct GNUNET_ShortHashCode);
+ n_acks = (ntohs (ra->header.size) - sizeof (*ra)) /
+ sizeof (struct GNUNET_ShortHashCode);
msg_uuids = (const struct GNUNET_ShortHashCode *) &ra[1];
/* FIXME-OPTIMIZE: maybe use another hash map here? */
matched = GNUNET_NO;
- for (struct PendingMessage *pm = n->pending_msg_head;
- NULL != pm;
- pm = nxt)
+ for (struct PendingMessage *pm = n->pending_msg_head; NULL != pm; pm = nxt)
{
int in_list;
nxt = pm->next_neighbour;
in_list = GNUNET_NO;
- for (unsigned int i=0;i<n_acks;i++)
+ for (unsigned int i = 0; i < n_acks; i++)
{
- if (0 !=
- GNUNET_memcmp (&msg_uuids[i],
- &pm->msg_uuid))
+ if (0 != GNUNET_memcmp (&msg_uuids[i], &pm->msg_uuid))
continue;
in_list = GNUNET_YES;
break;
@@ -4495,8 +4360,8 @@ handle_reliability_ack (void *cls,
free_pending_message (pm);
{
- struct GNUNET_TIME_Relative avg_ack_delay
- = GNUNET_TIME_relative_ntoh (ra->avg_ack_delay);
+ struct GNUNET_TIME_Relative avg_ack_delay =
+ GNUNET_TIME_relative_ntoh (ra->avg_ack_delay);
// FIXME: update RTT and other reliability data!
// ISSUE: we don't know which of n's queues the message(s)
// took (and in fact the different messages might have gone
@@ -4528,15 +4393,16 @@ handle_reliability_ack (void *cls,
* @return #GNUNET_YES if message is well-formed
*/
static int
-check_backchannel_encapsulation (void *cls,
- const struct TransportBackchannelEncapsulationMessage *be)
+check_backchannel_encapsulation (
+ void *cls,
+ const struct TransportBackchannelEncapsulationMessage *be)
{
uint16_t size = ntohs (be->header.size);
(void) cls;
- if (size - sizeof (*be) <
- sizeof (struct TransportBackchannelRequestPayload) +
- sizeof (struct GNUNET_MessageHeader) )
+ if ((size - sizeof (*be)) <
+ (sizeof (struct TransportBackchannelRequestPayload) +
+ sizeof (struct GNUNET_MessageHeader)))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -4550,12 +4416,14 @@ check_backchannel_encapsulation (void *cls,
* (We are not the origin of the backchannel here, the communicator simply
* received a backchannel message and we are expected to forward it.)
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param be the message that was received
*/
static void
-handle_backchannel_encapsulation (void *cls,
- const struct TransportBackchannelEncapsulationMessage *be)
+handle_backchannel_encapsulation (
+ void *cls,
+ const struct TransportBackchannelEncapsulationMessage *be)
{
struct CommunicatorMessageContext *cmc = cls;
struct BackchannelKeyState key;
@@ -4563,8 +4431,7 @@ handle_backchannel_encapsulation (void *cls,
const char *hdr;
size_t hdr_len;
- if (0 != GNUNET_memcmp (&be->target,
- &GST_my_identity))
+ if (0 != GNUNET_memcmp (&be->target, &GST_my_identity))
{
/* not for me, try to route to target */
/* FIXME: someone needs to update be->distance! */
@@ -4576,18 +4443,11 @@ handle_backchannel_encapsulation (void *cls,
finish_cmc_handling (cmc);
return;
}
- dh_key_derive_eph_pub (&be->ephemeral_key,
- &be->iv,
- &key);
+ dh_key_derive_eph_pub (&be->ephemeral_key, &be->iv, &key);
hdr = (const char *) &be[1];
hdr_len = ntohs (be->header.size) - sizeof (*be);
- bc_hmac (&key,
- &hmac,
- hdr,
- hdr_len);
- if (0 !=
- GNUNET_memcmp (&hmac,
- &be->hmac))
+ bc_hmac (&key, &hmac, hdr, hdr_len);
+ if (0 != GNUNET_memcmp (&hmac, &be->hmac))
{
/* HMAC missmatch, disard! */
GNUNET_break_op (0);
@@ -4599,15 +4459,10 @@ handle_backchannel_encapsulation (void *cls,
struct TransportBackchannelRequestPayload ppay;
char body[hdr_len - sizeof (ppay)];
- GNUNET_assert (hdr_len >= sizeof (ppay) + sizeof (struct GNUNET_MessageHeader));
- bc_decrypt (&key,
- &ppay,
- hdr,
- sizeof (ppay));
- bc_decrypt (&key,
- &body,
- &hdr[sizeof (ppay)],
- hdr_len - sizeof (ppay));
+ GNUNET_assert (hdr_len >=
+ sizeof (ppay) + sizeof (struct GNUNET_MessageHeader));
+ bc_decrypt (&key, &ppay, hdr, sizeof (ppay));
+ bc_decrypt (&key, &body, &hdr[sizeof (ppay)], hdr_len - sizeof (ppay));
bc_key_clean (&key);
// FIXME: verify signatures in ppay!
// => check if ephemeral key is known & valid, if not
@@ -4649,9 +4504,8 @@ path_cleanup_cb (void *cls)
free_dv_route (dv);
return;
}
- dv->timeout_task = GNUNET_SCHEDULER_add_at (pos->timeout,
- &path_cleanup_cb,
- dv);
+ dv->timeout_task =
+ GNUNET_SCHEDULER_add_at (pos->timeout, &path_cleanup_cb, dv);
}
@@ -4670,8 +4524,8 @@ path_cleanup_cb (void *cls)
* and then path contains a valid path from us to `path[path_len-1]`
* path[1] should be a direct neighbour (we should check!)
* @param path_len number of entries on the @a path, at least three!
- * @param network_latency how long does the message take from us to `path[path_len-1]`?
- * set to "forever" if unknown
+ * @param network_latency how long does the message take from us to
+ * `path[path_len-1]`? set to "forever" if unknown
* @return #GNUNET_YES on success,
* #GNUNET_NO if we have better path(s) to the target
* #GNUNET_SYSERR if the path is useless and/or invalid
@@ -4694,29 +4548,23 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
GNUNET_break (0);
return GNUNET_SYSERR;
}
- GNUNET_assert (0 ==
- GNUNET_memcmp (&GST_my_identity,
- &path[0]));
- next_hop = GNUNET_CONTAINER_multipeermap_get (neighbours,
- &path[1]);
+ GNUNET_assert (0 == GNUNET_memcmp (&GST_my_identity, &path[0]));
+ next_hop = GNUNET_CONTAINER_multipeermap_get (neighbours, &path[1]);
if (NULL == next_hop)
{
/* next hop must be a neighbour, otherwise this whole thing is useless! */
GNUNET_break (0);
return GNUNET_SYSERR;
}
- for (unsigned int i=2;i<path_len;i++)
- if (NULL !=
- GNUNET_CONTAINER_multipeermap_get (neighbours,
- &path[i]))
+ for (unsigned int i = 2; i < path_len; i++)
+ if (NULL != GNUNET_CONTAINER_multipeermap_get (neighbours, &path[i]))
{
/* Useless path, we have a direct connection to some hop
in the middle of the path, so this one doesn't even
seem terribly useful for redundancy */
return GNUNET_SYSERR;
}
- dv = GNUNET_CONTAINER_multipeermap_get (dv_routes,
- &path[path_len - 1]);
+ dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &path[path_len - 1]);
if (NULL == dv)
{
dv = GNUNET_new (struct DistanceVector);
@@ -4725,15 +4573,15 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
&path_cleanup_cb,
dv);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (dv_routes,
- &dv->target,
- dv,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multipeermap_put (
+ dv_routes,
+ &dv->target,
+ dv,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
/* Check if we have this path already! */
shorter_distance = 0;
- for (struct DistanceVectorHop *pos = dv->dv_head;
- NULL != pos;
+ for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos;
pos = pos->next_dv)
{
if (pos->distance < path_len - 2)
@@ -4741,16 +4589,13 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
/* Note that the distances in 'pos' excludes us (path[0]) and
the next_hop (path[1]), so we need to subtract two
and check next_hop explicitly */
- if ( (pos->distance == path_len - 2) &&
- (pos->next_hop == next_hop) )
+ if ((pos->distance == path_len - 2) && (pos->next_hop == next_hop))
{
int match = GNUNET_YES;
- for (unsigned int i=0;i<pos->distance;i++)
+ for (unsigned int i = 0; i < pos->distance; i++)
{
- if (0 !=
- GNUNET_memcmp (&pos->path[i],
- &path[i+2]))
+ if (0 != GNUNET_memcmp (&pos->path[i], &path[i + 2]))
{
match = GNUNET_NO;
break;
@@ -4766,19 +4611,14 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
1,
GNUNET_NO);
last_timeout = GNUNET_TIME_absolute_get_remaining (pos->timeout);
- pos->timeout
- = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT);
- GNUNET_CONTAINER_MDLL_remove (dv,
- dv->dv_head,
- dv->dv_tail,
- pos);
- GNUNET_CONTAINER_MDLL_insert (dv,
- dv->dv_head,
- dv->dv_tail,
- pos);
+ pos->timeout =
+ GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT);
+ GNUNET_CONTAINER_MDLL_remove (dv, dv->dv_head, dv->dv_tail, pos);
+ GNUNET_CONTAINER_MDLL_insert (dv, dv->dv_head, dv->dv_tail, pos);
if (last_timeout.rel_value_us <
GNUNET_TIME_relative_subtract (DV_PATH_VALIDITY_TIMEOUT,
- DV_PATH_DISCOVERY_FREQUENCY).rel_value_us)
+ DV_PATH_DISCOVERY_FREQUENCY)
+ .rel_value_us)
{
/* Some peer send DV learn messages too often, we are learning
the same path faster than it would be useful; do not forward! */
@@ -4806,10 +4646,7 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
sizeof (struct GNUNET_PeerIdentity) * (path_len - 2));
hop->timeout = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT);
hop->distance = path_len - 2;
- GNUNET_CONTAINER_MDLL_insert (dv,
- dv->dv_head,
- dv->dv_tail,
- hop);
+ GNUNET_CONTAINER_MDLL_insert (dv, dv->dv_head, dv->dv_tail, hop);
GNUNET_CONTAINER_MDLL_insert (neighbour,
next_hop->dv_head,
next_hop->dv_tail,
@@ -4826,8 +4663,7 @@ learn_dv_path (const struct GNUNET_PeerIdentity *path,
* @return #GNUNET_YES if message is well-formed
*/
static int
-check_dv_learn (void *cls,
- const struct TransportDVLearn *dvl)
+check_dv_learn (void *cls, const struct TransportDVLearn *dvl)
{
uint16_t size = ntohs (dvl->header.size);
uint16_t num_hops = ntohs (dvl->num_hops);
@@ -4844,16 +4680,14 @@ check_dv_learn (void *cls,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- for (unsigned int i=0;i<num_hops;i++)
+ for (unsigned int i = 0; i < num_hops; i++)
{
- if (0 == GNUNET_memcmp (&dvl->initiator,
- &hops[i].hop))
+ if (0 == GNUNET_memcmp (&dvl->initiator, &hops[i].hop))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (0 == GNUNET_memcmp (&GST_my_identity,
- &hops[i].hop))
+ if (0 == GNUNET_memcmp (&GST_my_identity, &hops[i].hop))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -4871,7 +4705,8 @@ check_dv_learn (void *cls,
* @param bi_history bitmask specifying hops on path that were bidirectional
* @param nhops length of the @a hops array
* @param hops path the message traversed so far
- * @param in_time when did we receive the message, used to calculate network delay
+ * @param in_time when did we receive the message, used to calculate network
+ * delay
*/
static void
forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
@@ -4895,33 +4730,29 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
fwd->num_hops = htons (nhops + 1);
fwd->bidirectional = htons (bi_history);
nnd = GNUNET_TIME_relative_add (GNUNET_TIME_absolute_get_duration (in_time),
- GNUNET_TIME_relative_ntoh (msg->non_network_delay));
+ GNUNET_TIME_relative_ntoh (
+ msg->non_network_delay));
fwd->non_network_delay = GNUNET_TIME_relative_hton (nnd);
fwd->init_sig = msg->init_sig;
fwd->initiator = msg->initiator;
fwd->challenge = msg->challenge;
dhops = (struct DVPathEntryP *) &fwd[1];
- GNUNET_memcpy (dhops,
- hops,
- sizeof (struct DVPathEntryP) * nhops);
+ GNUNET_memcpy (dhops, hops, sizeof (struct DVPathEntryP) * nhops);
dhops[nhops].hop = GST_my_identity;
{
- struct DvHopPS dhp = {
- .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
- .purpose.size = htonl (sizeof (dhp)),
- .pred = dhops[nhops-1].hop,
- .succ = *next_hop,
- .challenge = msg->challenge
- };
+ struct DvHopPS dhp = {.purpose.purpose =
+ htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
+ .purpose.size = htonl (sizeof (dhp)),
+ .pred = dhops[nhops - 1].hop,
+ .succ = *next_hop,
+ .challenge = msg->challenge};
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
&dhp.purpose,
&dhops[nhops].hop_sig));
}
- route_message (next_hop,
- &fwd->header,
- RMO_UNCONFIRMED_ALLOWED);
+ route_message (next_hop, &fwd->header, RMO_UNCONFIRMED_ALLOWED);
}
@@ -4934,21 +4765,22 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
* @return #GNUNET_OK if the signature is valid
*/
static int
-validate_dv_initiator_signature (const struct GNUNET_PeerIdentity *init,
- const struct GNUNET_ShortHashCode *challenge,
- const struct GNUNET_CRYPTO_EddsaSignature *init_sig)
-{
- struct DvInitPS ip = {
- .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
- .purpose.size = htonl (sizeof (ip)),
- .challenge = *challenge
- };
-
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR,
- &ip.purpose,
- init_sig,
- &init->public_key))
+validate_dv_initiator_signature (
+ const struct GNUNET_PeerIdentity *init,
+ const struct GNUNET_ShortHashCode *challenge,
+ const struct GNUNET_CRYPTO_EddsaSignature *init_sig)
+{
+ struct DvInitPS ip = {.purpose.purpose = htonl (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
+ .purpose.size = htonl (sizeof (ip)),
+ .challenge = *challenge};
+
+ if (
+ GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR,
+ &ip.purpose,
+ init_sig,
+ &init->public_key))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -4960,12 +4792,12 @@ validate_dv_initiator_signature (const struct GNUNET_PeerIdentity *init,
/**
* Communicator gave us a DV learn message. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param dvl the message that was received
*/
static void
-handle_dv_learn (void *cls,
- const struct TransportDVLearn *dvl)
+handle_dv_learn (void *cls, const struct TransportDVLearn *dvl)
{
struct CommunicatorMessageContext *cmc = cls;
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
@@ -4983,8 +4815,7 @@ handle_dv_learn (void *cls,
if (0 == nhops)
{
/* sanity check */
- if (0 != GNUNET_memcmp (&dvl->initiator,
- &cmc->im.sender))
+ if (0 != GNUNET_memcmp (&dvl->initiator, &cmc->im.sender))
{
GNUNET_break (0);
finish_cmc_handling (cmc);
@@ -4994,8 +4825,7 @@ handle_dv_learn (void *cls,
else
{
/* sanity check */
- if (0 != GNUNET_memcmp (&hops[nhops - 1].hop,
- &cmc->im.sender))
+ if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender))
{
GNUNET_break (0);
finish_cmc_handling (cmc);
@@ -5005,7 +4835,8 @@ handle_dv_learn (void *cls,
GNUNET_assert (CT_COMMUNICATOR == cmc->tc->type);
cc = cmc->tc->details.communicator.cc;
- bi_hop = (GNUNET_TRANSPORT_CC_RELIABLE == cc); // FIXME: add bi-directional flag to cc?
+ bi_hop = (GNUNET_TRANSPORT_CC_RELIABLE ==
+ cc); // FIXME: add bi-directional flag to cc?
in_time = GNUNET_TIME_absolute_get ();
/* continue communicator here, everything else can happen asynchronous! */
@@ -5013,20 +4844,19 @@ handle_dv_learn (void *cls,
/* OPTIMIZE-FIXME: Technically, we only need to bother checking
the initiator signature if we send the message back to the initiator... */
- if (GNUNET_OK !=
- validate_dv_initiator_signature (&dvl->initiator,
- &dvl->challenge,
- &dvl->init_sig))
+ if (GNUNET_OK != validate_dv_initiator_signature (&dvl->initiator,
+ &dvl->challenge,
+ &dvl->init_sig))
{
GNUNET_break_op (0);
return;
}
// FIXME: asynchronously (!) verify hop-by-hop signatures!
- // => if signature verification load too high, implement random drop strategy!?
+ // => if signature verification load too high, implement random drop
+ // strategy!?
do_fwd = GNUNET_YES;
- if (0 == GNUNET_memcmp (&GST_my_identity,
- &dvl->initiator))
+ if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator))
{
struct GNUNET_PeerIdentity path[nhops + 1];
struct GNUNET_TIME_Relative host_latency_sum;
@@ -5043,27 +4873,22 @@ handle_dv_learn (void *cls,
latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly
// (based on dvl->challenge, we can identify time of origin!)
- network_latency = GNUNET_TIME_relative_subtract (latency,
- host_latency_sum);
+ network_latency = GNUNET_TIME_relative_subtract (latency, host_latency_sum);
/* assumption: latency on all links is the same */
- network_latency = GNUNET_TIME_relative_divide (network_latency,
- nhops);
+ network_latency = GNUNET_TIME_relative_divide (network_latency, nhops);
- for (unsigned int i=2;i<=nhops;i++)
+ for (unsigned int i = 2; i <= nhops; i++)
{
struct GNUNET_TIME_Relative ilat;
/* assumption: linear latency increase per hop */
- ilat = GNUNET_TIME_relative_multiply (network_latency,
- i);
- path[i] = hops[i-1].hop;
+ ilat = GNUNET_TIME_relative_multiply (network_latency, i);
+ path[i] = hops[i - 1].hop;
// FIXME: mark ALL of these as *confirmed* (with what timeout?)
// -- and schedule a job for the confirmation to time out! --
// and possibly do #cores_send_connect_info() if
// the respective neighbour is NOT confirmed yet!
- learn_dv_path (path,
- i,
- ilat);
+ learn_dv_path (path, i, ilat);
}
/* as we initiated, do not forward again (would be circular!) */
do_fwd = GNUNET_NO;
@@ -5076,7 +4901,7 @@ handle_dv_learn (void *cls,
path[0] = GST_my_identity;
path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */
- for (unsigned int i=0;i<nhops;i++)
+ for (unsigned int i = 0; i < nhops; i++)
{
int iret;
@@ -5091,9 +4916,7 @@ handle_dv_learn (void *cls,
path[i + 2] = hops[nhops - i - 2].hop;
}
- iret = learn_dv_path (path,
- i + 2,
- GNUNET_TIME_UNIT_FOREVER_REL);
+ iret = learn_dv_path (path, i + 2, GNUNET_TIME_UNIT_FOREVER_REL);
if (GNUNET_SYSERR == iret)
{
/* path invalid or too long to be interesting for US, thus should also
@@ -5107,8 +4930,7 @@ handle_dv_learn (void *cls,
do_fwd = GNUNET_NO;
break;
}
- if ( (GNUNET_NO == iret) &&
- (nhops == i + 1) )
+ if ((GNUNET_NO == iret) && (nhops == i + 1))
{
/* we have better paths, and this is the longest target,
so there cannot be anything interesting later */
@@ -5132,27 +4954,20 @@ handle_dv_learn (void *cls,
/* Forward to initiator, if path non-trivial and possible */
bi_history = (bi_history << 1) | (bi_hop ? 1 : 0);
did_initiator = GNUNET_NO;
- if ( (1 < nhops) &&
- (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_contains (neighbours,
- &dvl->initiator)) )
+ if ((1 < nhops) &&
+ (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_contains (neighbours, &dvl->initiator)))
{
/* send back to origin! */
- forward_dv_learn (&dvl->initiator,
- dvl,
- bi_history,
- nhops,
- hops,
- in_time);
+ forward_dv_learn (&dvl->initiator, dvl, bi_history, nhops, hops, in_time);
did_initiator = GNUNET_YES;
}
/* We forward under two conditions: either we still learned something
ourselves (do_fwd), or the path was darn short and thus the initiator is
likely to still be very interested in this (and we did NOT already
send it back to the initiator) */
- if ( (do_fwd) ||
- ( (nhops < MIN_DV_PATH_LENGTH_FOR_INITIATOR) &&
- (GNUNET_NO == did_initiator) ) )
+ if ((do_fwd) || ((nhops < MIN_DV_PATH_LENGTH_FOR_INITIATOR) &&
+ (GNUNET_NO == did_initiator)))
{
/* FIXME: loop over all neighbours, pick those with low
queues AND that are not yet on the path; possibly
@@ -5177,38 +4992,39 @@ handle_dv_learn (void *cls,
* @return #GNUNET_YES if message is well-formed
*/
static int
-check_dv_box (void *cls,
- const struct TransportDVBox *dvb)
+check_dv_box (void *cls, const struct TransportDVBox *dvb)
{
uint16_t size = ntohs (dvb->header.size);
uint16_t num_hops = ntohs (dvb->num_hops);
- const struct GNUNET_PeerIdentity *hops = (const struct GNUNET_PeerIdentity *) &dvb[1];
- const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &hops[num_hops];
+ const struct GNUNET_PeerIdentity *hops =
+ (const struct GNUNET_PeerIdentity *) &dvb[1];
+ const struct GNUNET_MessageHeader *inbox =
+ (const struct GNUNET_MessageHeader *) &hops[num_hops];
uint16_t isize;
uint16_t itype;
(void) cls;
- if (size < sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + sizeof (struct GNUNET_MessageHeader))
+ if (size < sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) +
+ sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
isize = ntohs (inbox->size);
- if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize)
+ if (size !=
+ sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
itype = ntohs (inbox->type);
- if ( (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX == itype) ||
- (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN == itype) )
+ if ((GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX == itype) ||
+ (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN == itype))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (0 ==
- GNUNET_memcmp (&dvb->origin,
- &GST_my_identity))
+ if (0 == GNUNET_memcmp (&dvb->origin, &GST_my_identity))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -5241,74 +5057,66 @@ forward_dv_box (struct Neighbour *next_hop,
struct TransportDVBox *dvb;
struct GNUNET_PeerIdentity *dhops;
- GNUNET_assert (UINT16_MAX <
- sizeof (struct TransportDVBox) +
- sizeof (struct GNUNET_PeerIdentity) * num_hops +
- payload_size);
+ GNUNET_assert (UINT16_MAX < sizeof (struct TransportDVBox) +
+ sizeof (struct GNUNET_PeerIdentity) * num_hops +
+ payload_size);
dvb = GNUNET_malloc (sizeof (struct TransportDVBox) +
sizeof (struct GNUNET_PeerIdentity) * num_hops +
payload_size);
- dvb->header.size = htons (sizeof (struct TransportDVBox) +
- sizeof (struct GNUNET_PeerIdentity) * num_hops +
- payload_size);
+ dvb->header.size =
+ htons (sizeof (struct TransportDVBox) +
+ sizeof (struct GNUNET_PeerIdentity) * num_hops + payload_size);
dvb->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX);
dvb->total_hops = htons (total_hops);
dvb->num_hops = htons (num_hops);
dvb->origin = *origin;
dhops = (struct GNUNET_PeerIdentity *) &dvb[1];
- memcpy (dhops,
- hops,
- num_hops * sizeof (struct GNUNET_PeerIdentity));
- memcpy (&dhops[num_hops],
- payload,
- payload_size);
- route_message (&next_hop->pid,
- &dvb->header,
- RMO_NONE);
+ memcpy (dhops, hops, num_hops * sizeof (struct GNUNET_PeerIdentity));
+ memcpy (&dhops[num_hops], payload, payload_size);
+ route_message (&next_hop->pid, &dvb->header, RMO_NONE);
}
/**
* Communicator gave us a DV box. Process the request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param dvb the message that was received
*/
static void
-handle_dv_box (void *cls,
- const struct TransportDVBox *dvb)
+handle_dv_box (void *cls, const struct TransportDVBox *dvb)
{
struct CommunicatorMessageContext *cmc = cls;
uint16_t size = ntohs (dvb->header.size) - sizeof (*dvb);
uint16_t num_hops = ntohs (dvb->num_hops);
- const struct GNUNET_PeerIdentity *hops = (const struct GNUNET_PeerIdentity *) &dvb[1];
- const struct GNUNET_MessageHeader *inbox = (const struct GNUNET_MessageHeader *) &hops[num_hops];
+ const struct GNUNET_PeerIdentity *hops =
+ (const struct GNUNET_PeerIdentity *) &dvb[1];
+ const struct GNUNET_MessageHeader *inbox =
+ (const struct GNUNET_MessageHeader *) &hops[num_hops];
if (num_hops > 0)
{
/* We're trying from the end of the hops array, as we may be
able to find a shortcut unknown to the origin that way */
- for (int i=num_hops-1;i>=0;i--)
+ for (int i = num_hops - 1; i >= 0; i--)
{
struct Neighbour *n;
- if (0 ==
- GNUNET_memcmp (&hops[i],
- &GST_my_identity))
+ if (0 == GNUNET_memcmp (&hops[i], &GST_my_identity))
{
GNUNET_break_op (0);
finish_cmc_handling (cmc);
return;
}
- n = GNUNET_CONTAINER_multipeermap_get (neighbours,
- &hops[i]);
+ n = GNUNET_CONTAINER_multipeermap_get (neighbours, &hops[i]);
if (NULL == n)
continue;
forward_dv_box (n,
ntohs (dvb->total_hops) + 1,
num_hops - i - 1, /* number of hops left */
&dvb->origin,
- &hops[i+1], /* remaining hops */
+ &hops[i + 1], /* remaining hops */
(const void *) &dvb[1],
size);
finish_cmc_handling (cmc);
@@ -5325,8 +5133,7 @@ handle_dv_box (void *cls,
/* We are the target. Unbox and handle message. */
cmc->im.sender = dvb->origin;
cmc->total_hops = ntohs (dvb->total_hops);
- demultiplex_with_cmc (cmc,
- inbox);
+ demultiplex_with_cmc (cmc, inbox);
}
@@ -5354,9 +5161,11 @@ check_incoming_msg (void *cls,
/**
- * Communicator gave us a transport address validation challenge. Process the request.
+ * Communicator gave us a transport address validation challenge. Process the
+ * request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param tvc the message that was received
*/
static void
@@ -5374,24 +5183,23 @@ handle_validation_challenge (void *cls,
return;
}
tvr = GNUNET_new (struct TransportValidationResponse);
- tvr->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE);
+ tvr->header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE);
tvr->header.size = htons (sizeof (*tvr));
tvr->challenge = tvc->challenge;
tvr->origin_time = tvc->sender_time;
tvr->validity_duration = cmc->im.expected_address_validity;
{
/* create signature */
- struct TransportValidationPS tvp = {
- .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
- .purpose.size = htonl (sizeof (tvp)),
- .validity_duration = tvr->validity_duration,
- .challenge = tvc->challenge
- };
+ struct TransportValidationPS tvp =
+ {.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
+ .purpose.size = htonl (sizeof (tvp)),
+ .validity_duration = tvr->validity_duration,
+ .challenge = tvc->challenge};
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
- &tvp.purpose,
- &tvr->signature));
+ GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &tvp.purpose,
+ &tvr->signature));
}
route_message (&cmc->im.sender,
&tvr->header,
@@ -5435,8 +5243,7 @@ check_known_challenge (void *cls,
struct ValidationState *vs = value;
(void) pid;
- if (0 != GNUNET_memcmp (&vs->challenge,
- ckac->challenge))
+ if (0 != GNUNET_memcmp (&vs->challenge, ckac->challenge))
return GNUNET_OK;
ckac->vs = vs;
return GNUNET_NO;
@@ -5451,8 +5258,7 @@ check_known_challenge (void *cls,
* @param success #GNUNET_YES on success
*/
static void
-peerstore_store_validation_cb (void *cls,
- int success)
+peerstore_store_validation_cb (void *cls, int success)
{
struct ValidationState *vs = cls;
@@ -5492,25 +5298,22 @@ update_next_challenge_time (struct ValidationState *vs,
return; /* be lazy */
vs->next_challenge = new_time;
if (NULL == vs->hn)
- vs->hn = GNUNET_CONTAINER_heap_insert (validation_heap,
- vs,
- new_time.abs_value_us);
+ vs->hn =
+ GNUNET_CONTAINER_heap_insert (validation_heap, vs, new_time.abs_value_us);
else
- GNUNET_CONTAINER_heap_update_cost (vs->hn,
- new_time.abs_value_us);
- if ( (vs != GNUNET_CONTAINER_heap_peek (validation_heap)) &&
- (NULL != validation_task) )
+ GNUNET_CONTAINER_heap_update_cost (vs->hn, new_time.abs_value_us);
+ if ((vs != GNUNET_CONTAINER_heap_peek (validation_heap)) &&
+ (NULL != validation_task))
return;
if (NULL != validation_task)
GNUNET_SCHEDULER_cancel (validation_task);
/* randomize a bit */
- delta.rel_value_us = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
- MIN_DELAY_ADDRESS_VALIDATION.rel_value_us);
- new_time = GNUNET_TIME_absolute_add (new_time,
- delta);
- validation_task = GNUNET_SCHEDULER_add_at (new_time,
- &validation_start_cb,
- NULL);
+ delta.rel_value_us =
+ GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+ MIN_DELAY_ADDRESS_VALIDATION.rel_value_us);
+ new_time = GNUNET_TIME_absolute_add (new_time, delta);
+ validation_task =
+ GNUNET_SCHEDULER_add_at (new_time, &validation_start_cb, NULL);
}
@@ -5522,21 +5325,17 @@ update_next_challenge_time (struct ValidationState *vs,
* @return NULL if no such queue exists
*/
static struct Queue *
-find_queue (const struct GNUNET_PeerIdentity *pid,
- const char *address)
+find_queue (const struct GNUNET_PeerIdentity *pid, const char *address)
{
struct Neighbour *n;
- n = GNUNET_CONTAINER_multipeermap_get (neighbours,
- pid);
+ n = GNUNET_CONTAINER_multipeermap_get (neighbours, pid);
if (NULL == n)
return NULL;
- for (struct Queue *pos = n->queue_head;
- NULL != pos;
+ for (struct Queue *pos = n->queue_head; NULL != pos;
pos = pos->next_neighbour)
{
- if (0 == strcmp (pos->address,
- address))
+ if (0 == strcmp (pos->address, address))
return pos;
}
return NULL;
@@ -5559,10 +5358,9 @@ core_queue_visibility_check (void *cls)
q->visibility_task = NULL;
if (0 != GNUNET_TIME_absolute_get_remaining (q->validated_until).rel_value_us)
{
- q->visibility_task
- = GNUNET_SCHEDULER_add_at (q->validated_until,
- &core_queue_visibility_check,
- q);
+ q->visibility_task = GNUNET_SCHEDULER_add_at (q->validated_until,
+ &core_queue_visibility_check,
+ q);
return;
}
update_neighbour_core_visibility (q->neighbour);
@@ -5586,17 +5384,16 @@ update_neighbour_core_visibility (struct Neighbour *n)
GNUNET_assert (GNUNET_YES == n->core_visible);
/* Check if _any_ queue of this neighbour is still valid, if so, schedule
the #core_queue_visibility_check() task for that queue */
- for (struct Queue *q = n->queue_head;
- NULL != q;
- q = q->next_neighbour)
+ for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
{
- if (0 != GNUNET_TIME_absolute_get_remaining (q->validated_until).rel_value_us)
+ if (0 !=
+ GNUNET_TIME_absolute_get_remaining (q->validated_until).rel_value_us)
{
/* found a valid queue, use this one */
- q->visibility_task
- = GNUNET_SCHEDULER_add_at (q->validated_until,
- &core_queue_visibility_check,
- q);
+ q->visibility_task =
+ GNUNET_SCHEDULER_add_at (q->validated_until,
+ &core_queue_visibility_check,
+ q);
return;
}
}
@@ -5605,8 +5402,7 @@ update_neighbour_core_visibility (struct Neighbour *n)
/* Check if _any_ DV route to this neighbour is currently
valid, if so, do NOT tell core about the loss of direct
connectivity (DV still counts!) */
- dv = GNUNET_CONTAINER_multipeermap_get (dv_routes,
- &n->pid);
+ dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &n->pid);
if (GNUNET_YES == dv->core_visible)
return;
/* Nothing works anymore, need to tell CORE about the loss of
@@ -5616,9 +5412,11 @@ update_neighbour_core_visibility (struct Neighbour *n)
/**
- * Communicator gave us a transport address validation response. Process the request.
+ * Communicator gave us a transport address validation response. Process the
+ * request.
*
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
+ * @param cls a `struct CommunicatorMessageContext` (must call
+ * #finish_cmc_handling() when done)
* @param tvr the message that was received
*/
static void
@@ -5627,10 +5425,8 @@ handle_validation_response (void *cls,
{
struct CommunicatorMessageContext *cmc = cls;
struct ValidationState *vs;
- struct CheckKnownChallengeContext ckac = {
- .challenge = &tvr->challenge,
- .vs = NULL
- };
+ struct CheckKnownChallengeContext ckac = {.challenge = &tvr->challenge,
+ .vs = NULL};
struct GNUNET_TIME_Absolute origin_time;
struct Queue *q;
struct DistanceVector *dv;
@@ -5654,8 +5450,8 @@ handle_validation_response (void *cls,
/* sanity check on origin time */
origin_time = GNUNET_TIME_absolute_ntoh (tvr->origin_time);
- if ( (origin_time.abs_value_us < vs->first_challenge_use.abs_value_us) ||
- (origin_time.abs_value_us > vs->last_challenge_use.abs_value_us) )
+ if ((origin_time.abs_value_us < vs->first_challenge_use.abs_value_us) ||
+ (origin_time.abs_value_us > vs->last_challenge_use.abs_value_us))
{
GNUNET_break_op (0);
finish_cmc_handling (cmc);
@@ -5664,18 +5460,18 @@ handle_validation_response (void *cls,
{
/* check signature */
- struct TransportValidationPS tvp = {
- .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
- .purpose.size = htonl (sizeof (tvp)),
- .validity_duration = tvr->validity_duration,
- .challenge = tvr->challenge
- };
-
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE,
- &tvp.purpose,
- &tvr->signature,
- &cmc->im.sender.public_key))
+ struct TransportValidationPS tvp =
+ {.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
+ .purpose.size = htonl (sizeof (tvp)),
+ .validity_duration = tvr->validity_duration,
+ .challenge = tvr->challenge};
+
+ if (
+ GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE,
+ &tvp.purpose,
+ &tvr->signature,
+ &cmc->im.sender.public_key))
{
GNUNET_break_op (0);
finish_cmc_handling (cmc);
@@ -5685,23 +5481,26 @@ handle_validation_response (void *cls,
/* validity is capped by our willingness to keep track of the
validation entry and the maximum the other peer allows */
- vs->valid_until
- = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_min (GNUNET_TIME_relative_ntoh (tvr->validity_duration),
- MAX_ADDRESS_VALID_UNTIL));
- vs->validated_until
- = GNUNET_TIME_absolute_min (vs->valid_until,
- GNUNET_TIME_relative_to_absolute (ADDRESS_VALIDATION_LIFETIME));
+ vs->valid_until = GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_relative_min (GNUNET_TIME_relative_ntoh (
+ tvr->validity_duration),
+ MAX_ADDRESS_VALID_UNTIL));
+ vs->validated_until =
+ GNUNET_TIME_absolute_min (vs->valid_until,
+ GNUNET_TIME_relative_to_absolute (
+ ADDRESS_VALIDATION_LIFETIME));
vs->validation_rtt = GNUNET_TIME_absolute_get_duration (origin_time);
vs->challenge_backoff = GNUNET_TIME_UNIT_ZERO;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&vs->challenge,
sizeof (vs->challenge));
- vs->first_challenge_use = GNUNET_TIME_absolute_subtract (vs->validated_until,
- GNUNET_TIME_relative_multiply (vs->validation_rtt,
- VALIDATION_RTT_BUFFER_FACTOR));
- vs->last_challenge_use = GNUNET_TIME_UNIT_ZERO_ABS; /* challenge was not yet used */
- update_next_challenge_time (vs,
- vs->first_challenge_use);
+ vs->first_challenge_use = GNUNET_TIME_absolute_subtract (
+ vs->validated_until,
+ GNUNET_TIME_relative_multiply (vs->validation_rtt,
+ VALIDATION_RTT_BUFFER_FACTOR));
+ vs->last_challenge_use =
+ GNUNET_TIME_UNIT_ZERO_ABS; /* challenge was not yet used */
+ update_next_challenge_time (vs, vs->first_challenge_use);
vs->sc = GNUNET_PEERSTORE_store (peerstore,
"transport",
&cmc->im.sender,
@@ -5716,8 +5515,7 @@ handle_validation_response (void *cls,
/* Finally, we now possibly have a confirmed (!) working queue,
update queue status (if queue still is around) */
- q = find_queue (&vs->pid,
- vs->address);
+ q = find_queue (&vs->pid, vs->address);
if (NULL == q)
{
GNUNET_STATISTICS_update (GST_stats,
@@ -5731,20 +5529,17 @@ handle_validation_response (void *cls,
if (GNUNET_NO != q->neighbour->core_visible)
return; /* nothing changed, we are done here */
q->neighbour->core_visible = GNUNET_YES;
- q->visibility_task
- = GNUNET_SCHEDULER_add_at (q->validated_until,
- &core_queue_visibility_check,
- q);
+ q->visibility_task = GNUNET_SCHEDULER_add_at (q->validated_until,
+ &core_queue_visibility_check,
+ q);
/* Check if _any_ DV route to this neighbour is
currently valid, if so, do NOT tell core anything! */
- dv = GNUNET_CONTAINER_multipeermap_get (dv_routes,
- &q->neighbour->pid);
+ dv = GNUNET_CONTAINER_multipeermap_get (dv_routes, &q->neighbour->pid);
if (GNUNET_YES == dv->core_visible)
return; /* nothing changed, done */
/* We lacked a confirmed connection to the neighbour
before, so tell CORE about it (finally!) */
- cores_send_connect_info (&q->neighbour->pid,
- GNUNET_BANDWIDTH_ZERO);
+ cores_send_connect_info (&q->neighbour->pid, GNUNET_BANDWIDTH_ZERO);
}
@@ -5758,12 +5553,12 @@ handle_incoming_msg (void *cls,
const struct GNUNET_TRANSPORT_IncomingMessage *im)
{
struct TransportClient *tc = cls;
- struct CommunicatorMessageContext *cmc = GNUNET_new (struct CommunicatorMessageContext);
+ struct CommunicatorMessageContext *cmc =
+ GNUNET_new (struct CommunicatorMessageContext);
cmc->tc = tc;
cmc->im = *im;
- demultiplex_with_cmc (cmc,
- (const struct GNUNET_MessageHeader *) &im[1]);
+ demultiplex_with_cmc (cmc, (const struct GNUNET_MessageHeader *) &im[1]);
}
@@ -5778,49 +5573,49 @@ static void
demultiplex_with_cmc (struct CommunicatorMessageContext *cmc,
const struct GNUNET_MessageHeader *msg)
{
- struct GNUNET_MQ_MessageHandler handlers[] = {
- GNUNET_MQ_hd_var_size (fragment_box,
- GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT,
- struct TransportFragmentBox,
- &cmc),
- GNUNET_MQ_hd_fixed_size (fragment_ack,
- GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK,
- struct TransportFragmentAckMessage,
- &cmc),
- GNUNET_MQ_hd_var_size (reliability_box,
- GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX,
- struct TransportReliabilityBox,
- &cmc),
- GNUNET_MQ_hd_fixed_size (reliability_ack,
- GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK,
- struct TransportReliabilityAckMessage,
- &cmc),
- GNUNET_MQ_hd_var_size (backchannel_encapsulation,
- GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION,
- struct TransportBackchannelEncapsulationMessage,
- &cmc),
- GNUNET_MQ_hd_var_size (dv_learn,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN,
- struct TransportDVLearn,
- &cmc),
- GNUNET_MQ_hd_var_size (dv_box,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX,
- struct TransportDVBox,
- &cmc),
- GNUNET_MQ_hd_fixed_size (validation_challenge,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE,
- struct TransportValidationChallenge,
- &cmc),
- GNUNET_MQ_hd_fixed_size (validation_response,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE,
- struct TransportValidationResponse,
- &cmc),
- GNUNET_MQ_handler_end()
- };
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_var_size (fragment_box,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT,
+ struct TransportFragmentBox,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (fragment_ack,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK,
+ struct TransportFragmentAckMessage,
+ &cmc),
+ GNUNET_MQ_hd_var_size (reliability_box,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX,
+ struct TransportReliabilityBox,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (reliability_ack,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK,
+ struct TransportReliabilityAckMessage,
+ &cmc),
+ GNUNET_MQ_hd_var_size (backchannel_encapsulation,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION,
+ struct TransportBackchannelEncapsulationMessage,
+ &cmc),
+ GNUNET_MQ_hd_var_size (dv_learn,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN,
+ struct TransportDVLearn,
+ &cmc),
+ GNUNET_MQ_hd_var_size (dv_box,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX,
+ struct TransportDVBox,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (
+ validation_challenge,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE,
+ struct TransportValidationChallenge,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (
+ validation_response,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE,
+ struct TransportValidationResponse,
+ &cmc),
+ GNUNET_MQ_handler_end ()};
int ret;
- ret = GNUNET_MQ_handle_message (handlers,
- msg);
+ ret = GNUNET_MQ_handle_message (handlers, msg);
if (GNUNET_SYSERR == ret)
{
GNUNET_break (0);
@@ -5831,8 +5626,7 @@ demultiplex_with_cmc (struct CommunicatorMessageContext *cmc,
if (GNUNET_NO == ret)
{
/* unencapsulated 'raw' message */
- handle_raw_message (&cmc,
- msg);
+ handle_raw_message (&cmc, msg);
}
}
@@ -5873,8 +5667,7 @@ tracker_update_in_cb (void *cls)
unsigned int rsize;
rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu;
- in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in,
- rsize);
+ in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, rsize);
// FIXME: how exactly do we do inbound flow control?
}
@@ -5907,8 +5700,7 @@ set_pending_message_uuid (struct PendingMessage *pm)
* @return new message to transmit
*/
static struct PendingMessage *
-fragment_message (struct PendingMessage *pm,
- uint16_t mtu)
+fragment_message (struct PendingMessage *pm, uint16_t mtu)
{
struct PendingMessage *ff;
@@ -5918,19 +5710,16 @@ fragment_message (struct PendingMessage *pm,
GNUNET_assert (mtu > sizeof (struct TransportFragmentBox));
/* select fragment for transmission, descending the tree if it has
- been expanded until we are at a leaf or at a fragment that is small enough */
+ been expanded until we are at a leaf or at a fragment that is small enough
+ */
ff = pm;
- while ( ( (ff->bytes_msg > mtu) ||
- (pm == ff) ) &&
- (ff->frag_off == ff->bytes_msg) &&
- (NULL != ff->head_frag) )
+ while (((ff->bytes_msg > mtu) || (pm == ff)) &&
+ (ff->frag_off == ff->bytes_msg) && (NULL != ff->head_frag))
{
ff = ff->head_frag; /* descent into fragmented fragments */
}
- if ( ( (ff->bytes_msg > mtu) ||
- (pm == ff) ) &&
- (pm->frag_off < pm->bytes_msg) )
+ if (((ff->bytes_msg > mtu) || (pm == ff)) && (pm->frag_off < pm->bytes_msg))
{
/* Did not yet calculate all fragments, calculate next fragment */
struct PendingMessage *frag;
@@ -5954,11 +5743,9 @@ fragment_message (struct PendingMessage *pm,
xoff = ntohs (tfbo->frag_off);
}
fragmax = mtu - sizeof (struct TransportFragmentBox);
- fragsize = GNUNET_MIN (msize - ff->frag_off,
- fragmax);
+ fragsize = GNUNET_MIN (msize - ff->frag_off, fragmax);
frag = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct TransportFragmentBox) +
- fragsize);
+ sizeof (struct TransportFragmentBox) + fragsize);
frag->target = pm->target;
frag->frag_parent = ff;
frag->timeout = pm->timeout;
@@ -5966,35 +5753,27 @@ fragment_message (struct PendingMessage *pm,
frag->pmt = PMT_FRAGMENT_BOX;
msg = (char *) &frag[1];
tfb.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT);
- tfb.header.size = htons (sizeof (struct TransportFragmentBox) +
- fragsize);
+ tfb.header.size = htons (sizeof (struct TransportFragmentBox) + fragsize);
tfb.frag_uuid = htonl (pm->frag_uuidgen++);
tfb.msg_uuid = pm->msg_uuid;
tfb.frag_off = htons (ff->frag_off + xoff);
tfb.msg_size = htons (pm->bytes_msg);
- memcpy (msg,
- &tfb,
- sizeof (tfb));
- memcpy (&msg[sizeof (tfb)],
- &orig[ff->frag_off],
- fragsize);
- GNUNET_CONTAINER_MDLL_insert (frag,
- ff->head_frag,
- ff->tail_frag,
- frag);
+ memcpy (msg, &tfb, sizeof (tfb));
+ memcpy (&msg[sizeof (tfb)], &orig[ff->frag_off], fragsize);
+ GNUNET_CONTAINER_MDLL_insert (frag, ff->head_frag, ff->tail_frag, frag);
ff->frag_off += fragsize;
ff = frag;
}
/* Move head to the tail and return it */
GNUNET_CONTAINER_MDLL_remove (frag,
- ff->frag_parent->head_frag,
- ff->frag_parent->tail_frag,
- ff);
+ ff->frag_parent->head_frag,
+ ff->frag_parent->tail_frag,
+ ff);
GNUNET_CONTAINER_MDLL_insert_tail (frag,
- ff->frag_parent->head_frag,
- ff->frag_parent->tail_frag,
- ff);
+ ff->frag_parent->head_frag,
+ ff->frag_parent->tail_frag,
+ ff);
return ff;
}
@@ -6017,7 +5796,8 @@ reliability_box_message (struct PendingMessage *pm)
char *msg;
if (PMT_CORE != pm->pmt)
- return pm; /* already fragmented or reliability boxed, or control message: do nothing */
+ return pm; /* already fragmented or reliability boxed, or control message:
+ do nothing */
if (NULL != pm->bpm)
return pm->bpm; /* already computed earlier: do nothing */
GNUNET_assert (NULL == pm->head_frag);
@@ -6025,20 +5805,14 @@ reliability_box_message (struct PendingMessage *pm)
{
/* failed hard */
GNUNET_break (0);
- client_send_response (pm,
- GNUNET_NO,
- 0);
+ client_send_response (pm, GNUNET_NO, 0);
return NULL;
}
- bpm = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (rbox) +
+ bpm = GNUNET_malloc (sizeof (struct PendingMessage) + sizeof (rbox) +
pm->bytes_msg);
bpm->target = pm->target;
bpm->frag_parent = pm;
- GNUNET_CONTAINER_MDLL_insert (frag,
- pm->head_frag,
- pm->tail_frag,
- bpm);
+ GNUNET_CONTAINER_MDLL_insert (frag, pm->head_frag, pm->tail_frag, bpm);
bpm->timeout = pm->timeout;
bpm->pmt = PMT_RELIABILITY_BOX;
bpm->bytes_msg = pm->bytes_msg + sizeof (rbox);
@@ -6048,12 +5822,8 @@ reliability_box_message (struct PendingMessage *pm)
rbox.ack_countdown = htonl (0); // FIXME: implement ACK countdown support
rbox.msg_uuid = pm->msg_uuid;
msg = (char *) &bpm[1];
- memcpy (msg,
- &rbox,
- sizeof (rbox));
- memcpy (&msg[sizeof (rbox)],
- &pm[1],
- pm->bytes_msg);
+ memcpy (msg, &rbox, sizeof (rbox));
+ memcpy (&msg[sizeof (rbox)], &pm[1], pm->bytes_msg);
pm->bpm = bpm;
return bpm;
}
@@ -6097,8 +5867,9 @@ transmit_on_queue (void *cls)
this queue */) )
s = fragment_message (s,
(0 == queue->mtu)
- ? UINT16_MAX - sizeof (struct GNUNET_TRANSPORT_SendMessageTo)
- : queue->mtu);
+ ? UINT16_MAX -
+ sizeof (struct GNUNET_TRANSPORT_SendMessageTo)
+ : queue->mtu);
if (NULL == s)
{
/* Fragmentation failed, try next message... */
@@ -6115,56 +5886,45 @@ transmit_on_queue (void *cls)
}
/* Pass 's' for transission to the communicator */
- queue_send_msg (queue,
- s,
- &s[1],
- s->bytes_msg);
+ queue_send_msg (queue, s, &s[1], s->bytes_msg);
// FIXME: do something similar to the logic below
// in defragmentation / reliability ACK handling!
/* Check if this transmission somehow conclusively finished handing 'pm'
even without any explicit ACKs */
- if ( (PMT_CORE == s->pmt) &&
- (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) )
+ if ((PMT_CORE == s->pmt) &&
+ (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc))
{
/* Full message sent, and over reliabile channel */
- client_send_response (pm,
- GNUNET_YES,
- pm->bytes_msg);
+ client_send_response (pm, GNUNET_YES, pm->bytes_msg);
}
- else if ( (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc) &&
- (PMT_FRAGMENT_BOX == s->pmt) )
+ else if ((GNUNET_TRANSPORT_CC_RELIABLE ==
+ queue->tc->details.communicator.cc) &&
+ (PMT_FRAGMENT_BOX == s->pmt))
{
struct PendingMessage *pos;
/* Fragment sent over reliabile channel */
free_fragment_tree (s);
pos = s->frag_parent;
- GNUNET_CONTAINER_MDLL_remove (frag,
- pos->head_frag,
- pos->tail_frag,
- s);
+ GNUNET_CONTAINER_MDLL_remove (frag, pos->head_frag, pos->tail_frag, s);
GNUNET_free (s);
/* check if subtree is done */
- while ( (NULL == pos->head_frag) &&
- (pos->frag_off == pos->bytes_msg) &&
- (pos != pm) )
+ while ((NULL == pos->head_frag) && (pos->frag_off == pos->bytes_msg) &&
+ (pos != pm))
{
s = pos;
pos = s->frag_parent;
- GNUNET_CONTAINER_MDLL_remove (frag,
- pos->head_frag,
- pos->tail_frag,
- s);
+ GNUNET_CONTAINER_MDLL_remove (frag, pos->head_frag, pos->tail_frag, s);
GNUNET_free (s);
}
/* Was this the last applicable fragmment? */
- if ( (NULL == pm->head_frag) &&
- (pm->frag_off == pm->bytes_msg) )
- client_send_response (pm,
- GNUNET_YES,
- pm->bytes_msg /* FIXME: calculate and add overheads! */);
+ if ((NULL == pm->head_frag) && (pm->frag_off == pm->bytes_msg))
+ client_send_response (
+ pm,
+ GNUNET_YES,
+ pm->bytes_msg /* FIXME: calculate and add overheads! */);
}
else if (PMT_CORE != pm->pmt)
{
@@ -6182,9 +5942,8 @@ transmit_on_queue (void *cls)
retransmitting. Note that in the future this heuristic should
likely be improved further (measure RTT stability, consider
message urgency and size when delaying ACKs, etc.) */
- s->next_attempt = GNUNET_TIME_relative_to_absolute
- (GNUNET_TIME_relative_multiply (queue->rtt,
- 4));
+ s->next_attempt = GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_relative_multiply (queue->rtt, 4));
if (s == pm)
{
struct PendingMessage *pos;
@@ -6195,8 +5954,8 @@ transmit_on_queue (void *cls)
neighbour->pending_msg_tail,
pm);
pos = neighbour->pending_msg_tail;
- while ( (NULL != pos) &&
- (pm->next_attempt.abs_value_us > pos->next_attempt.abs_value_us) )
+ while ((NULL != pos) &&
+ (pm->next_attempt.abs_value_us > pos->next_attempt.abs_value_us))
pos = pos->prev_neighbour;
GNUNET_CONTAINER_MDLL_insert_after (neighbour,
neighbour->pending_msg_head,
@@ -6210,13 +5969,10 @@ transmit_on_queue (void *cls)
struct PendingMessage *fp = s->frag_parent;
struct PendingMessage *pos;
- GNUNET_CONTAINER_MDLL_remove (frag,
- fp->head_frag,
- fp->tail_frag,
- s);
+ GNUNET_CONTAINER_MDLL_remove (frag, fp->head_frag, fp->tail_frag, s);
pos = fp->tail_frag;
- while ( (NULL != pos) &&
- (s->next_attempt.abs_value_us > pos->next_attempt.abs_value_us) )
+ while ((NULL != pos) &&
+ (s->next_attempt.abs_value_us > pos->next_attempt.abs_value_us))
pos = pos->prev_frag;
GNUNET_CONTAINER_MDLL_insert_after (frag,
fp->head_frag,
@@ -6246,8 +6002,8 @@ tracker_update_out_cb (void *cls)
if (NULL == n->pending_msg_head)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Bandwidth allocation updated for empty transmission queue `%s'\n",
- queue->address);
+ "Bandwidth allocation updated for empty transmission queue `%s'\n",
+ queue->address);
return; /* no message pending, nothing to do here! */
}
GNUNET_SCHEDULER_cancel (queue->transmit_task);
@@ -6279,7 +6035,6 @@ tracker_excess_out_cb (void *cls)
}
-
/**
* Bandwidth tracker informs us that excessive inbound bandwidth was allocated
* which is not being used.
@@ -6317,15 +6072,13 @@ handle_del_queue_message (void *cls,
GNUNET_SERVICE_client_drop (tc->client);
return;
}
- for (struct Queue *queue = tc->details.communicator.queue_head;
- NULL != queue;
+ for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue;
queue = queue->next_client)
{
struct Neighbour *neighbour = queue->neighbour;
- if ( (dqm->qid != queue->qid) ||
- (0 != GNUNET_memcmp (&dqm->receiver,
- &neighbour->pid)) )
+ if ((dqm->qid != queue->qid) ||
+ (0 != GNUNET_memcmp (&dqm->receiver, &neighbour->pid)))
continue;
free_queue (queue);
GNUNET_SERVICE_client_continue (tc->client);
@@ -6358,15 +6111,12 @@ handle_send_message_ack (void *cls,
/* find our queue entry matching the ACK */
qe = NULL;
- for (struct Queue *queue = tc->details.communicator.queue_head;
- NULL != queue;
+ for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue;
queue = queue->next_client)
{
- if (0 != GNUNET_memcmp (&queue->neighbour->pid,
- &sma->receiver))
+ if (0 != GNUNET_memcmp (&queue->neighbour->pid, &sma->receiver))
continue;
- for (struct QueueEntry *qep = queue->queue_head;
- NULL != qep;
+ for (struct QueueEntry *qep = queue->queue_head; NULL != qep;
qep = qep->next)
{
if (qep->mid != sma->mid)
@@ -6391,13 +6141,15 @@ handle_send_message_ack (void *cls,
GNUNET_SERVICE_client_continue (tc->client);
/* if applicable, resume transmissions that waited on ACK */
- if (COMMUNICATOR_TOTAL_QUEUE_LIMIT - 1 == tc->details.communicator.total_queue_length)
+ if (COMMUNICATOR_TOTAL_QUEUE_LIMIT - 1 ==
+ tc->details.communicator.total_queue_length)
{
/* Communicator dropped below threshold, resume all queues */
- GNUNET_STATISTICS_update (GST_stats,
- "# Transmission throttled due to communicator queue limit",
- -1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ GST_stats,
+ "# Transmission throttled due to communicator queue limit",
+ -1,
+ GNUNET_NO);
for (struct Queue *queue = tc->details.communicator.queue_head;
NULL != queue;
queue = queue->next_client)
@@ -6440,22 +6192,15 @@ notify_client_queues (void *cls,
struct Neighbour *neighbour = value;
GNUNET_assert (CT_MONITOR == tc->type);
- for (struct Queue *q = neighbour->queue_head;
- NULL != q;
+ for (struct Queue *q = neighbour->queue_head; NULL != q;
q = q->next_neighbour)
{
- struct MonitorEvent me = {
- .rtt = q->rtt,
- .cs = q->cs,
- .num_msg_pending = q->num_msg_pending,
- .num_bytes_pending = q->num_bytes_pending
- };
+ struct MonitorEvent me = {.rtt = q->rtt,
+ .cs = q->cs,
+ .num_msg_pending = q->num_msg_pending,
+ .num_bytes_pending = q->num_bytes_pending};
- notify_monitor (tc,
- pid,
- q->address,
- q->nt,
- &me);
+ notify_monitor (tc, pid, q->address, q->nt, &me);
}
return GNUNET_OK;
}
@@ -6482,9 +6227,7 @@ handle_monitor_start (void *cls,
tc->type = CT_MONITOR;
tc->details.monitor.peer = start->peer;
tc->details.monitor.one_shot = ntohl (start->one_shot);
- GNUNET_CONTAINER_multipeermap_iterate (neighbours,
- &notify_client_queues,
- tc);
+ GNUNET_CONTAINER_multipeermap_iterate (neighbours, &notify_client_queues, tc);
GNUNET_SERVICE_client_mark_monitor (tc->client);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -6500,19 +6243,17 @@ handle_monitor_start (void *cls,
static struct TransportClient *
lookup_communicator (const char *prefix)
{
- for (struct TransportClient *tc = clients_head;
- NULL != tc;
- tc = tc->next)
+ for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next)
{
if (CT_COMMUNICATOR != tc->type)
continue;
- if (0 == strcmp (prefix,
- tc->details.communicator.address_prefix))
+ if (0 == strcmp (prefix, tc->details.communicator.address_prefix))
return tc;
}
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Somone suggested use of communicator for `%s', but we do not have such a communicator!\n",
- prefix);
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_WARNING,
+ "Somone suggested use of communicator for `%s', but we do not have such a communicator!\n",
+ prefix);
return NULL;
}
@@ -6525,8 +6266,7 @@ lookup_communicator (const char *prefix)
* @param address the address to try
*/
static void
-suggest_to_connect (const struct GNUNET_PeerIdentity *pid,
- const char *address)
+suggest_to_connect (const struct GNUNET_PeerIdentity *pid, const char *address)
{
static uint32_t idgen;
struct TransportClient *tc;
@@ -6557,16 +6297,12 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid,
prefix,
address);
alen = strlen (address) + 1;
- env = GNUNET_MQ_msg_extra (cqm,
- alen,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
+ env =
+ GNUNET_MQ_msg_extra (cqm, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
cqm->request_id = htonl (idgen++);
cqm->receiver = *pid;
- memcpy (&cqm[1],
- address,
- alen);
- GNUNET_MQ_send (tc->mq,
- env);
+ memcpy (&cqm[1], address, alen);
+ GNUNET_MQ_send (tc->mq, env);
}
@@ -6578,21 +6314,18 @@ suggest_to_connect (const struct GNUNET_PeerIdentity *pid,
* @param vs state to derive validation challenge from
*/
static void
-validation_transmit_on_queue (struct Queue *q,
- struct ValidationState *vs)
+validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs)
{
struct TransportValidationChallenge tvc;
vs->last_challenge_use = GNUNET_TIME_absolute_get ();
- tvc.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
+ tvc.header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
tvc.header.size = htons (sizeof (tvc));
tvc.reserved = htonl (0);
tvc.challenge = vs->challenge;
tvc.sender_time = GNUNET_TIME_absolute_hton (vs->last_challenge_use);
- queue_send_msg (q,
- NULL,
- &tvc,
- sizeof (tvc));
+ queue_send_msg (q, NULL, &tvc, sizeof (tvc));
}
@@ -6611,8 +6344,9 @@ validation_start_cb (void *cls)
validation_task = NULL;
vs = GNUNET_CONTAINER_heap_peek (validation_heap);
/* drop validations past their expiration */
- while ( (NULL != vs) &&
- (0 == GNUNET_TIME_absolute_get_remaining (vs->valid_until).rel_value_us) )
+ while (
+ (NULL != vs) &&
+ (0 == GNUNET_TIME_absolute_get_remaining (vs->valid_until).rel_value_us))
{
free_validation_state (vs);
vs = GNUNET_CONTAINER_heap_peek (validation_heap);
@@ -6620,22 +6354,21 @@ validation_start_cb (void *cls)
if (NULL == vs)
return; /* woopsie, no more addresses known, should only
happen if we're really a lonely peer */
- q = find_queue (&vs->pid,
- vs->address);
+ q = find_queue (&vs->pid, vs->address);
if (NULL == q)
{
vs->awaiting_queue = GNUNET_YES;
- suggest_to_connect (&vs->pid,
- vs->address);
+ suggest_to_connect (&vs->pid, vs->address);
}
else
- validation_transmit_on_queue (q,
- vs);
+ validation_transmit_on_queue (q, vs);
/* Finally, reschedule next attempt */
- vs->challenge_backoff = GNUNET_TIME_randomized_backoff (vs->challenge_backoff,
- MAX_VALIDATION_CHALLENGE_FREQ);
+ vs->challenge_backoff =
+ GNUNET_TIME_randomized_backoff (vs->challenge_backoff,
+ MAX_VALIDATION_CHALLENGE_FREQ);
update_next_challenge_time (vs,
- GNUNET_TIME_relative_to_absolute (vs->challenge_backoff));
+ GNUNET_TIME_relative_to_absolute (
+ vs->challenge_backoff));
}
@@ -6664,7 +6397,6 @@ struct QueueQualityContext
* k-th queue in @e q.
*/
unsigned int k;
-
};
@@ -6690,9 +6422,7 @@ check_connection_quality (void *cls,
(void) pid;
do_inc = GNUNET_NO;
- for (struct Queue *q = n->queue_head;
- NULL != q;
- q = q->next_neighbour)
+ for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour)
{
if (0 != q->distance)
continue; /* DV does not count */
@@ -6730,8 +6460,7 @@ start_dv_learn (void *cls)
(void) cls;
dvlearn_task = NULL;
- if (0 ==
- GNUNET_CONTAINER_multipeermap_size (neighbours))
+ if (0 == GNUNET_CONTAINER_multipeermap_size (neighbours))
return; /* lost all connectivity, cannot do learning */
qqc.quality_count = 0;
qqc.num_queues = 0;
@@ -6745,11 +6474,8 @@ start_dv_learn (void *cls)
/* scale our retries by how far we are above the threshold */
factor = qqc.quality_count / DV_LEARN_QUALITY_THRESHOLD;
- delay = GNUNET_TIME_relative_multiply (DV_LEARN_BASE_FREQUENCY,
- factor);
- dvlearn_task = GNUNET_SCHEDULER_add_delayed (delay,
- &start_dv_learn,
- NULL);
+ delay = GNUNET_TIME_relative_multiply (DV_LEARN_BASE_FREQUENCY, factor);
+ dvlearn_task = GNUNET_SCHEDULER_add_delayed (delay, &start_dv_learn, NULL);
return;
}
/* remove old entries in #dvlearn_map if it has grown too big */
@@ -6761,9 +6487,7 @@ start_dv_learn (void *cls)
GNUNET_CONTAINER_multishortmap_remove (dvlearn_map,
&lle->challenge,
lle));
- GNUNET_CONTAINER_DLL_remove (lle_head,
- lle_tail,
- lle);
+ GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle);
GNUNET_free (lle);
}
/* setup data structure for learning */
@@ -6771,37 +6495,33 @@ start_dv_learn (void *cls)
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&lle->challenge,
sizeof (lle->challenge));
- GNUNET_CONTAINER_DLL_insert (lle_head,
- lle_tail,
- lle);
+ GNUNET_CONTAINER_DLL_insert (lle_head, lle_tail, lle);
GNUNET_break (GNUNET_YES ==
- GNUNET_CONTAINER_multishortmap_put (dvlearn_map,
- &lle->challenge,
- lle,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multishortmap_put (
+ dvlearn_map,
+ &lle->challenge,
+ lle,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
dvl.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN);
dvl.header.size = htons (sizeof (dvl));
dvl.num_hops = htons (0);
dvl.bidirectional = htons (0);
dvl.non_network_delay = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO);
{
- struct DvInitPS dvip = {
- .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
- .purpose.size = htonl (sizeof (dvip)),
- .challenge = lle->challenge
- };
+ struct DvInitPS dvip = {.purpose.purpose = htonl (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
+ .purpose.size = htonl (sizeof (dvip)),
+ .challenge = lle->challenge};
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
- &dvip.purpose,
- &dvl.init_sig));
+ GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &dvip.purpose,
+ &dvl.init_sig));
}
dvl.initiator = GST_my_identity;
dvl.challenge = lle->challenge;
qqc.quality_count = 0;
- qqc.k = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- qqc.num_queues);
+ qqc.k = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, qqc.num_queues);
qqc.num_queues = 0;
qqc.q = NULL;
GNUNET_CONTAINER_multipeermap_iterate (neighbours,
@@ -6812,16 +6532,13 @@ start_dv_learn (void *cls)
/* Do this as close to transmission time as possible! */
lle->launch_time = GNUNET_TIME_absolute_get ();
- queue_send_msg (qqc.q,
- NULL,
- &dvl,
- sizeof (dvl));
+ queue_send_msg (qqc.q, NULL, &dvl, sizeof (dvl));
/* reschedule this job, randomizing the time it runs (but no
actual backoff!) */
- dvlearn_task
- = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_randomize (DV_LEARN_BASE_FREQUENCY),
- &start_dv_learn,
- NULL);
+ dvlearn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_randomize (
+ DV_LEARN_BASE_FREQUENCY),
+ &start_dv_learn,
+ NULL);
}
@@ -6843,13 +6560,11 @@ check_validation_request_pending (void *cls,
struct ValidationState *vs = value;
(void) pid;
- if ( (GNUNET_YES == vs->awaiting_queue) &&
- (0 == strcmp (vs->address,
- q->address)) )
+ if ((GNUNET_YES == vs->awaiting_queue) &&
+ (0 == strcmp (vs->address, q->address)))
{
vs->awaiting_queue = GNUNET_NO;
- validation_transmit_on_queue (q,
- vs);
+ validation_transmit_on_queue (q, vs);
return GNUNET_NO;
}
return GNUNET_OK;
@@ -6887,10 +6602,11 @@ handle_add_queue_message (void *cls,
neighbour->earliest_timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
neighbour->pid = aqm->receiver;
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (neighbours,
- &neighbour->pid,
- neighbour,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multipeermap_put (
+ neighbours,
+ &neighbour->pid,
+ neighbour,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
addr_len = ntohs (aqm->header.size) - sizeof (*aqm);
addr = (const char *) &aqm[1];
@@ -6918,20 +6634,12 @@ handle_add_queue_message (void *cls,
GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S,
&tracker_excess_out_cb,
queue);
- memcpy (&queue[1],
- addr,
- addr_len);
+ memcpy (&queue[1], addr, addr_len);
/* notify monitors about new queue */
{
- struct MonitorEvent me = {
- .rtt = queue->rtt,
- .cs = queue->cs
- };
+ struct MonitorEvent me = {.rtt = queue->rtt, .cs = queue->cs};
- notify_monitors (&neighbour->pid,
- queue->address,
- queue->nt,
- &me);
+ notify_monitors (&neighbour->pid, queue->address, queue->nt, &me);
}
GNUNET_CONTAINER_MDLL_insert (neighbour,
neighbour->queue_head,
@@ -6942,14 +6650,14 @@ handle_add_queue_message (void *cls,
tc->details.communicator.queue_tail,
queue);
/* check if valdiations are waiting for the queue */
- (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
- &aqm->receiver,
- &check_validation_request_pending,
- queue);
+ (void)
+ GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
+ &aqm->receiver,
+ &check_validation_request_pending,
+ queue);
/* might be our first queue, try launching DV learning */
if (NULL == dvlearn_task)
- dvlearn_task = GNUNET_SCHEDULER_add_now (&start_dv_learn,
- NULL);
+ dvlearn_task = GNUNET_SCHEDULER_add_now (&start_dv_learn, NULL);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -6986,15 +6694,16 @@ handle_queue_create_ok (void *cls,
/**
* Communicator tells us that our request to create a queue failed. This usually
- * indicates that the provided address is simply invalid or that the communicator's
- * resources are exhausted.
+ * indicates that the provided address is simply invalid or that the
+ * communicator's resources are exhausted.
*
* @param cls the `struct TransportClient`
* @param cqr failure message
*/
static void
-handle_queue_create_fail (void *cls,
- const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
+handle_queue_create_fail (
+ void *cls,
+ const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
{
struct TransportClient *tc = cls;
@@ -7016,14 +6725,14 @@ handle_queue_create_fail (void *cls,
/**
- * We have received a `struct ExpressPreferenceMessage` from an application client.
+ * We have received a `struct ExpressPreferenceMessage` from an application
+ * client.
*
* @param cls handle to the client
* @param msg the start message
*/
static void
-handle_suggest_cancel (void *cls,
- const struct ExpressPreferenceMessage *msg)
+handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg)
{
struct TransportClient *tc = cls;
struct PeerRequest *pr;
@@ -7042,9 +6751,7 @@ handle_suggest_cancel (void *cls,
GNUNET_SERVICE_client_drop (tc->client);
return;
}
- (void) stop_peer_request (tc,
- &pr->pid,
- pr);
+ (void) stop_peer_request (tc, &pr->pid, pr);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -7058,8 +6765,9 @@ handle_suggest_cancel (void *cls,
* @return #GNUNET_OK
*/
static int
-check_address_consider_verify (void *cls,
- const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
+check_address_consider_verify (
+ void *cls,
+ const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
{
(void) cls;
(void) hdr;
@@ -7102,8 +6810,7 @@ check_known_address (void *cls,
struct ValidationState *vs = value;
(void) pid;
- if (0 != strcmp (vs->address,
- ckac->address))
+ if (0 != strcmp (vs->address, ckac->address))
return GNUNET_OK;
ckac->vs = vs;
return GNUNET_NO;
@@ -7124,10 +6831,7 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid,
{
struct GNUNET_TIME_Absolute now;
struct ValidationState *vs;
- struct CheckKnownAddressContext ckac = {
- .address = address,
- .vs = NULL
- };
+ struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL};
if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
return; /* expired */
@@ -7137,19 +6841,22 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid,
&ckac);
if (NULL != (vs = ckac.vs))
{
- /* if 'vs' is not currently valid, we need to speed up retrying the validation */
+ /* if 'vs' is not currently valid, we need to speed up retrying the
+ * validation */
if (vs->validated_until.abs_value_us < vs->next_challenge.abs_value_us)
{
/* reduce backoff as we got a fresh advertisement */
- vs->challenge_backoff = GNUNET_TIME_relative_min (FAST_VALIDATION_CHALLENGE_FREQ,
- GNUNET_TIME_relative_divide (vs->challenge_backoff,
- 2));
+ vs->challenge_backoff =
+ GNUNET_TIME_relative_min (FAST_VALIDATION_CHALLENGE_FREQ,
+ GNUNET_TIME_relative_divide (vs->challenge_backoff,
+ 2));
update_next_challenge_time (vs,
- GNUNET_TIME_relative_to_absolute (vs->challenge_backoff));
+ GNUNET_TIME_relative_to_absolute (
+ vs->challenge_backoff));
}
return;
}
- now = GNUNET_TIME_absolute_get();
+ now = GNUNET_TIME_absolute_get ();
vs = GNUNET_new (struct ValidationState);
vs->pid = *pid;
vs->valid_until = expiration;
@@ -7160,12 +6867,12 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid,
sizeof (vs->challenge));
vs->address = GNUNET_strdup (address);
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_put (validation_map,
- &vs->pid,
- vs,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
- update_next_challenge_time (vs,
- now);
+ GNUNET_CONTAINER_multipeermap_put (
+ validation_map,
+ &vs->pid,
+ vs,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ update_next_challenge_time (vs, now);
}
@@ -7192,8 +6899,7 @@ handle_hello (void *cls,
return;
}
val = record->value;
- if ( (0 == record->value_size) ||
- ('\0' != val[record->value_size - 1]) )
+ if ((0 == record->value_size) || ('\0' != val[record->value_size - 1]))
{
GNUNET_break (0);
return;
@@ -7205,14 +6911,14 @@ handle_hello (void *cls,
/**
- * We have received a `struct ExpressPreferenceMessage` from an application client.
+ * We have received a `struct ExpressPreferenceMessage` from an application
+ * client.
*
* @param cls handle to the client
* @param msg the start message
*/
static void
-handle_suggest (void *cls,
- const struct ExpressPreferenceMessage *msg)
+handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
{
struct TransportClient *tc = cls;
struct PeerRequest *pr;
@@ -7220,9 +6926,8 @@ handle_suggest (void *cls,
if (CT_NONE == tc->type)
{
tc->type = CT_APPLICATION;
- tc->details.application.requests
- = GNUNET_CONTAINER_multipeermap_create (16,
- GNUNET_YES);
+ tc->details.application.requests =
+ GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
}
if (CT_APPLICATION != tc->type)
{
@@ -7240,11 +6945,11 @@ handle_suggest (void *cls,
pr->pid = msg->peer;
pr->bw = msg->bw;
pr->pk = (enum GNUNET_MQ_PreferenceKind) ntohl (msg->pk);
- if (GNUNET_YES !=
- GNUNET_CONTAINER_multipeermap_put (tc->details.application.requests,
- &pr->pid,
- pr,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put (
+ tc->details.application.requests,
+ &pr->pid,
+ pr,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
GNUNET_break (0);
GNUNET_free (pr);
@@ -7270,8 +6975,9 @@ handle_suggest (void *cls,
* signature in the body, see #GNUNET_HELLO_extract_address()
*/
static void
-handle_address_consider_verify (void *cls,
- const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
+handle_address_consider_verify (
+ void *cls,
+ const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
{
struct TransportClient *tc = cls;
char *address;
@@ -7282,19 +6988,18 @@ handle_address_consider_verify (void *cls,
// OPTIMIZE-FIXME: checking that we know this address already should
// be done BEFORE checking the signature => HELLO API change!
// OPTIMIZE-FIXME: pre-check: rate-limit signature verification / validation?!
- address = GNUNET_HELLO_extract_address (&hdr[1],
- ntohs (hdr->header.size) - sizeof (*hdr),
- &hdr->peer,
- &nt,
- &expiration);
+ address =
+ GNUNET_HELLO_extract_address (&hdr[1],
+ ntohs (hdr->header.size) - sizeof (*hdr),
+ &hdr->peer,
+ &nt,
+ &expiration);
if (NULL == address)
{
GNUNET_break_op (0);
return;
}
- start_address_validation (&hdr->peer,
- address,
- expiration);
+ start_address_validation (&hdr->peer, address, expiration);
GNUNET_free (address);
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -7446,19 +7151,15 @@ do_shutdown (void *cls)
GNUNET_SCHEDULER_cancel (ephemeral_task);
ephemeral_task = NULL;
}
- GNUNET_CONTAINER_multipeermap_iterate (neighbours,
- &free_neighbour_cb,
- NULL);
+ GNUNET_CONTAINER_multipeermap_iterate (neighbours, &free_neighbour_cb, NULL);
if (NULL != peerstore)
{
- GNUNET_PEERSTORE_disconnect (peerstore,
- GNUNET_NO);
+ GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO);
peerstore = NULL;
}
if (NULL != GST_stats)
{
- GNUNET_STATISTICS_destroy (GST_stats,
- GNUNET_NO);
+ GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
GST_stats = NULL;
}
if (NULL != GST_my_private_key)
@@ -7475,18 +7176,14 @@ do_shutdown (void *cls)
validation_map = NULL;
while (NULL != (lle = lle_head))
{
- GNUNET_CONTAINER_DLL_remove (lle_head,
- lle_tail,
- lle);
+ GNUNET_CONTAINER_DLL_remove (lle_head, lle_tail, lle);
GNUNET_free (lle);
}
GNUNET_CONTAINER_multishortmap_destroy (dvlearn_map);
dvlearn_map = NULL;
GNUNET_CONTAINER_heap_destroy (validation_heap);
validation_heap = NULL;
- GNUNET_CONTAINER_multipeermap_iterate (dv_routes,
- &free_dv_routes_cb,
- NULL);
+ GNUNET_CONTAINER_multipeermap_iterate (dv_routes, &free_dv_routes_cb, NULL);
GNUNET_CONTAINER_multipeermap_destroy (dv_routes);
dv_routes = NULL;
GNUNET_CONTAINER_multipeermap_iterate (ephemeral_map,
@@ -7515,35 +7212,34 @@ run (void *cls,
(void) service;
/* setup globals */
GST_cfg = c;
- neighbours = GNUNET_CONTAINER_multipeermap_create (1024,
- GNUNET_YES);
- dv_routes = GNUNET_CONTAINER_multipeermap_create (1024,
- GNUNET_YES);
- ephemeral_map = GNUNET_CONTAINER_multipeermap_create (32,
- GNUNET_YES);
- ephemeral_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES);
+ dv_routes = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES);
+ ephemeral_map = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES);
+ ephemeral_heap =
+ GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
dvlearn_map = GNUNET_CONTAINER_multishortmap_create (2 * MAX_DV_LEARN_PENDING,
GNUNET_YES);
- validation_map = GNUNET_CONTAINER_multipeermap_create (1024,
- GNUNET_YES);
- validation_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- GST_my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg);
+ validation_map = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES);
+ validation_heap =
+ GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ GST_my_private_key =
+ GNUNET_CRYPTO_eddsa_key_create_from_configuration (GST_cfg);
if (NULL == GST_my_private_key)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Transport service is lacking key configuration settings. Exiting.\n"));
+ GNUNET_log (
+ GNUNET_ERROR_TYPE_ERROR,
+ _ (
+ "Transport service is lacking key configuration settings. Exiting.\n"));
GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_CRYPTO_eddsa_key_get_public (GST_my_private_key,
&GST_my_identity.public_key);
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "My identity is `%s'\n",
- GNUNET_i2s_full (&GST_my_identity));
- GST_stats = GNUNET_STATISTICS_create ("transport",
- GST_cfg);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
- NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "My identity is `%s'\n",
+ GNUNET_i2s_full (&GST_my_identity));
+ GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
peerstore = GNUNET_PEERSTORE_connect (GST_cfg);
if (NULL == peerstore)
{
@@ -7557,86 +7253,86 @@ run (void *cls,
/**
* Define "main" method using service macro.
*/
-GNUNET_SERVICE_MAIN
-("transport",
- GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN,
- &run,
- &client_connect_cb,
- &client_disconnect_cb,
- NULL,
- /* communication with applications */
- GNUNET_MQ_hd_fixed_size (suggest,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST,
- struct ExpressPreferenceMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (suggest_cancel,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL,
- struct ExpressPreferenceMessage,
- NULL),
- GNUNET_MQ_hd_var_size (request_hello_validation,
- GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION,
- struct RequestHelloValidationMessage,
- NULL),
- /* communication with core */
- GNUNET_MQ_hd_fixed_size (client_start,
- GNUNET_MESSAGE_TYPE_TRANSPORT_START,
- struct StartMessage,
- NULL),
- GNUNET_MQ_hd_var_size (client_send,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
- struct OutboundMessage,
- NULL),
- /* communication with communicators */
- GNUNET_MQ_hd_var_size (communicator_available,
- GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
- struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
- NULL),
- GNUNET_MQ_hd_var_size (communicator_backchannel,
- GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
- struct GNUNET_TRANSPORT_CommunicatorBackchannel,
- NULL),
- GNUNET_MQ_hd_var_size (add_address,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
- struct GNUNET_TRANSPORT_AddAddressMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (del_address,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
- struct GNUNET_TRANSPORT_DelAddressMessage,
- NULL),
- GNUNET_MQ_hd_var_size (incoming_msg,
- GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG,
- struct GNUNET_TRANSPORT_IncomingMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (queue_create_ok,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
- struct GNUNET_TRANSPORT_CreateQueueResponse,
- NULL),
- GNUNET_MQ_hd_fixed_size (queue_create_fail,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL,
- struct GNUNET_TRANSPORT_CreateQueueResponse,
- NULL),
- GNUNET_MQ_hd_var_size (add_queue_message,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
- struct GNUNET_TRANSPORT_AddQueueMessage,
- NULL),
- GNUNET_MQ_hd_var_size (address_consider_verify,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY,
- struct GNUNET_TRANSPORT_AddressToVerify,
- NULL),
- GNUNET_MQ_hd_fixed_size (del_queue_message,
- GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
- struct GNUNET_TRANSPORT_DelQueueMessage,
- NULL),
- GNUNET_MQ_hd_fixed_size (send_message_ack,
- GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
- struct GNUNET_TRANSPORT_SendMessageToAck,
- NULL),
- /* communication with monitors */
- GNUNET_MQ_hd_fixed_size (monitor_start,
- GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START,
- struct GNUNET_TRANSPORT_MonitorStart,
- NULL),
- GNUNET_MQ_handler_end ());
+GNUNET_SERVICE_MAIN (
+ "transport",
+ GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN,
+ &run,
+ &client_connect_cb,
+ &client_disconnect_cb,
+ NULL,
+ /* communication with applications */
+ GNUNET_MQ_hd_fixed_size (suggest,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST,
+ struct ExpressPreferenceMessage,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (suggest_cancel,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL,
+ struct ExpressPreferenceMessage,
+ NULL),
+ GNUNET_MQ_hd_var_size (request_hello_validation,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION,
+ struct RequestHelloValidationMessage,
+ NULL),
+ /* communication with core */
+ GNUNET_MQ_hd_fixed_size (client_start,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_START,
+ struct StartMessage,
+ NULL),
+ GNUNET_MQ_hd_var_size (client_send,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
+ struct OutboundMessage,
+ NULL),
+ /* communication with communicators */
+ GNUNET_MQ_hd_var_size (communicator_available,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
+ struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
+ NULL),
+ GNUNET_MQ_hd_var_size (communicator_backchannel,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
+ struct GNUNET_TRANSPORT_CommunicatorBackchannel,
+ NULL),
+ GNUNET_MQ_hd_var_size (add_address,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
+ struct GNUNET_TRANSPORT_AddAddressMessage,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (del_address,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
+ struct GNUNET_TRANSPORT_DelAddressMessage,
+ NULL),
+ GNUNET_MQ_hd_var_size (incoming_msg,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG,
+ struct GNUNET_TRANSPORT_IncomingMessage,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (queue_create_ok,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
+ struct GNUNET_TRANSPORT_CreateQueueResponse,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (queue_create_fail,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL,
+ struct GNUNET_TRANSPORT_CreateQueueResponse,
+ NULL),
+ GNUNET_MQ_hd_var_size (add_queue_message,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
+ struct GNUNET_TRANSPORT_AddQueueMessage,
+ NULL),
+ GNUNET_MQ_hd_var_size (address_consider_verify,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY,
+ struct GNUNET_TRANSPORT_AddressToVerify,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (del_queue_message,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
+ struct GNUNET_TRANSPORT_DelQueueMessage,
+ NULL),
+ GNUNET_MQ_hd_fixed_size (send_message_ack,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
+ struct GNUNET_TRANSPORT_SendMessageToAck,
+ NULL),
+ /* communication with monitors */
+ GNUNET_MQ_hd_fixed_size (monitor_start,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_START,
+ struct GNUNET_TRANSPORT_MonitorStart,
+ NULL),
+ GNUNET_MQ_handler_end ());
/* end of file gnunet-service-transport.c */