#define VERBOSE GNUNET_NO
+#define ATS_BLOCKING_DELTA GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100)
+
enum ATS_Mode
{
/*
memcpy (&aa[1], plugin_addr, plugin_addr_len);
aa->plugin = GNUNET_strdup (plugin_name);
aa->session_id = session_id;
- aa->mlp_information = NULL;
- aa->next = NULL;
- aa->prev = NULL;
return aa;
}
aa->ats_count = atsi_count;
memcpy (aa->ats, atsi, atsi_count * sizeof (struct GNUNET_ATS_Information));
-#if DEBUG_ATS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' %u\n",
GNUNET_i2s (peer),
session_id);
-#endif
+
/* Get existing address or address with session == 0 */
old = find_address (peer, aa);
if (old == NULL)
(aa->addr_len == info->addr_len) &&
(0 == memcmp (info->addr, aa->addr, aa->addr_len)))
{
-#if VERBOSE
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Deleting address for peer `%s': `%s' %u\n",
GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
-#endif
+
if (GNUNET_YES == destroy_address (aa))
recalculate_assigned_bw ();
return GNUNET_OK;
struct ATS_Address **ap = cls;
struct ATS_Address *aa = (struct ATS_Address *) value;
struct ATS_Address *ab = *ap;
+ struct GNUNET_TIME_Absolute now;
+
+ now = GNUNET_TIME_absolute_get();
+
+ if (aa->blocked_until.abs_value == GNUNET_TIME_absolute_max (now, aa->blocked_until).abs_value)
+ {
+ /* This address is blocked for suggestion */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Address %p blocked for suggestion for %llu ms \n",
+ aa,
+ GNUNET_TIME_absolute_get_difference(now, aa->blocked_until).rel_value);
+ return GNUNET_OK;
+ }
+
+ aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval, ATS_BLOCKING_DELTA);
+ aa->blocked_until = GNUNET_TIME_absolute_add (now, aa->block_interval);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Address %p ready for suggestion, block interval now %llu \n", aa, aa->block_interval);
+
+ /* FIXME this is a hack */
+
+
+ if (NULL != ab)
+ {
+ if ((0 == strcmp (ab->plugin, "tcp")) &&
+ (0 == strcmp (aa->plugin, "tcp")))
+ {
+ if ((0 != ab->addr_len) &&
+ (0 == aa->addr_len))
+ {
+ /* saved address was an outbound address, but we have an inbound address */
+ *ap = aa;
+ return GNUNET_OK;
+ }
+ if (0 == ab->addr_len)
+ {
+ /* saved address was an inbound address, so do not overwrite */
+ return GNUNET_OK;
+ }
+ }
+ }
+ /* FIXME end of hack */
if (NULL == ab)
{
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+ "Suggesting address %p for peer `%s'\n", aa, GNUNET_i2s (peer));
+
if (aa->active == GNUNET_NO)
{
aa->active = GNUNET_YES;
}
+static int
+reset_address_it (void *cls, const GNUNET_HashCode * key, void *value)
+{
+ struct ATS_Address *aa = value;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Resetting interval for peer `%s' address %p from %llu to 0\n", GNUNET_i2s (&aa->peer), aa, aa->block_interval);
+
+ aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS;
+ aa->block_interval = GNUNET_TIME_UNIT_ZERO;
+ return GNUNET_OK;
+}
+
+void
+GAS_addresses_handle_backoff_reset (const struct GNUNET_PeerIdentity *peer)
+{
+ GNUNET_break (GNUNET_SYSERR != GNUNET_CONTAINER_multihashmap_get_multiple (addresses,
+ &peer->hashPubKey,
+ &reset_address_it,
+ NULL));
+}
+
+
+
// FIXME: this function should likely end up in the LP-subsystem and
// not with 'addresses' in the future...
void
void
GAS_addresses_done ()
{
- running = GNUNET_NO;
GAS_addresses_destroy_all ();
+ running = GNUNET_NO;
GNUNET_CONTAINER_multihashmap_destroy (addresses);
addresses = NULL;
#if HAVE_LIBGLPK