summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-08 15:56:44 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-08 15:56:44 +0000
commit226ee707da1f1d38570fc4fa2afe7c0cdf6851e9 (patch)
tree52703b9c161b245ad12cc1b23c372ef4a2b962f3
parent49ecfcfe408b62f96213e1271d036a116f95cd3c (diff)
finishing implementation of #3652
-rw-r--r--src/core/gnunet-service-core_kx.c27
-rw-r--r--src/core/gnunet-service-core_sessions.c14
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c40
3 files changed, 60 insertions, 21 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 4983dab0e..9d8fb415b 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -1095,7 +1095,7 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
GNUNET_NO);
GSC_NEIGHBOURS_transmit (&kx->peer,
&tp.header,
- GNUNET_TIME_UNIT_FOREVER_REL /* FIXME: timeout */ );
+ kx->set_key_retry_frequency);
}
@@ -1378,24 +1378,35 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
ph->iv_seed = calculate_seed (kx);
ph->reserved = 0;
ph->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- memcpy (&ph[1], payload, payload_size);
+ memcpy (&ph[1],
+ payload,
+ payload_size);
em = (struct EncryptedMessage *) cbuf;
em->header.size = htons (used);
em->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE);
em->iv_seed = ph->iv_seed;
- derive_iv (&iv, &kx->encrypt_key, ph->iv_seed, &kx->peer);
+ derive_iv (&iv,
+ &kx->encrypt_key,
+ ph->iv_seed,
+ &kx->peer);
GNUNET_assert (GNUNET_OK ==
- do_encrypt (kx, &iv, &ph->sequence_number,
+ do_encrypt (kx,
+ &iv,
+ &ph->sequence_number,
&em->sequence_number,
used - ENCRYPTED_HEADER_SIZE));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted %u bytes for %s\n",
- used - ENCRYPTED_HEADER_SIZE, GNUNET_i2s (&kx->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Encrypted %u bytes for %s\n",
+ used - ENCRYPTED_HEADER_SIZE,
+ GNUNET_i2s (&kx->peer));
derive_auth_key (&auth_key,
&kx->encrypt_key,
ph->iv_seed);
- GNUNET_CRYPTO_hmac (&auth_key, &em->sequence_number,
- used - ENCRYPTED_HEADER_SIZE, &em->hmac);
+ GNUNET_CRYPTO_hmac (&auth_key,
+ &em->sequence_number,
+ used - ENCRYPTED_HEADER_SIZE,
+ &em->hmac);
GSC_NEIGHBOURS_transmit (&kx->peer,
&em->header,
GNUNET_TIME_UNIT_FOREVER_REL);
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index 289d9468f..a16da8b7e 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -275,10 +275,13 @@ transmit_typemap_task (void *cls,
GNUNET_SCHEDULER_add_delayed (delay,
&transmit_typemap_task, session);
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# type map refreshes sent"), 1,
+ gettext_noop ("# type map refreshes sent"),
+ 1,
GNUNET_NO);
hdr = GSC_TYPEMAP_compute_type_map_message ();
- GSC_KX_encrypt_and_transmit (session->kxinfo, hdr, ntohs (hdr->size));
+ GSC_KX_encrypt_and_transmit (session->kxinfo,
+ hdr,
+ ntohs (hdr->size));
GNUNET_free (hdr);
}
@@ -761,10 +764,13 @@ try_transmission (struct Session *session)
}
GNUNET_STATISTICS_set (GSC_stats,
"# avg payload per encrypted message",
- total_bytes / total_msgs, GNUNET_NO);
+ total_bytes / total_msgs,
+ GNUNET_NO);
/* now actually transmit... */
session->ready_to_transmit = GNUNET_NO;
- GSC_KX_encrypt_and_transmit (session->kxinfo, pbuf, used);
+ GSC_KX_encrypt_and_transmit (session->kxinfo,
+ pbuf,
+ used);
}
}
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index a2aaa19ec..76f8a9984 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -2500,14 +2500,20 @@ try_run_fast_ats_update (const struct GNUNET_HELLO_Address *address,
GST_ats_is_known (n->primary_address.address,
n->primary_address.session));
}
- n->primary_address.bandwidth_in = bandwidth_in;
- n->primary_address.bandwidth_out = bandwidth_out;
- GST_neighbours_set_incoming_quota (&address->peer,
- bandwidth_in);
- bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out,
- n->neighbour_receive_quota);
- send_outbound_quota_to_clients (&address->peer,
- bandwidth_min);
+ if (n->primary_address.bandwidth_in.value__ != bandwidth_in.value__)
+ {
+ n->primary_address.bandwidth_in = bandwidth_in;
+ GST_neighbours_set_incoming_quota (&address->peer,
+ bandwidth_in);
+ }
+ if (n->primary_address.bandwidth_out.value__ != bandwidth_out.value__)
+ {
+ n->primary_address.bandwidth_out = bandwidth_out;
+ bandwidth_min = GNUNET_BANDWIDTH_value_min (bandwidth_out,
+ n->neighbour_receive_quota);
+ send_outbound_quota_to_clients (&address->peer,
+ bandwidth_min);
+ }
return GNUNET_OK;
}
@@ -3569,7 +3575,9 @@ GST_neighbours_test_connected (const struct GNUNET_PeerIdentity *target)
/**
- * Change the incoming quota for the given peer.
+ * Change the incoming quota for the given peer. Updates
+ * our own receive rate and informs the neighbour about
+ * the new quota.
*
* @param neighbour identity of peer to change qutoa for
* @param quota new quota
@@ -3593,7 +3601,21 @@ GST_neighbours_set_incoming_quota (const struct GNUNET_PeerIdentity *neighbour,
ntohl (quota.value__), GNUNET_i2s (&n->id));
GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, quota);
if (0 != ntohl (quota.value__))
+ {
+ struct SessionQuotaMessage sqm;
+
+ sqm.header.size = htons (sizeof (struct SessionQuotaMessage));
+ sqm.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA);
+ sqm.quota = quota.value__;
+ (void) send_with_session (n,
+ &sqm,
+ sizeof (sqm),
+ UINT32_MAX - 1,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_NO,
+ NULL, NULL);
return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Disconnecting peer `%4s' due to SET_QUOTA\n",
GNUNET_i2s (&n->id));