/*
- This file is part of GNUnet.
- Copyright (C) 2010-2016, 2018, 2019 GNUnet e.V.
+ This file is part of GNUnet.
+ Copyright (C) 2010-2016, 2018, 2019 GNUnet e.V.
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
*/
*
* TODO:
* Implement next:
- * - FIXME-FC: realize transport-to-transport flow control (needed in case
- * communicators do not offer flow control).
- * We do transmit FC window sizes now. Left:
- * for SENDING)
- * - need to call consider_sending_fc() periodically if it goes unanswered!
- *
- * for DV)
- * - send challenges via DV (when DVH is confirmed *and* we care about
- * the target to get window size, or when DVH is unconfirmed (passive
- * learning!) to confirm it!)
- * - handle challenge responses in this case (note: validity period of addresses
- * will be zero!)
- * - if available, try to use DV paths when trying to establish
- * virtual link for a `struct IncomingRequest`. (i.e. if DVH is
- * unconfirmed, incoming requests also trigger challenge-via-DV!)
- *
* - review retransmission logic, right now there is no smartness there!
* => congestion control, etc [PERFORMANCE-BASICS]
*
- * Optimizations:
+ * Optimizations-Statistics:
+ * - Track ACK losses based on ACK-counter [ROUTING]
+ * - Need to track total bandwidth per VirtualLink and adjust how frequently
+ * we send FC messages based on bandwidth-delay-product (and relation
+ * to the window size!). See OPTIMIZE-FC-BDP.
+ * - Consider more statistics in #check_connection_quality() [FIXME-CONQ-STATISTICS]
+ * - Adapt available_fc_window_size, using larger values for high-bandwidth
+ * and high-latency links *if* we have the RAM [GOODPUT / utilization / stalls]
+ * - Set last_window_consum_limit promise properly based on
+ * latency and bandwidth of the respective connection [GOODPUT / utilization / stalls]
+ *
+ * Optimizations-DV:
* - When forwarding DV learn messages, if a peer is reached that
* has a *bidirectional* link to the origin beyond 1st hop,
* do NOT forward it to peers _other_ than the origin, as
* there is clearly a better path directly from the origin to
* whatever else we could reach.
- * - AcknowledgementUUIDPs are overkill with 256 bits (128 would do)
- * => Need 128 bit hash map though! [BANDWIDTH, MEMORY]
- * - queue_send_msg by API design has to make a copy
- * of the payload, and route_message on top of that requires a malloc/free.
- * Change design to approximate "zero" copy better... [CPU]
- * - could avoid copying body of message into each fragment and keep
- * fragments as just pointers into the original message and only
- * fully build fragments just before transmission (optimization, should
- * reduce CPU and memory use) [CPU, MEMORY]
- * - if messages are below MTU, consider adding ACKs and other stuff
- * to the same transmission to avoid tiny messages (requires planning at
- * receiver, and additional MST-style demultiplex at receiver!) [PACKET COUNT]
* - When we passively learned DV (with unconfirmed freshness), we
* right now add the path to our list but with a zero path_valid_until
* time and only use it for unconfirmed routes. However, we could consider
* triggering an explicit validation mechansim ourselves, specifically routing
* a challenge-response message over the path [ROUTING]
- * - Track ACK losses based on ACK-counter [ROUTING]
+ * = if available, try to confirm unconfirmed DV paths when trying to establish
+ * virtual link for a `struct IncomingRequest`. (i.e. if DVH is
+ * unconfirmed, incoming requests cause us to try to validate a passively
+ * learned path (requires new message type!))
+ *
+ * Optimizations-Fragmentation:
* - Fragments send over a reliable channel could do without the
* AcknowledgementUUIDP altogether, as they won't be acked! [BANDWIDTH]
* (-> have 2nd type of acknowledgment message; low priority, as we
- * do not have an MTU-limited *reliable* communicator)
- * - Adapt available_fc_window_size, using larger values for high-bandwidth
- * and high-latency links *if* we have the RAM [GOODPUT / utilization / stalls]
- * - Set last_window_consum_limit promise properly based on
- * latency and bandwidth of the respective connection [GOODPUT / utilization / stalls]
+ * do not have an MTU-limited *reliable* communicator) [FIXME-FRAG-REL-UUID]
+ * - if messages are below MTU, consider adding ACKs and other stuff
+ * to the same transmission to avoid tiny messages (requires planning at
+ * receiver, and additional MST-style demultiplex at receiver!) [PACKET COUNT]
*
- * Design realizations / discussion:
- * - communicators do flow control by calling MQ "notify sent"
- * when 'ready'. They determine flow implicitly (i.e. TCP blocking)
- * or explicitly via backchannel FC ACKs. As long as the
- * channel is not full, they may 'notify sent' even if the other
- * peer has not yet confirmed receipt. The other peer confirming
- * is _only_ for FC, not for more reliable transmission; reliable
- * transmission (i.e. of fragments) is left to _transport_.
- * - ACKs sent back in uni-directional communicators are done via
- * the background channel API; here transport _may_ initially
- * broadcast (with bounded # hops) if no path is known;
- * - transport should _integrate_ DV-routing and build a view of
- * the network; then background channel traffic can be
- * routed via DV as well as explicit "DV" traffic.
- * - background channel is also used for ACKs and NAT traversal support
- * - transport service is responsible for AEAD'ing the background
- * channel, timestamps and monotonic time are used against replay
- * of old messages -> peerstore needs to be supplied with
- * "latest timestamps seen" data
- * - if transport implements DV, we likely need a 3rd peermap
- * in addition to ephemerals and (direct) neighbours
- * ==> check if stuff needs to be moved out of "Neighbour"
- * - transport should encapsualte core-level messages and do its
- * own ACKing for RTT/goodput/loss measurements _and_ fragment
- * for retransmission
+ * Optimizations-internals:
+ * - queue_send_msg by API design has to make a copy
+ * of the payload, and route_message on top of that requires a malloc/free.
+ * Change design to approximate "zero" copy better... [CPU]
+ * - could avoid copying body of message into each fragment and keep
+ * fragments as just pointers into the original message and only
+ * fully build fragments just before transmission (optimization, should
+ * reduce CPU and memory use) [CPU, MEMORY]
*/
#include "platform.h"
#include "gnunet_util_lib.h"
*/
#define MAX_CUMMULATIVE_ACKS 64
+/**
+ * What is the 1:n chance that we send a Flow control response when
+ * receiving a flow control message that did not change anything for
+ * us? Basically, this is used in the case where both peers are stuck
+ * on flow control (no window changes), but one might continue sending
+ * flow control messages to the other peer as the first FC message
+ * when things stalled got lost, and then subsequently the other peer
+ * does *usually* not respond as nothing changed. So to ensure that
+ * eventually the FC messages stop, we do send with 1/8th probability
+ * an FC message even if nothing changed. That prevents one peer
+ * being stuck in sending (useless) FC messages "forever".
+ */
+#define FC_NO_CHANGE_REPLY_PROBABILITY 8
+
/**
* What is the size we assume for a read operation in the
* absence of an MTU for the purpose of flow control?
struct AcknowledgementUUIDP
{
/**
- * The UUID value. Not actually a hash, but a random value.
+ * The UUID value.
*/
- struct GNUNET_ShortHashCode value;
+ struct GNUNET_Uuid value;
};
*/
struct EphemeralConfirmationPS
{
-
/**
* Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL
*/
*/
struct TransportDVBoxPayloadP
{
-
/**
* Sender's peer identity.
*/
*/
struct TransportValidationChallengeMessage
{
-
/**
* Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE
*/
*/
struct TransportValidationPS
{
-
/**
* Purpose is #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE
*/
*/
struct TransportValidationResponseMessage
{
-
/**
* Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE
*/
*/
struct LearnLaunchEntry
{
-
/**
* Kept (also) in a DLL sorted by launch time.
*/
*/
struct CommunicatorMessageContext
{
-
/**
* Kept in a DLL of `struct VirtualLink` if waiting for CORE
* flow control to unchoke.
*/
struct CoreSentContext
{
-
/**
* Kept in a DLL to clear @e vl in case @e vl is lost.
*/
*/
struct GNUNET_SCHEDULER_Task *visibility_task;
+ /**
+ * Task scheduled to periodically retransmit FC messages (in
+ * case one got lost).
+ */
+ struct GNUNET_SCHEDULER_Task *fc_retransmit_task;
+
/**
* Neighbour used by this virtual link, NULL if @e dv is used.
*/
*/
struct DistanceVector *dv;
- /**
- * Last challenge we received from @a n.
- * FIXME: where do we need this?
- */
- struct ChallengeNonceP n_challenge;
-
- /**
- * Last challenge we used with @a n for flow control.
- * FIXME: where do we need this?
- */
- struct ChallengeNonceP my_challenge;
-
/**
* Sender timestamp of @e n_challenge, used to generate out-of-order
* challenges (as sender's timestamps must be monotonically
*/
struct GNUNET_TIME_Absolute last_fc_timestamp;
+ /**
+ * Expected RTT from the last FC transmission. (Zero if the last
+ * attempt failed, but could theoretically be zero even on success.)
+ */
+ struct GNUNET_TIME_Relative last_fc_rtt;
+
/**
* Used to generate unique UUIDs for messages that are being
* fragmented.
*/
uint64_t outbound_fc_window_size_used;
+ /**
+ * What is the most recent FC window the other peer sent us
+ * in `outbound_window_size`? This is basically the window
+ * size value the other peer has definitively received from
+ * us. If it matches @e incoming_fc_window_size, we should
+ * not send a FC message to increase the FC window. However,
+ * we may still send an FC message to notify the other peer
+ * that we received the other peer's FC message.
+ */
+ uint64_t last_outbound_window_size_received;
+
/**
* Generator for the sequence numbers of
* #GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL messages we send.
*/
struct PendingAcknowledgement
{
-
/**
* If @e pm is non-NULL, this is the DLL in which this acknowledgement
* is kept in relation to its pending message.
*/
struct DistanceVectorHop
{
-
/**
* Kept in a MDLL, sorted by @e timeout.
*/
*/
struct DistanceVector
{
-
/**
* To which peer is this a route?
*/
*/
struct QueueEntry
{
-
/**
* Kept as a DLL.
*/
*/
struct ReassemblyContext
{
-
/**
* Original message ID for of the message that all the fragments
* belong to.
*/
struct Neighbour
{
-
/**
* Which peer is this about?
*/
*/
struct IncomingRequest
{
-
/**
* Kept in a DLL.
*/
*/
struct PeerRequest
{
-
/**
* Which peer is this about?
*/
*/
enum PendingMessageType
{
-
/**
* Ordinary message received from the CORE service.
*/
* Pending message created during #forward_dv_box().
*/
PMT_DV_BOX = 3
-
};
*/
struct AddressListEntry
{
-
/**
* Kept in a DLL.
*/
*/
struct TransportClient
{
-
/**
* Kept in a DLL.
*/
union
{
-
/**
* Information for @e type #CT_CORE.
*/
struct
{
-
/**
* Head of list of messages pending for this client, sorted by
* transmission time ("next_attempt" + possibly internal prioritization).
* Tail of list of messages pending for this client.
*/
struct PendingMessage *pending_msg_tail;
-
} core;
/**
*/
struct
{
-
/**
* Peer identity to monitor the addresses of.
* Zero to monitor all neighbours. Valid if
* Is this a one-shot monitor?
*/
int one_shot;
-
} monitor;
* Characteristics of this communicator.
*/
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
-
} communicator;
/**
*/
struct
{
-
/**
* Map of requests for peers the given client application would like to
* see connections for. Maps from PIDs to `struct PeerRequest`.
*/
struct GNUNET_CONTAINER_MultiPeerMap *requests;
-
} application;
-
} details;
};
*/
struct ValidationState
{
-
/**
* For which peer is @a address to be validated (or possibly valid)?
* Serves as key in the #validation_map.
* Map of pending acknowledgements, mapping `struct AcknowledgementUUID` to
* a `struct PendingAcknowledgement`.
*/
-static struct GNUNET_CONTAINER_MultiShortmap *pending_acks;
+static struct GNUNET_CONTAINER_MultiUuidmap *pending_acks;
/**
* Map from PIDs to `struct DistanceVector` entries describing
pa->queue = NULL;
}
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multishortmap_remove (pending_acks,
- &pa->ack_uuid.value,
- pa));
+ GNUNET_CONTAINER_multiuuidmap_remove (pending_acks,
+ &pa->ack_uuid.value,
+ pa));
GNUNET_free (pa);
}
GNUNET_SCHEDULER_cancel (vl->visibility_task);
vl->visibility_task = NULL;
}
+ if (NULL != vl->fc_retransmit_task)
+ {
+ GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task);
+ vl->fc_retransmit_task = NULL;
+ }
while (NULL != (csc = vl->csc_head))
{
GNUNET_CONTAINER_DLL_remove (vl->csc_head, vl->csc_tail, csc);
while (NULL != (rc = GNUNET_CONTAINER_heap_peek (n->reassembly_heap)))
{
if (0 == GNUNET_TIME_absolute_get_remaining (rc->reassembly_timeout)
- .rel_value_us)
+ .rel_value_us)
{
free_reassembly_context (rc);
continue;
{
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;
struct PendingAcknowledgement *pa;
{
case CT_NONE:
break;
+
case CT_CORE: {
- struct PendingMessage *pm;
+ 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;
+ 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;
+ break;
+
case CT_MONITOR:
break;
+
case CT_COMMUNICATOR: {
- struct Queue *q;
- struct AddressListEntry *ale;
+ 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;
- 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,
GNUNET_break (0);
return GNUNET_SYSERR;
}
- size = ntohs (obm->header.size) - sizeof (struct OutboundMessage);
- if (size < sizeof (struct GNUNET_MessageHeader))
+ size = ntohs (obm->header.size) - sizeof(struct OutboundMessage);
+ if (size < sizeof(struct GNUNET_MessageHeader))
{
GNUNET_break (0);
return GNUNET_SYSERR;
{
struct TransportClient *tc = pm->client;
struct VirtualLink *vl = pm->vl;
- struct GNUNET_MQ_Envelope *env;
- struct SendOkMessage *som;
if (NULL != tc)
{
+ struct GNUNET_MQ_Envelope *env;
+ struct SendOkMessage *som;
+
env = GNUNET_MQ_msg (som, GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
som->peer = vl->target;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
{
if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
(GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
- .rel_value_us == 0))
- continue; /* pos unconfirmed and confirmed required */
+ .rel_value_us == 0))
+ continue; /* pos unconfirmed and confirmed required */
num_dv += MAX_DV_HOPS_ALLOWED - pos->distance;
dv_count++;
}
if ((0 == (options & RMO_UNCONFIRMED_ALLOWED)) &&
(GNUNET_TIME_absolute_get_remaining (pos->path_valid_until)
- .rel_value_us == 0))
- continue; /* pos unconfirmed and confirmed required */
+ .rel_value_us == 0))
+ continue; /* pos unconfirmed and confirmed required */
for (unsigned int i = 0; i < hops_array_length; i++)
if ((num_dv <= choices[i]) && (num_dv + delta > choices[i]))
hops_array[dv_count++] = pos;
return GNUNET_SYSERR;
}
tc->type = CT_COMMUNICATOR;
- size = ntohs (cam->header.size) - sizeof (*cam);
+ size = ntohs (cam->header.size) - sizeof(*cam);
if (0 == size)
return GNUNET_OK; /* receive-only communicator */
GNUNET_MQ_check_zero_termination (cam);
struct TransportClient *tc = cls;
uint16_t size;
- size = ntohs (cam->header.size) - sizeof (*cam);
+ size = ntohs (cam->header.size) - sizeof(*cam);
if (0 == size)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Receive-only communicator connected\n");
- return; /* receive-only communicator */
+ return; /* receive-only communicator */
}
tc->details.communicator.address_prefix =
GNUNET_strdup ((const char *) &cam[1]);
uint16_t isize;
(void) cls;
- msize = ntohs (cb->header.size) - sizeof (*cb);
+ msize = ntohs (cb->header.size) - sizeof(*cb);
inbox = (const struct GNUNET_MessageHeader *) &cb[1];
isize = ntohs (inbox->size);
if (isize >= msize)
GNUNET_CRYPTO_ecdhe_key_create2 (&dv->private_key));
GNUNET_CRYPTO_ecdhe_key_get_public (&dv->private_key, &dv->ephemeral_key);
ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
- ec.purpose.size = htonl (sizeof (ec));
+ ec.purpose.size = htonl (sizeof(ec));
ec.target = dv->target;
ec.ephemeral_key = dv->ephemeral_key;
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
- &ec.purpose,
- &dv->sender_sig));
+ GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &ec,
+ &dv->sender_sig);
}
GNUNET_ERROR_TYPE_DEBUG,
"Queueing %u bytes of payload for transmission <%llu> on queue %llu to %s\n",
(unsigned int) payload_size,
- pm->logging_uuid,
+ (NULL == pm) ? 0 : pm->logging_uuid,
(unsigned long long) queue->qid,
GNUNET_i2s (&queue->neighbour->pid));
env = GNUNET_MQ_msg_extra (smt,
* @param hdr message to send as payload
* @param options whether queues must be confirmed or not,
* and whether we may pick multiple (2) queues
+ * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed
*/
-static void
+static struct GNUNET_TIME_Relative
route_via_neighbour (const struct Neighbour *n,
const struct GNUNET_MessageHeader *hdr,
enum RouteMessageOptions options)
unsigned int candidates;
unsigned int sel1;
unsigned int sel2;
+ struct GNUNET_TIME_Relative rtt;
/* Pick one or two 'random' queues from n (under constraints of options) */
now = GNUNET_TIME_absolute_get ();
"# route selection failed (all no valid queue)",
1,
GNUNET_NO);
- return;
+ return GNUNET_TIME_UNIT_FOREVER_REL;
}
+ rtt = GNUNET_TIME_UNIT_FOREVER_REL;
sel1 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, candidates);
if (0 == (options & RMO_REDUNDANT))
sel2 = candidates; /* picks none! */
GNUNET_i2s (&n->pid),
pos->address,
(sel1 == candidates) ? 1 : 2);
+ rtt = GNUNET_TIME_relative_min (rtt, pos->pd.aged_rtt);
queue_send_msg (pos, NULL, hdr, ntohs (hdr->size));
}
candidates++;
}
}
+ return rtt;
}
*/
struct
{
-
/**
* Key used for HMAC calculations (via #GNUNET_CRYPTO_hmac()).
*/
* Counter value to use during setup.
*/
char aes_ctr[128 / 8];
-
} material;
};
/* must match #dh_key_derive_eph_pub */
GNUNET_assert (GNUNET_YES ==
GNUNET_CRYPTO_kdf (&key->material,
- sizeof (key->material),
+ sizeof(key->material),
"transport-backchannel-key",
strlen ("transport-backchannel-key"),
&km,
- sizeof (km),
+ sizeof(km),
iv,
- sizeof (*iv)));
+ sizeof(*iv)));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deriving backchannel key based on KM %s and IV %s\n",
GNUNET_h2s (km),
0 /* flags */);
gcry_cipher_setkey (key->cipher,
&key->material.aes_key,
- sizeof (key->material.aes_key));
+ sizeof(key->material.aes_key));
gcry_cipher_setctr (key->cipher,
&key->material.aes_ctr,
- sizeof (key->material.aes_ctr));
+ sizeof(key->material.aes_ctr));
}
dv_key_clean (struct DVKeyState *key)
{
gcry_cipher_close (key->cipher);
- GNUNET_CRYPTO_zero_keys (&key->material, sizeof (key->material));
+ GNUNET_CRYPTO_zero_keys (&key->material, sizeof(key->material));
}
* @param use function to call with the encapsulated message
* @param use_cls closure for @a use
* @param options whether path must be confirmed or not, to be passed to @a use
+ * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed
*/
-static void
+static struct GNUNET_TIME_Relative
encapsulate_for_dv (struct DistanceVector *dv,
unsigned int num_dvhs,
struct DistanceVectorHop **dvhs,
struct TransportDVBoxMessage box_hdr;
struct TransportDVBoxPayloadP payload_hdr;
uint16_t enc_body_size = ntohs (hdr->size);
- char enc[sizeof (struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN;
+ char enc[sizeof(struct TransportDVBoxPayloadP) + enc_body_size] GNUNET_ALIGN;
struct TransportDVBoxPayloadP *enc_payload_hdr =
(struct TransportDVBoxPayloadP *) enc;
struct DVKeyState key;
+ struct GNUNET_TIME_Relative rtt;
/* Encrypt payload */
box_hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX);
payload_hdr.sender_sig = dv->sender_sig;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&box_hdr.iv,
- sizeof (box_hdr.iv));
+ sizeof(box_hdr.iv));
dh_key_derive_eph_pid (&dv->private_key, &dv->target, &box_hdr.iv, &key);
payload_hdr.sender = GST_my_identity;
payload_hdr.monotonic_time = GNUNET_TIME_absolute_hton (dv->monotime);
- dv_encrypt (&key, &payload_hdr, enc_payload_hdr, sizeof (payload_hdr));
+ dv_encrypt (&key, &payload_hdr, enc_payload_hdr, sizeof(payload_hdr));
dv_encrypt (&key,
hdr,
- &enc[sizeof (struct TransportDVBoxPayloadP)],
+ &enc[sizeof(struct TransportDVBoxPayloadP)],
enc_body_size);
- dv_hmac (&key, &box_hdr.hmac, enc, sizeof (enc));
+ dv_hmac (&key, &box_hdr.hmac, enc, sizeof(enc));
dv_key_clean (&key);
-
+ rtt = GNUNET_TIME_UNIT_FOREVER_REL;
/* For each selected path, take the pre-computed header and body
and add the path in the middle of the message; then send it. */
for (unsigned int i = 0; i < num_dvhs; i++)
{
struct DistanceVectorHop *dvh = dvhs[i];
unsigned int num_hops = dvh->distance + 1;
- char buf[sizeof (struct TransportDVBoxMessage) +
- sizeof (struct GNUNET_PeerIdentity) * num_hops +
- sizeof (struct TransportDVBoxPayloadP) +
- enc_body_size] GNUNET_ALIGN;
+ char buf[sizeof(struct TransportDVBoxMessage)
+ + sizeof(struct GNUNET_PeerIdentity) * num_hops
+ + sizeof(struct TransportDVBoxPayloadP)
+ + enc_body_size] GNUNET_ALIGN;
struct GNUNET_PeerIdentity *dhops;
- box_hdr.header.size = htons (sizeof (buf));
+ box_hdr.header.size = htons (sizeof(buf));
box_hdr.num_hops = htons (num_hops);
- memcpy (buf, &box_hdr, sizeof (box_hdr));
- dhops = (struct GNUNET_PeerIdentity *) &buf[sizeof (box_hdr)];
+ memcpy (buf, &box_hdr, sizeof(box_hdr));
+ dhops = (struct GNUNET_PeerIdentity *) &buf[sizeof(box_hdr)];
memcpy (dhops,
dvh->path,
- dvh->distance * sizeof (struct GNUNET_PeerIdentity));
+ dvh->distance * sizeof(struct GNUNET_PeerIdentity));
dhops[dvh->distance] = dv->target;
if (GNUNET_EXTRA_LOGGING > 0)
{
char *path;
path = GNUNET_strdup (GNUNET_i2s (&GST_my_identity));
- for (unsigned int i = 0; i <= num_hops; i++)
+ for (unsigned int j = 0; j <= num_hops; j++)
{
char *tmp;
- GNUNET_asprintf (&tmp, "%s-%s", path, GNUNET_i2s (&dhops[i]));
+ GNUNET_asprintf (&tmp, "%s-%s", path, GNUNET_i2s (&dhops[j]));
GNUNET_free (path);
path = tmp;
}
path);
GNUNET_free (path);
}
-
- memcpy (&dhops[num_hops], enc, sizeof (enc));
+ rtt = GNUNET_TIME_relative_min (rtt, dvh->pd.aged_rtt);
+ memcpy (&dhops[num_hops], enc, sizeof(enc));
use (use_cls,
dvh->next_hop,
(const struct GNUNET_MessageHeader *) buf,
options);
}
+ return rtt;
}
enum RouteMessageOptions options)
{
(void) cls;
- route_via_neighbour (next_hop, hdr, options);
+ (void) route_via_neighbour (next_hop, hdr, options);
}
* @param target peer to receive @a hdr
* @param hdr header of the message to route and #GNUNET_free()
* @param options which transmission channels are allowed
+ * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed
*/
-static void
+static struct GNUNET_TIME_Relative
route_control_message_without_fc (const struct GNUNET_PeerIdentity *target,
const struct GNUNET_MessageHeader *hdr,
enum RouteMessageOptions options)
struct VirtualLink *vl;
struct Neighbour *n;
struct DistanceVector *dv;
+ struct GNUNET_TIME_Relative rtt1;
+ struct GNUNET_TIME_Relative rtt2;
vl = lookup_virtual_link (target);
GNUNET_assert (NULL != vl);
"# Messages dropped in routing: no acceptable method",
1,
GNUNET_NO);
- return;
+ return GNUNET_TIME_UNIT_FOREVER_REL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing message of type %u to %s with options %X\n",
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. */
+ rtt1 = GNUNET_TIME_UNIT_FOREVER_REL;
+ rtt2 = GNUNET_TIME_UNIT_FOREVER_REL;
if (NULL != n)
{
- route_via_neighbour (n, hdr, options);
+ rtt1 = route_via_neighbour (n, hdr, options);
}
if (NULL != dv)
{
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Failed to route message, could not determine DV path\n");
- return;
+ return rtt1;
}
- encapsulate_for_dv (dv,
- res,
- hops,
- hdr,
- &send_dv_to_neighbour,
- NULL,
- options & (~RMO_REDUNDANT));
+ rtt2 = encapsulate_for_dv (dv,
+ res,
+ hops,
+ hdr,
+ &send_dv_to_neighbour,
+ NULL,
+ options & (~RMO_REDUNDANT));
}
+ return GNUNET_TIME_relative_min (rtt1, rtt2);
}
* Something changed on the virtual link with respect to flow
* control. Consider retransmitting the FC window size.
*
- * @param vl virtual link to work with
+ * @param cls a `struct VirtualLink` to work with
*/
static void
-consider_sending_fc (struct VirtualLink *vl)
+consider_sending_fc (void *cls)
{
+ struct VirtualLink *vl = cls;
struct GNUNET_TIME_Absolute monotime;
struct TransportFlowControlMessage fc;
struct GNUNET_TIME_Relative duration;
+ struct GNUNET_TIME_Relative rtt;
duration = GNUNET_TIME_absolute_get_duration (vl->last_fc_transmission);
- /* FIXME: decide sane criteria on when to do this, instead of doing
+ /* OPTIMIZE-FC-BDP: decide sane criteria on when to do this, instead of doing
it always! */
/* For example, we should probably ONLY do this if a bit more than
an RTT has passed, or if the window changed "significantly" since
- then. */
- (void) duration;
+ then. See vl->last_fc_rtt! NOTE: to do this properly, we also
+ need an estimate for the bandwidth-delay-product for the entire
+ VL, as that determines "significantly". We have the delay, but
+ the bandwidth statistics need to be added for the VL!*/(void) duration;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending FC seq %u to %s with new window %llu\n",
monotime = GNUNET_TIME_absolute_get_monotonic (GST_cfg);
vl->last_fc_transmission = monotime;
fc.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL);
- fc.header.size = htons (sizeof (fc));
+ fc.header.size = htons (sizeof(fc));
fc.seq = htonl (vl->fc_seq_gen++);
fc.inbound_window_size = GNUNET_htonll (vl->incoming_fc_window_size);
fc.outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used);
fc.outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size);
fc.sender_time = GNUNET_TIME_absolute_hton (monotime);
- route_control_message_without_fc (&vl->target, &fc.header, RMO_NONE);
+ rtt = route_control_message_without_fc (&vl->target, &fc.header, RMO_NONE);
+ if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us)
+ {
+ rtt = GNUNET_TIME_UNIT_SECONDS;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "FC retransmission to %s failed, will retry in %s\n",
+ GNUNET_i2s (&vl->target),
+ GNUNET_STRINGS_relative_time_to_string (rtt, GNUNET_YES));
+ vl->last_fc_rtt = GNUNET_TIME_UNIT_ZERO;
+ }
+ else
+ {
+ /* OPTIMIZE-FC-BDP: rtt is not ideal, we can do better! */
+ vl->last_fc_rtt = rtt;
+ }
+ if (NULL != vl->fc_retransmit_task)
+ GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task);
+ vl->fc_retransmit_task =
+ GNUNET_SCHEDULER_add_delayed (rtt, &consider_sending_fc, vl);
}
pm = pm->next_vl)
{
if (NULL != pm->qe)
- continue; /* not eligible, is in a queue! */
+ continue; /* not eligible, is in a queue! */
if (pm->bytes_msg + vl->outbound_fc_window_size_used >
vl->outbound_fc_window_size)
{
"Stalled transmision on VL %s due to flow control: %llu < %llu\n",
GNUNET_i2s (&vl->target),
(unsigned long long) vl->outbound_fc_window_size,
- (unsigned long long) (pm->bytes_msg +
- vl->outbound_fc_window_size_used));
+ (unsigned long long) (pm->bytes_msg
+ + vl->outbound_fc_window_size_used));
consider_sending_fc (vl);
- return; /* We have a message, but flow control says "nope" */
+ return; /* We have a message, but flow control says "nope" */
}
elig = GNUNET_YES;
break;
struct Neighbour *nh = pos->next_hop;
if (pos->path_valid_until.abs_value_us <= now.abs_value_us)
- continue; /* skip this one: path not validated */
+ continue; /* skip this one: path not validated */
for (struct Queue *queue = nh->queue_head; NULL != queue;
queue = queue->next_neighbour)
if ((GNUNET_YES == queue->idle) &&
return;
}
- pm = GNUNET_malloc (sizeof (struct PendingMessage) + bytes_msg);
+ pm = GNUNET_malloc (sizeof(struct PendingMessage) + bytes_msg);
pm->logging_uuid = logging_uuid_gen++;
pm->prefs = pp;
pm->client = tc;
uint16_t isize = ntohs (inbox->size);
const char *is = ((const char *) &cb[1]) + isize;
char
- mbuf[isize +
- sizeof (struct TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN;
+ mbuf[isize
+ + sizeof(struct
+ TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN;
struct TransportBackchannelEncapsulationMessage *be =
(struct TransportBackchannelEncapsulationMessage *) mbuf;
/* 0-termination of 'is' was checked already in
- #check_communicator_backchannel() */
+ #check_communicator_backchannel() */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Preparing backchannel transmission to %s:%s of type %u\n",
GNUNET_i2s (&cb->pid),
/* encapsulate and encrypt message */
be->header.type =
htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION);
- be->header.size = htons (sizeof (mbuf));
+ be->header.size = htons (sizeof(mbuf));
memcpy (&be[1], inbox, isize);
- memcpy (&mbuf[sizeof (struct TransportBackchannelEncapsulationMessage) +
- isize],
+ memcpy (&mbuf[sizeof(struct TransportBackchannelEncapsulationMessage)
+ + isize],
is,
strlen (is) + 1);
route_control_message_without_fc (&cb->pid, &be->header, RMO_DV_ALLOWED);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Communicator added address `%s'!\n",
(const char *) &aam[1]);
- slen = ntohs (aam->header.size) - sizeof (*aam);
- ale = GNUNET_malloc (sizeof (struct AddressListEntry) + slen);
+ slen = ntohs (aam->header.size) - sizeof(*aam);
+ ale = GNUNET_malloc (sizeof(struct AddressListEntry) + slen);
ale->tc = tc;
ale->address = (const char *) &ale[1];
ale->expiration = GNUNET_TIME_relative_ntoh (aam->expiration);
uint16_t size = ntohs (mh->size);
int have_core;
- 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;
we pass this on, CORE would be confused (link down, messages
arrive). We should investigate more if this happens often,
or in a persistent manner, and possibly do "something" about
- it. Thus logging as error for now. */
- GNUNET_break_op (0);
+ it. Thus logging as error for now. */GNUNET_break_op (0);
GNUNET_STATISTICS_update (GST_stats,
"# CORE messages droped (virtual link still down)",
1,
check_fragment_box (void *cls, const struct TransportFragmentBoxMessage *fb)
{
uint16_t size = ntohs (fb->header.size);
- uint16_t bsize = size - sizeof (*fb);
+ uint16_t bsize = size - sizeof(*fb);
(void) cls;
if (0 == bsize)
transmit_cummulative_ack_cb (void *cls)
{
struct AcknowledgementCummulator *ac = cls;
- char buf[sizeof (struct TransportReliabilityAckMessage) +
- ac->ack_counter *
- sizeof (struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN;
+ char buf[sizeof(struct TransportReliabilityAckMessage)
+ + ac->ack_counter
+ * sizeof(struct TransportCummulativeAckPayloadP)] GNUNET_ALIGN;
struct TransportReliabilityAckMessage *ack =
(struct TransportReliabilityAckMessage *) buf;
struct TransportCummulativeAckPayloadP *ap;
GNUNET_assert (0 < ac->ack_counter);
ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK);
ack->header.size =
- htons (sizeof (*ack) +
- ac->ack_counter * sizeof (struct TransportCummulativeAckPayloadP));
+ htons (sizeof(*ack)
+ + ac->ack_counter * sizeof(struct TransportCummulativeAckPayloadP));
ack->ack_counter = htonl (ac->ack_counter++);
ap = (struct TransportCummulativeAckPayloadP *) &ack[1];
for (unsigned int i = 0; i < ac->ack_counter; i++)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling ACK %s for transmission to %s\n",
- GNUNET_sh2s (&ack_uuid->value),
+ GNUNET_uuid2s (&ack_uuid->value),
GNUNET_i2s (pid));
ac = GNUNET_CONTAINER_multipeermap_get (ack_cummulators, pid);
if (NULL == ac)
&fc);
if (NULL == (rc = fc.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;
}
/* reassemble */
- fsize = ntohs (fb->header.size) - sizeof (*fb);
+ fsize = ntohs (fb->header.size) - sizeof(*fb);
if (0 == fsize)
{
GNUNET_break (0);
return;
}
frag_off = ntohs (fb->frag_off);
+ if (frag_off + fsize > msize)
+ {
+ /* Fragment (plus fragment size) exceeds message size! */
+ GNUNET_break_op (0);
+ finish_cmc_handling (cmc);
+ return;
+ }
memcpy (&target[frag_off], &fb[1], fsize);
/* update bitfield and msg_missing */
for (unsigned int i = frag_off; i < frag_off + fsize; i++)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received reliability box from %s with UUID %s of type %u\n",
GNUNET_i2s (&cmc->im.sender),
- GNUNET_sh2s (&rb->ack_uuid.value),
+ GNUNET_uuid2s (&rb->ack_uuid.value),
(unsigned int) ntohs (inbox->type));
rtt = GNUNET_TIME_UNIT_SECONDS; /* FIXME: should base this on "RTT", but we
do not really have an RTT for the
- *incoming* queue (should we have
+ * incoming* queue (should we have
the sender add it to the rb message?) */
cummulative_ack (
&cmc->im.sender,
&rb->ack_uuid,
(0 == ntohl (rb->ack_countdown))
- ? GNUNET_TIME_UNIT_ZERO_ABS
- : GNUNET_TIME_relative_to_absolute (
- GNUNET_TIME_relative_divide (rtt, 8 /* FIXME: magic constant */)));
+ ? GNUNET_TIME_UNIT_ZERO_ABS
+ : GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_relative_divide (rtt, 8 /* FIXME: magic constant */)));
/* continue with inner message */
/* FIXME: check that inbox is NOT a DV Box, fragment or another
reliability box (not allowed!) */
/* Full message sent, we are done */
client_send_response (pm);
return;
+
case PMT_FRAGMENT_BOX:
/* Fragment sent over reliabile channel */
free_fragment_tree (pm);
(pos->frag_off == pos->bytes_msg))
client_send_response (pos);
return;
+
case PMT_DV_BOX:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Completed transmission of message %llu (DV Box)\n",
unsigned int n_acks;
(void) cls;
- n_acks = (ntohs (ra->header.size) - sizeof (*ra)) /
- sizeof (struct TransportCummulativeAckPayloadP);
+ n_acks = (ntohs (ra->header.size) - sizeof(*ra))
+ / sizeof(struct TransportCummulativeAckPayloadP);
if (0 == n_acks)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if ((ntohs (ra->header.size) - sizeof (*ra)) !=
- n_acks * sizeof (struct TransportCummulativeAckPayloadP))
+ if ((ntohs (ra->header.size) - sizeof(*ra)) !=
+ n_acks * sizeof(struct TransportCummulativeAckPayloadP))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
{
struct CommunicatorMessageContext *cmc = cls;
const struct TransportCummulativeAckPayloadP *ack;
- struct PendingAcknowledgement *pa;
unsigned int n_acks;
uint32_t ack_counter;
- n_acks = (ntohs (ra->header.size) - sizeof (*ra)) /
- sizeof (struct TransportCummulativeAckPayloadP);
+ n_acks = (ntohs (ra->header.size) - sizeof(*ra))
+ / sizeof(struct TransportCummulativeAckPayloadP);
ack = (const struct TransportCummulativeAckPayloadP *) &ra[1];
for (unsigned int i = 0; i < n_acks; i++)
{
- pa =
- GNUNET_CONTAINER_multishortmap_get (pending_acks, &ack[i].ack_uuid.value);
+ struct PendingAcknowledgement *pa =
+ GNUNET_CONTAINER_multiuuidmap_get (pending_acks, &ack[i].ack_uuid.value);
if (NULL == pa)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received ACK from %s with UUID %s which is unknown to us!\n",
GNUNET_i2s (&cmc->im.sender),
- GNUNET_sh2s (&ack[i].ack_uuid.value));
+ GNUNET_uuid2s (&ack[i].ack_uuid.value));
GNUNET_STATISTICS_update (
GST_stats,
"# FRAGMENT_ACKS dropped, no matching pending message",
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received ACK from %s with UUID %s\n",
GNUNET_i2s (&cmc->im.sender),
- GNUNET_sh2s (&ack[i].ack_uuid.value));
+ GNUNET_uuid2s (&ack[i].ack_uuid.value));
handle_acknowledged (pa, GNUNET_TIME_relative_ntoh (ack[i].ack_delay));
}
ack_counter = htonl (ra->ack_counter);
- (void) ack_counter; /* silence compiler warning for now */
+ (void) ack_counter; /* silence compiler warning for now */
// FIXME-OPTIMIZE: track ACK losses based on ack_counter somewhere!
// (DV and/or Neighbour?)
finish_cmc_handling (cmc);
void *cls,
const struct TransportBackchannelEncapsulationMessage *be)
{
- uint16_t size = ntohs (be->header.size) - sizeof (*be);
+ uint16_t size = ntohs (be->header.size) - sizeof(*be);
const struct GNUNET_MessageHeader *inbox =
(const struct GNUNET_MessageHeader *) &be[1];
const char *is;
if (last_timeout.rel_value_us <
GNUNET_TIME_relative_subtract (DV_PATH_VALIDITY_TIMEOUT,
DV_PATH_DISCOVERY_FREQUENCY)
- .rel_value_us)
+ .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! */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Discovered new DV path to %s\n",
GNUNET_i2s (&dv->target));
- hop = GNUNET_malloc (sizeof (struct DistanceVectorHop) +
- sizeof (struct GNUNET_PeerIdentity) * (path_len - 2));
+ hop = GNUNET_malloc (sizeof(struct DistanceVectorHop)
+ + sizeof(struct GNUNET_PeerIdentity) * (path_len - 2));
hop->next_hop = next_hop;
hop->dv = dv;
hop->path = (const struct GNUNET_PeerIdentity *) &hop[1];
memcpy (&hop[1],
&path[2],
- sizeof (struct GNUNET_PeerIdentity) * (path_len - 2));
+ sizeof(struct GNUNET_PeerIdentity) * (path_len - 2));
hop->timeout = GNUNET_TIME_relative_to_absolute (DV_PATH_VALIDITY_TIMEOUT);
hop->path_valid_until = path_valid_until;
hop->distance = path_len - 2;
const struct DVPathEntryP *hops = (const struct DVPathEntryP *) &dvl[1];
(void) cls;
- if (size != sizeof (*dvl) + num_hops * sizeof (struct DVPathEntryP))
+ if (size != sizeof(*dvl) + num_hops * sizeof(struct DVPathEntryP))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
struct GNUNET_TIME_Absolute in_time)
{
struct DVPathEntryP *dhops;
- char buf[sizeof (struct TransportDVLearnMessage) +
- (nhops + 1) * sizeof (struct DVPathEntryP)] GNUNET_ALIGN;
+ char buf[sizeof(struct TransportDVLearnMessage)
+ + (nhops + 1) * sizeof(struct DVPathEntryP)] GNUNET_ALIGN;
struct TransportDVLearnMessage *fwd = (struct TransportDVLearnMessage *) buf;
struct GNUNET_TIME_Relative nnd;
GNUNET_i2s2 (next_hop));
GNUNET_assert (nhops < MAX_DV_HOPS_ALLOWED);
fwd->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN);
- fwd->header.size = htons (sizeof (struct TransportDVLearnMessage) +
- (nhops + 1) * sizeof (struct DVPathEntryP));
+ fwd->header.size = htons (sizeof(struct TransportDVLearnMessage)
+ + (nhops + 1) * sizeof(struct DVPathEntryP));
fwd->num_hops = htons (nhops + 1);
fwd->bidirectional = htons (bi_history);
nnd = GNUNET_TIME_relative_add (GNUNET_TIME_absolute_get_duration (in_time),
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));
+ GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &dhp,
+ &dhops[nhops].hop_sig);
}
route_control_message_without_fc (next_hop,
&fwd->header,
const struct ChallengeNonceP *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)),
- .monotonic_time = sender_monotonic_time,
- .challenge = *challenge};
+ struct DvInitPS ip = { .purpose.purpose = htonl (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
+ .purpose.size = htonl (sizeof(ip)),
+ .monotonic_time = sender_monotonic_time,
+ .challenge = *challenge };
if (
GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR,
- &ip.purpose,
+ &ip,
init_sig,
&init->public_key))
{
return GNUNET_YES; /* skip initiator */
for (unsigned int i = 0; i < nsc->nhops; i++)
if (0 == GNUNET_memcmp (pid, &nsc->hops[i].hop))
- return GNUNET_YES; /* skip peers on path */
+ return GNUNET_YES;
+ /* skip peers on path */
nsc->num_eligible++;
return GNUNET_YES;
}
return GNUNET_YES; /* skip initiator */
for (unsigned int i = 0; i < nsc->nhops; i++)
if (0 == GNUNET_memcmp (pid, &nsc->hops[i].hop))
- return GNUNET_YES; /* skip peers on path */
+ return GNUNET_YES;
+ /* skip peers on path */
for (unsigned int i = 0; i < nsc->num_selections; i++)
{
if (nsc->selections[i] == nsc->num_eligible)
if (hops_taken >= 64)
{
GNUNET_break (0);
- return 0; /* precaution given bitshift below */
+ return 0; /* precaution given bitshift below */
}
for (unsigned int i = 1; i < hops_taken; i++)
{
struct GNUNET_TIME_Absolute in_time;
struct Neighbour *n;
- nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */
+ nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */
bi_history = ntohs (dvl->bidirectional);
hops = (const struct DVPathEntryP *) &dvl[1];
if (0 == nhops)
&dvl->initiator,
GNUNET_PEERSTORE_TRANSPORT_DVLEARN_MONOTIME,
&dvl->monotonic_time,
- sizeof (dvl->monotonic_time),
+ sizeof(dvl->monotonic_time),
GNUNET_TIME_UNIT_FOREVER_ABS,
GNUNET_PEERSTORE_STOREOPTION_REPLACE,
&neighbour_store_dvmono_cb,
If signature verification load too high, implement random drop strategy */
for (unsigned int i = 0; i < nhops; i++)
{
- struct DvHopPS dhp = {.purpose.purpose =
- htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
- .purpose.size = htonl (sizeof (dhp)),
- .pred = (0 == i) ? dvl->initiator : hops[i - 1].hop,
- .succ = (nhops == i + 1) ? GST_my_identity
- : hops[i + 1].hop,
- .challenge = dvl->challenge};
+ struct DvHopPS dhp = { .purpose.purpose =
+ htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
+ .purpose.size = htonl (sizeof(dhp)),
+ .pred = (0 == i) ? dvl->initiator : hops[i - 1].hop,
+ .succ = (nhops == i + 1) ? GST_my_identity
+ : hops[i + 1].hop,
+ .challenge = dvl->challenge };
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP,
- &dhp.purpose,
+ &dhp,
&hops[i].hop_sig,
&hops[i].hop.public_key))
{
// Need also something to lookup initiation time
// to compute RTT! -> add RTT argument here?
- latency = GNUNET_TIME_UNIT_FOREVER_REL; // FIXME: initialize properly
+ 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);
struct GNUNET_PeerIdentity path[nhops + 2];
path[0] = GST_my_identity;
- path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */
+ path[1] = hops[nhops - 1].hop; /* direct neighbour == predecessor! */
for (unsigned int i = 0; i < nhops; i++)
{
int iret;
if (0 == (bi_history & (1 << i)))
- break; /* i-th hop not bi-directional, stop learning! */
- if (i == nhops)
+ break; /* i-th hop not bi-directional, stop learning! */
+ if (i == nhops - 1)
{
path[i + 2] = dvl->initiator;
}
&dv_neighbour_selection,
&nsc);
if (0 == nsc.num_eligible)
- return; /* done here, cannot forward to anyone else */
+ return; /* done here, cannot forward to anyone else */
nsc.num_selections = calculate_fork_degree (nhops, n_cnt, nsc.num_eligible);
nsc.num_selections =
GNUNET_MIN (MAX_DV_DISCOVERY_SELECTION, nsc.num_selections);
for (unsigned int i = 0; i < nsc.num_selections; i++)
nsc.selections[i] =
(nsc.num_selections == n_cnt)
- ? i /* all were selected, avoid collisions by chance */
- : GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, n_cnt);
+ ? i /* all were selected, avoid collisions by chance */
+ : GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, n_cnt);
nsc.num_eligible = 0;
GNUNET_CONTAINER_multipeermap_iterate (neighbours,
&dv_neighbour_transmission,
(const struct GNUNET_PeerIdentity *) &dvb[1];
(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;
struct GNUNET_PeerIdentity *dhops;
GNUNET_assert (NULL != vl);
- msg_size = sizeof (struct TransportDVBoxMessage) +
- num_hops * sizeof (struct GNUNET_PeerIdentity) + enc_payload_size;
- pm = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size);
+ msg_size = sizeof(struct TransportDVBoxMessage)
+ + num_hops * sizeof(struct GNUNET_PeerIdentity) + enc_payload_size;
+ pm = GNUNET_malloc (sizeof(struct PendingMessage) + msg_size);
pm->pmt = PMT_DV_BOX;
pm->vl = vl;
pm->timeout = GNUNET_TIME_relative_to_absolute (DV_FORWARD_TIMEOUT);
pm->prefs = GNUNET_MQ_PRIO_BACKGROUND;
pm->bytes_msg = msg_size;
buf = (char *) &pm[1];
- memcpy (buf, hdr, sizeof (*hdr));
+ memcpy (buf, hdr, sizeof(*hdr));
dhops =
- (struct GNUNET_PeerIdentity *) &buf[sizeof (struct TransportDVBoxMessage)];
- memcpy (dhops, hops, num_hops * sizeof (struct GNUNET_PeerIdentity));
+ (struct GNUNET_PeerIdentity *) &buf[sizeof(struct TransportDVBoxMessage)];
+ memcpy (dhops, hops, num_hops * sizeof(struct GNUNET_PeerIdentity));
memcpy (&dhops[num_hops], enc_payload, enc_payload_size);
GNUNET_CONTAINER_MDLL_insert (vl,
vl->pending_msg_head,
b->cmc = NULL;
return;
}
- if (sizeof (*mtbe) != record->value_size)
+ if (sizeof(*mtbe) != record->value_size)
{
GNUNET_break (0);
return;
&b->pid,
GNUNET_PEERSTORE_TRANSPORT_BACKCHANNEL_MONOTIME,
&mtbe,
- sizeof (mtbe),
+ sizeof(mtbe),
GNUNET_TIME_UNIT_FOREVER_ABS,
GNUNET_PEERSTORE_STOREOPTION_REPLACE,
&backtalker_monotime_store_cb,
handle_dv_box (void *cls, const struct TransportDVBoxMessage *dvb)
{
struct CommunicatorMessageContext *cmc = cls;
- uint16_t size = ntohs (dvb->header.size) - sizeof (*dvb);
+ 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 char *enc_payload = (const char *) &hops[num_hops];
uint16_t enc_payload_size =
- size - (num_hops * sizeof (struct GNUNET_PeerIdentity));
+ size - (num_hops * sizeof(struct GNUNET_PeerIdentity));
struct DVKeyState key;
struct GNUNET_HashCode hmac;
const char *hdr;
forward_dv_box (n,
dvb,
ntohs (dvb->total_hops) + 1,
- num_hops - i - 1, /* number of hops left */
- &hops[i + 1], /* remaining hops */
+ num_hops - i - 1, /* number of hops left */
+ &hops[i + 1], /* remaining hops */
enc_payload,
enc_payload_size);
GNUNET_STATISTICS_update (GST_stats,
dh_key_derive_eph_pub (&dvb->ephemeral_key, &dvb->iv, &key);
hdr = (const char *) &dvb[1];
- hdr_len = ntohs (dvb->header.size) - sizeof (*dvb);
+ hdr_len = ntohs (dvb->header.size) - sizeof(*dvb);
dv_hmac (&key, &hmac, hdr, hdr_len);
if (0 != GNUNET_memcmp (&hmac, &dvb->hmac))
{
struct Backtalker *b;
struct GNUNET_TIME_Absolute monotime;
struct TransportDVBoxPayloadP ppay;
- char body[hdr_len - sizeof (ppay)] GNUNET_ALIGN;
+ char body[hdr_len - sizeof(ppay)] GNUNET_ALIGN;
const struct GNUNET_MessageHeader *mh =
(const struct GNUNET_MessageHeader *) body;
GNUNET_assert (hdr_len >=
- sizeof (ppay) + sizeof (struct GNUNET_MessageHeader));
- dv_decrypt (&key, &ppay, hdr, sizeof (ppay));
- dv_decrypt (&key, &body, &hdr[sizeof (ppay)], hdr_len - sizeof (ppay));
+ sizeof(ppay) + sizeof(struct GNUNET_MessageHeader));
+ dv_decrypt (&key, &ppay, hdr, sizeof(ppay));
+ dv_decrypt (&key, &body, &hdr[sizeof(ppay)], hdr_len - sizeof(ppay));
dv_key_clean (&key);
- if (ntohs (mh->size) != sizeof (body))
+ if (ntohs (mh->size) != sizeof(body))
{
GNUNET_break_op (0);
finish_cmc_handling (cmc);
GNUNET_break_op (0);
finish_cmc_handling (cmc);
return;
+
case GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN:
GNUNET_break_op (0);
finish_cmc_handling (cmc);
return;
+
default:
/* permitted, continue */
break;
struct EphemeralConfirmationPS ec;
ec.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL);
- ec.purpose.size = htonl (sizeof (ec));
+ ec.purpose.size = htonl (sizeof(ec));
ec.target = GST_my_identity;
ec.ephemeral_key = dvb->ephemeral_key;
if (
GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL,
- &ec.purpose,
- &ppay.sender_sig,
- &ppay.sender.public_key))
+ GNUNET_CRYPTO_eddsa_verify (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_EPHEMERAL,
+ &ec,
+ &ppay.sender_sig,
+ &ppay.sender.public_key))
{
/* Signature invalid, disard! */
GNUNET_break_op (0);
}
/* setup data structure to cache signature AND check
monotonic time with PEERSTORE before forwarding backchannel payload */
- b = GNUNET_malloc (sizeof (struct Backtalker) + sizeof (body));
+ b = GNUNET_malloc (sizeof(struct Backtalker) + sizeof(body));
b->pid = ppay.sender;
- b->body_size = sizeof (body);
- memcpy (&b[1], body, sizeof (body));
+ b->body_size = sizeof(body);
+ memcpy (&b[1], body, sizeof(body));
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_put (
backtalkers,
}
-#if 0
-/**
- * We received a @a challenge from another peer, check if we can
- * increase the flow control window to that peer.
- *
- * @param vl virtual link
- * @param challenge the challenge we received
- * @param sender_time when did the peer send the message?
- * @param last_window_consum_limit maximum number of kb the sender
- * promises to use of the previous window (if any)
- */
-static void
-update_fc_window (struct VirtualLink *vl,
- struct GNUNET_TIME_Absolute sender_time,
- uint32_t last_window_consum_limit)
-{
- // FIXME: update to new FC logic
- if (0 == GNUNET_memcmp (challenge, &vl->n_challenge))
- {
- uint32_t avail;
-
- /* Challenge identical to last one, update
- @a last_window_consum_limit (to minimum) */
- vl->last_fc_window_size_remaining =
- GNUNET_MIN (last_window_consum_limit, vl->last_fc_window_size_remaining);
- /* window could have shrunk! */
- if (vl->available_fc_window_size > vl->last_fc_window_size_remaining)
- avail = vl->available_fc_window_size - vl->last_fc_window_size_remaining;
- else
- avail = 0;
- /* guard against integer overflow */
- if (vl->incoming_fc_window_size_used + avail >=
- vl->incoming_fc_window_size_used)
- vl->incoming_fc_window_size = vl->incoming_fc_window_size_used + avail;
- else
- vl->incoming_fc_window_size = UINT32_MAX;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Updated window to %u/%u kb (%u used) for virtual link to %s!\n",
- vl->incoming_fc_window_size,
- vl->available_fc_window_size,
- vl->incoming_fc_window_size_used,
- GNUNET_i2s (&vl->target));
- return;
- }
- if (vl->n_challenge_time.abs_value_us >= sender_time.abs_value_us)
- {
- GNUNET_STATISTICS_update (GST_stats,
- "# Challenges ignored: sender time not increasing",
- 1,
- GNUNET_NO);
- return;
- }
- /* new challenge! */
- if (vl->incoming_fc_window_size_used > last_window_consum_limit)
- {
- /* lying peer: it already used more than it promised it would ever use! */
- GNUNET_break_op (0);
- last_window_consum_limit = vl->incoming_fc_window_size_used;
- }
- /* What remains is at most the difference between what we already processed
- and what the sender promises to limit itself to. */
- vl->last_fc_window_size_remaining =
- last_window_consum_limit - vl->incoming_fc_window_size_used;
- vl->n_challenge = *challenge;
- vl->n_challenge_time = sender_time;
- vl->incoming_fc_window_size_used = 0;
- /* window could have shrunk! */
- if (vl->available_fc_window_size > vl->last_fc_window_size_remaining)
- vl->incoming_fc_window_size =
- vl->available_fc_window_size - vl->last_fc_window_size_remaining;
- else
- vl->incoming_fc_window_size = 0;
- GNUNET_log (
- GNUNET_ERROR_TYPE_DEBUG,
- "New window at %u/%u kb (%u left on previous) for virtual link to %s!\n",
- vl->incoming_fc_window_size,
- vl->available_fc_window_size,
- vl->last_fc_window_size_remaining,
- GNUNET_i2s (&vl->target));
-}
-#endif
-
-
/**
* Closure for #check_known_address.
*/
{
struct GNUNET_TIME_Absolute now;
struct ValidationState *vs;
- struct CheckKnownAddressContext ckac = {.address = address, .vs = NULL};
+ struct CheckKnownAddressContext ckac = { .address = address, .vs = NULL };
(void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
pid,
/* 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));
+ GNUNET_TIME_relative_divide (
+ vs->challenge_backoff,
+ 2));
update_next_challenge_time (vs,
GNUNET_TIME_relative_to_absolute (
vs->challenge_backoff));
vs->validation_rtt = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&vs->challenge,
- sizeof (vs->challenge));
+ sizeof(vs->challenge));
vs->address = GNUNET_strdup (address);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting address validation `%s' of peer %s using challenge %s\n",
we will always give a window size of zero. */
tvr.header.type =
htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE);
- tvr.header.size = htons (sizeof (tvr));
+ tvr.header.size = htons (sizeof(tvr));
tvr.reserved = htonl (0);
tvr.challenge = tvc->challenge;
tvr.origin_time = tvc->sender_time;
tvr.validity_duration = validity_duration;
{
/* create signature */
- struct TransportValidationPS tvp =
- {.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
- .purpose.size = htonl (sizeof (tvp)),
- .validity_duration = validity_duration,
- .challenge = tvc->challenge};
+ struct TransportValidationPS tvp = {
+ .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE),
+ .purpose.size = htonl (sizeof(tvp)),
+ .validity_duration = validity_duration,
+ .challenge = tvc->challenge
+ };
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
- &tvp.purpose,
- &tvr.signature));
+ GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &tvp,
+ &tvr.signature);
}
route_control_message_without_fc (&cmc->im.sender,
&tvr.header,
we could use */
for (ir = ir_head; NULL != ir; ir = ir->next)
if (0 == GNUNET_memcmp (&ir->pid, &sender))
- return; /* we are already trying */
+ return;
+ /* we are already trying */
ir = GNUNET_new (struct IncomingRequest);
ir->pid = sender;
GNUNET_CONTAINER_DLL_insert (ir_head, ir_tail, ir);
{
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 Neighbour *n;
{
/* 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};
+ 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,
+ &tvp,
&tvr->signature,
&cmc->im.sender.public_key))
{
vs->challenge_backoff = GNUNET_TIME_UNIT_ZERO;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&vs->challenge,
- sizeof (vs->challenge));
+ sizeof(vs->challenge));
vs->first_challenge_use = GNUNET_TIME_absolute_subtract (
vs->validated_until,
GNUNET_TIME_relative_multiply (vs->validation_rtt,
n->vl = vl;
vl->core_recv_window = RECV_WINDOW_SIZE;
vl->available_fc_window_size = DEFAULT_WINDOW_SIZE;
- vl->my_challenge = tvr->challenge;
vl->visibility_task =
GNUNET_SCHEDULER_add_at (q->validated_until, &check_link_down, vl);
GNUNET_break (GNUNET_YES ==
(unsigned long long) vl->outbound_fc_window_size,
(long long) vl->incoming_fc_window_size_loss);
wnd = GNUNET_ntohll (fc->outbound_window_size);
- if (wnd < vl->incoming_fc_window_size)
+ if ((wnd < vl->incoming_fc_window_size) ||
+ (vl->last_outbound_window_size_received != wnd) ||
+ (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)
+ % FC_NO_CHANGE_REPLY_PROBABILITY))
{
/* Consider re-sending our FC message, as clearly the
other peer's idea of the window is not up-to-date */
consider_sending_fc (vl);
}
+ if ((wnd == vl->incoming_fc_window_size) &&
+ (vl->last_outbound_window_size_received == wnd) &&
+ (NULL != vl->fc_retransmit_task))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stopping FC retransmission to %s: peer is current at window %llu\n",
+ GNUNET_i2s (&vl->target),
+ (unsigned long long) wnd);
+ GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task);
+ vl->fc_retransmit_task = NULL;
+ }
+ vl->last_outbound_window_size_received = wnd;
/* FC window likely increased, check transmission possibilities! */
check_vl_transmission (vl);
finish_cmc_handling (cmc);
const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_MQ_MessageHandler handlers[] =
- {GNUNET_MQ_hd_var_size (fragment_box,
- GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT,
- struct TransportFragmentBoxMessage,
- &cmc),
- GNUNET_MQ_hd_var_size (reliability_box,
- GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX,
- struct TransportReliabilityBoxMessage,
- &cmc),
- GNUNET_MQ_hd_var_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 TransportDVLearnMessage,
- &cmc),
- GNUNET_MQ_hd_var_size (dv_box,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX,
- struct TransportDVBoxMessage,
- &cmc),
- GNUNET_MQ_hd_fixed_size (
- validation_challenge,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE,
- struct TransportValidationChallengeMessage,
- &cmc),
- GNUNET_MQ_hd_fixed_size (flow_control,
- GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL,
- struct TransportFlowControlMessage,
- &cmc),
- GNUNET_MQ_hd_fixed_size (
- validation_response,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE,
- struct TransportValidationResponseMessage,
- &cmc),
- GNUNET_MQ_handler_end ()};
+ { GNUNET_MQ_hd_var_size (fragment_box,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT,
+ struct TransportFragmentBoxMessage,
+ &cmc),
+ GNUNET_MQ_hd_var_size (reliability_box,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX,
+ struct TransportReliabilityBoxMessage,
+ &cmc),
+ GNUNET_MQ_hd_var_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 TransportDVLearnMessage,
+ &cmc),
+ GNUNET_MQ_hd_var_size (dv_box,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX,
+ struct TransportDVBoxMessage,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (
+ validation_challenge,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE,
+ struct TransportValidationChallengeMessage,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (flow_control,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL,
+ struct TransportFlowControlMessage,
+ &cmc),
+ GNUNET_MQ_hd_fixed_size (
+ validation_response,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE,
+ struct TransportValidationResponseMessage,
+ &cmc),
+ GNUNET_MQ_handler_end () };
int ret;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
{
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&pa->ack_uuid,
- sizeof (pa->ack_uuid));
- } while (GNUNET_YES != GNUNET_CONTAINER_multishortmap_put (
- pending_acks,
- &pa->ack_uuid.value,
- pa,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ sizeof(pa->ack_uuid));
+ }
+ while (GNUNET_YES != GNUNET_CONTAINER_multiuuidmap_put (
+ pending_acks,
+ &pa->ack_uuid.value,
+ pa,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
GNUNET_CONTAINER_MDLL_insert (queue, queue->pa_head, queue->pa_tail, pa);
GNUNET_CONTAINER_MDLL_insert (pm, pm->pa_head, pm->pa_tail, pa);
if (NULL != dvh)
pa->message_size = pm->bytes_msg;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Waiting for ACKnowledgment `%s' for <%llu>\n",
- GNUNET_sh2s (&pa->ack_uuid.value),
+ GNUNET_uuid2s (&pa->ack_uuid.value),
pm->logging_uuid);
return pa;
}
uint16_t mtu;
mtu = (0 == queue->mtu)
- ? UINT16_MAX - sizeof (struct GNUNET_TRANSPORT_SendMessageTo)
- : queue->mtu;
+ ? UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo)
+ : queue->mtu;
set_pending_message_uuid (pm);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Fragmenting message %llu <%llu> to %s for MTU %u\n",
pa = prepare_pending_acknowledgement (queue, dvh, pm);
/* This invariant is established in #handle_add_queue_message() */
- GNUNET_assert (mtu > sizeof (struct TransportFragmentBoxMessage));
+ GNUNET_assert (mtu > sizeof(struct TransportFragmentBoxMessage));
/* 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
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 */
+ ff = ff->head_frag; /* descent into fragmented fragments */
}
if (((ff->bytes_msg > mtu) || (pm == ff)) && (pm->frag_off < pm->bytes_msg))
const struct TransportFragmentBoxMessage *tfbo;
tfbo = (const struct TransportFragmentBoxMessage *) orig;
- orig += sizeof (struct TransportFragmentBoxMessage);
- msize -= sizeof (struct TransportFragmentBoxMessage);
+ orig += sizeof(struct TransportFragmentBoxMessage);
+ msize -= sizeof(struct TransportFragmentBoxMessage);
xoff = ntohs (tfbo->frag_off);
}
- fragmax = mtu - sizeof (struct TransportFragmentBoxMessage);
+ fragmax = mtu - sizeof(struct TransportFragmentBoxMessage);
fragsize = GNUNET_MIN (msize - ff->frag_off, fragmax);
frag =
- GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct TransportFragmentBoxMessage) + fragsize);
+ GNUNET_malloc (sizeof(struct PendingMessage)
+ + sizeof(struct TransportFragmentBoxMessage) + fragsize);
frag->logging_uuid = logging_uuid_gen++;
frag->vl = pm->vl;
frag->frag_parent = ff;
frag->timeout = pm->timeout;
- frag->bytes_msg = sizeof (struct TransportFragmentBoxMessage) + fragsize;
+ frag->bytes_msg = sizeof(struct TransportFragmentBoxMessage) + fragsize;
frag->pmt = PMT_FRAGMENT_BOX;
msg = (char *) &frag[1];
tfb.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT);
tfb.header.size =
- htons (sizeof (struct TransportFragmentBoxMessage) + fragsize);
+ htons (sizeof(struct TransportFragmentBoxMessage) + fragsize);
tfb.ack_uuid = pa->ack_uuid;
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);
+ 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;
if (NULL != pm->bpm)
return pm->bpm; /* already computed earlier: do nothing */
GNUNET_assert (NULL == pm->head_frag);
- if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX)
+ if (pm->bytes_msg + sizeof(rbox) > UINT16_MAX)
{
/* failed hard */
GNUNET_break (0);
queue->address);
pa = prepare_pending_acknowledgement (queue, dvh, pm);
- bpm = GNUNET_malloc (sizeof (struct PendingMessage) + sizeof (rbox) +
- pm->bytes_msg);
+ bpm = GNUNET_malloc (sizeof(struct PendingMessage) + sizeof(rbox)
+ + pm->bytes_msg);
bpm->logging_uuid = logging_uuid_gen++;
bpm->vl = pm->vl;
bpm->frag_parent = pm;
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);
+ bpm->bytes_msg = pm->bytes_msg + sizeof(rbox);
set_pending_message_uuid (bpm);
rbox.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX);
- rbox.header.size = htons (sizeof (rbox) + pm->bytes_msg);
- rbox.ack_countdown = htonl (0); // FIXME: implement ACK countdown support
+ rbox.header.size = htons (sizeof(rbox) + pm->bytes_msg);
+ rbox.ack_countdown = htonl (0); // FIXME: implement ACK countdown support
rbox.ack_uuid = pa->ack_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;
}
int relb;
if ((NULL != dvh) && (PMT_DV_BOX == pos->pmt))
- continue; /* DV messages must not be DV-routed to next hop! */
+ continue; /* DV messages must not be DV-routed to next hop! */
if (pos->next_attempt.abs_value_us > now.abs_value_us)
- break; /* too early for all messages, they are sorted by next_attempt */
+ break; /* too early for all messages, they are sorted by next_attempt */
if (NULL != pos->qe)
- continue; /* not eligible */
+ continue; /* not eligible */
sc->consideration_counter++;
- /* determine if we have to reliability-box, if so add reliability box
- overhead */
- relb = GNUNET_NO;
- if ((GNUNET_NO == frag) &&
- (0 == (pos->prefs & GNUNET_MQ_PREF_UNRELIABLE)) &&
- (GNUNET_TRANSPORT_CC_RELIABLE != queue->tc->details.communicator.cc))
- {
- relb = GNUNET_YES;
- real_overhead += sizeof (struct TransportReliabilityBoxMessage);
- }
/* determine if we have to fragment, if so add fragmentation
overhead! */
frag = GNUNET_NO;
- if ( ( (0 != queue->mtu) &&
- (pos->bytes_msg + real_overhead > queue->mtu) ) ||
- (pos->bytes_msg > UINT16_MAX - sizeof (struct GNUNET_TRANSPORT_SendMessageTo)) ||
- (NULL != pos->head_frag /* fragments already exist, should
- respect that even if MTU is 0 for
- this queue */) )
+ if (((0 != queue->mtu) &&
+ (pos->bytes_msg + real_overhead > queue->mtu)) ||
+ (pos->bytes_msg > UINT16_MAX - sizeof(struct
+ GNUNET_TRANSPORT_SendMessageTo))
+ ||
+ (NULL != pos->head_frag /* fragments already exist, should
+ respect that even if MTU is 0 for
+ this queue */))
{
frag = GNUNET_YES;
- relb = GNUNET_NO; /* if we fragment, we never also reliability box */
if (GNUNET_TRANSPORT_CC_RELIABLE == queue->tc->details.communicator.cc)
{
- /* FIXME-OPTIMIZE: we could use an optimized, shorter fragmentation
+ /* FIXME-FRAG-REL-UUID: we could use an optimized, shorter fragmentation
header without the ACK UUID when using a *reliable* channel! */
}
- real_overhead = overhead + sizeof (struct TransportFragmentBoxMessage);
+ real_overhead = overhead + sizeof(struct TransportFragmentBoxMessage);
+ }
+ /* determine if we have to reliability-box, if so add reliability box
+ overhead */
+ relb = GNUNET_NO;
+ if ((GNUNET_NO == frag) &&
+ (0 == (pos->prefs & GNUNET_MQ_PREF_UNRELIABLE)) &&
+ (GNUNET_TRANSPORT_CC_RELIABLE != queue->tc->details.communicator.cc))
+ {
+ relb = GNUNET_YES;
+ real_overhead += sizeof(struct TransportReliabilityBoxMessage);
}
/* Finally, compare to existing 'best' in sc to see if this 'pos' pending
given message fits _this_ queue, and do not consider how well other
queues might suit the message. Taking other queues into consideration
may further improve the result, but could also be expensive
- in terms of CPU time. */
- long long sc_score = sc->frag * 40 + sc->relb * 20 + sc->real_overhead;
+ in terms of CPU time. */long long sc_score = sc->frag * 40 + sc->relb * 20 + sc->real_overhead;
long long pm_score = frag * 40 + relb * 20 + real_overhead;
long long time_delta =
- (sc->best->next_attempt.abs_value_us - pos->next_attempt.abs_value_us) /
- 1000LL;
+ (sc->best->next_attempt.abs_value_us - pos->next_attempt.abs_value_us)
+ / 1000LL;
/* "time_delta" considers which message has been 'ready' for transmission
for longer, if a message has a preference for low latency, increase
the weight of the time_delta by 10x if it is favorable for that message */
if ((0 != (pos->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) &&
(0 != (sc->best->prefs & GNUNET_MQ_PREF_LOW_LATENCY)))
- time_delta *= 10; /* increase weight (always, both are low latency) */
+ time_delta *= 10; /* increase weight (always, both are low latency) */
else if ((0 != (pos->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) &&
(time_delta > 0))
time_delta *=
- 10; /* increase weight, favors 'pos', which is low latency */
+ 10; /* increase weight, favors 'pos', which is low latency */
else if ((0 != (sc->best->prefs & GNUNET_MQ_PREF_LOW_LATENCY)) &&
(time_delta < 0))
time_delta *=
- 10; /* increase weight, favors 'sc->best', which is low latency */
+ 10; /* increase weight, favors 'sc->best', which is low latency */
if (0 != queue->mtu)
{
/* Grant bonus if we are bellow MTU, larger bonus the closer we will
pm_score -= queue->mtu - (real_overhead + pos->bytes_msg);
}
if (sc_score + time_delta > pm_score)
- continue; /* sc_score larger, keep sc->best */
+ continue; /* sc_score larger, keep sc->best */
}
sc->best = pos;
sc->dvh = dvh;
uint16_t bsize = ntohs (hdr->size);
GNUNET_assert (NULL == pm->bpm);
- bpm = GNUNET_malloc (sizeof (struct PendingMessage) + bsize);
+ bpm = GNUNET_malloc (sizeof(struct PendingMessage) + bsize);
bpm->logging_uuid = logging_uuid_gen++;
bpm->pmt = PMT_DV_BOX;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
queue->idle = GNUNET_YES;
return;
}
- memset (&sc, 0, sizeof (sc));
+ memset (&sc, 0, sizeof(sc));
select_best_pending_from_link (&sc, queue, n->vl, NULL, 0);
if (NULL == sc.best)
{
queue,
dvh->dv->vl,
dvh,
- sizeof (struct GNUNET_PeerIdentity) *
- (1 + dvh->distance) +
- sizeof (struct TransportDVBoxMessage) +
- sizeof (struct TransportDVBoxPayloadP));
+ sizeof(struct GNUNET_PeerIdentity)
+ * (1 + dvh->distance)
+ + sizeof(struct TransportDVBoxMessage)
+ + sizeof(struct TransportDVBoxPayloadP));
}
}
if (NULL == sc.best)
"Fragmentation failed queue %s to %s for <%llu>, trying again\n",
queue->address,
GNUNET_i2s (&n->pid),
- pm->logging_uuid);
+ sc.best->logging_uuid);
schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
+ return;
}
}
else if (GNUNET_YES == sc.relb)
"Reliability boxing failed queue %s to %s for <%llu>, trying again\n",
queue->address,
GNUNET_i2s (&n->pid),
- pm->logging_uuid);
+ sc.best->logging_uuid);
schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
return;
}
via DV (and thus the ultimate target of the pending message is for
a different virtual link than the one of the queue), then we need
to use up not only the window of the direct link but also the
- flow control window for the DV link! */
- pm->vl->outbound_fc_window_size_used += pm->bytes_msg;
+ flow control window for the DV link! */pm->vl->outbound_fc_window_size_used += pm->bytes_msg;
if (pm->vl != queue->neighbour->vl)
{
OPTIMIZE: Note that in the future this heuristic should likely
be improved further (measure RTT stability, consider message
- urgency and size when delaying ACKs, etc.) */
- update_pm_next_attempt (pm,
+ urgency and size when delaying ACKs, etc.) */update_pm_next_attempt (pm,
GNUNET_TIME_relative_to_absolute (
GNUNET_TIME_relative_multiply (queue->pd.aged_rtt,
4)));
for (struct Queue *q = neighbour->queue_head; NULL != q;
q = q->next_neighbour)
{
- struct MonitorEvent me = {.rtt = q->pd.aged_rtt,
- .cs = q->cs,
- .num_msg_pending = q->num_msg_pending,
- .num_bytes_pending = q->num_bytes_pending};
+ struct MonitorEvent me = { .rtt = q->pd.aged_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);
}
prefix = GNUNET_HELLO_address_to_prefix (address);
if (NULL == prefix)
{
- GNUNET_break (0); /* We got an invalid address!? */
+ GNUNET_break (0); /* We got an invalid address!? */
return;
}
tc = lookup_communicator (prefix);
vs->last_challenge_use = GNUNET_TIME_absolute_get_monotonic (GST_cfg);
tvc.header.type =
htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
- tvc.header.size = htons (sizeof (tvc));
+ 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);
"Sending address validation challenge %s to %s\n",
GNUNET_sh2s (&tvc.challenge.value),
GNUNET_i2s (&q->neighbour->pid));
- queue_send_msg (q, NULL, &tvc, sizeof (tvc));
+ queue_send_msg (q, NULL, &tvc, sizeof(tvc));
}
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Address validation task not scheduled anymore, nothing to do\n");
- return; /* woopsie, no more addresses known, should only
- happen if we're really a lonely peer */
+ return; /* woopsie, no more addresses known, should only
+ happen if we're really a lonely peer */
}
q = find_queue (&vs->pid, vs->address);
if (NULL == q)
ctx->num_queues++;
if (0 == ctx->k--)
ctx->q = q;
- /* OPTIMIZE-FIXME: in the future, add reliability / goodput
+ /* FIXME-CONQ-STATISTICS: in the future, add reliability / goodput
statistics and consider those as well here? */
if (q->pd.aged_rtt.rel_value_us < DV_QUALITY_RTT_THRESHOLD.rel_value_us)
do_inc = GNUNET_YES;
lle = GNUNET_new (struct LearnLaunchEntry);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&lle->challenge,
- sizeof (lle->challenge));
+ sizeof(lle->challenge));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting launch DV learn with challenge %s\n",
GNUNET_sh2s (&lle->challenge.value));
lle,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
dvl.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN);
- dvl.header.size = htons (sizeof (dvl));
+ 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);
dvl.monotonic_time =
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (GST_cfg));
{
- struct DvInitPS dvip = {.purpose.purpose = htonl (
- GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
- .purpose.size = htonl (sizeof (dvip)),
- .monotonic_time = dvl.monotonic_time,
- .challenge = lle->challenge};
+ struct DvInitPS dvip = {
+ .purpose.purpose = htonl (
+ GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_INITIATOR),
+ .purpose.size = htonl (sizeof(dvip)),
+ .monotonic_time = dvl.monotonic_time,
+ .challenge = lle->challenge
+ };
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
- &dvip.purpose,
- &dvl.init_sig));
+ GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
+ &dvip,
+ &dvl.init_sig);
}
dvl.initiator = GST_my_identity;
dvl.challenge = lle->challenge;
/* 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 (
n->dv_monotime_available = GNUNET_YES;
return;
}
- if (sizeof (*mtbe) != record->value_size)
+ if (sizeof(*mtbe) != record->value_size)
{
GNUNET_break (0);
return;
const char *addr;
uint16_t addr_len;
- if (ntohl (aqm->mtu) <= sizeof (struct TransportFragmentBoxMessage))
+ if (ntohl (aqm->mtu) <= sizeof(struct TransportFragmentBoxMessage))
{
/* MTU so small as to be useless for transmissions,
required for #fragment_message()! */
&neighbour_dv_monotime_cb,
neighbour);
}
- addr_len = ntohs (aqm->header.size) - sizeof (*aqm);
+ addr_len = ntohs (aqm->header.size) - sizeof(*aqm);
addr = (const char *) &aqm[1];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New queue %s to %s available with QID %llu\n",
addr,
GNUNET_i2s (&aqm->receiver),
(unsigned long long) aqm->qid);
- queue = GNUNET_malloc (sizeof (struct Queue) + addr_len);
+ queue = GNUNET_malloc (sizeof(struct Queue) + addr_len);
queue->tc = tc;
queue->address = (const char *) &queue[1];
queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL;
memcpy (&queue[1], addr, addr_len);
/* notify monitors about new queue */
{
- struct MonitorEvent me = {.rtt = queue->pd.aged_rtt, .cs = queue->cs};
+ struct MonitorEvent me = { .rtt = queue->pd.aged_rtt, .cs = queue->cs };
notify_monitors (&neighbour->pid, queue->address, queue->nt, &me);
}
queue);
/* check if valdiations are waiting for the queue */
(void)
- GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
- &aqm->receiver,
- &check_validation_request_pending,
- queue);
+ GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
+ &aqm->receiver,
+ &check_validation_request_pending,
+ queue);
/* look for traffic for this queue */
schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT);
/* might be our first queue, try launching DV learning */
pr->bw = msg->bw;
pr->pk = (enum GNUNET_MQ_PriorityPreferences) ntohl (msg->pk);
if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_put (
- tc->details.application.requests,
- &pr->pid,
- pr,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ tc->details.application.requests,
+ &pr->pid,
+ pr,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
{
GNUNET_break (0);
GNUNET_free (pr);
(void) cls;
(void) pid;
- GNUNET_break (0); // should this ever happen?
+ GNUNET_break (0); // should this ever happen?
free_neighbour (neighbour);
return GNUNET_OK;
* @return #GNUNET_OK (always)
*/
static int
-free_pending_ack_cb (void *cls,
- const struct GNUNET_ShortHashCode *key,
- void *value)
+free_pending_ack_cb (void *cls, const struct GNUNET_Uuid *key, void *value)
{
struct PendingAcknowledgement *pa = value;
do_shutdown (void *cls)
{
struct LearnLaunchEntry *lle;
+
(void) cls;
GNUNET_CONTAINER_multipeermap_iterate (neighbours, &free_neighbour_cb, NULL);
NULL);
GNUNET_CONTAINER_multipeermap_destroy (ack_cummulators);
ack_cummulators = NULL;
- GNUNET_CONTAINER_multishortmap_iterate (pending_acks,
- &free_pending_ack_cb,
- NULL);
- GNUNET_CONTAINER_multishortmap_destroy (pending_acks);
+ GNUNET_CONTAINER_multiuuidmap_iterate (pending_acks,
+ &free_pending_ack_cb,
+ NULL);
+ GNUNET_CONTAINER_multiuuidmap_destroy (pending_acks);
pending_acks = NULL;
GNUNET_break (0 == GNUNET_CONTAINER_multipeermap_size (neighbours));
GNUNET_CONTAINER_multipeermap_destroy (neighbours);
hello_mono_time = GNUNET_TIME_absolute_get_monotonic (c);
GST_cfg = c;
backtalkers = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
- pending_acks = GNUNET_CONTAINER_multishortmap_create (32768, GNUNET_YES);
+ pending_acks = GNUNET_CONTAINER_multiuuidmap_create (32768, GNUNET_YES);
ack_cummulators = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_YES);
neighbours = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES);
links = GNUNET_CONTAINER_multipeermap_create (512, GNUNET_YES);