res ++;
break;
case GNUNET_ATS_QUALITY_NET_DISTANCE:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Old ATS type %u %u\n", dest->atsp_distance, ntohl (src[i].type));
dest->atsp_distance = ntohl (src[i].value);
res ++;
break;
plugin_name,
plugin_addr, plugin_addr_len,
session_id);
- aa->solver_information = NULL;
if (atsi_count != (ats_res = disassemble_ats_information(atsi, atsi_count, aa)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' session id %u, %p\n",
GNUNET_i2s (peer), session_id, aa);
- /* Tell solver about update */
+ /* Tell solver about new address */
handle->s_add (handle->solver, handle->addresses, aa);
return;
}
+ GNUNET_free (aa->plugin);
+ GNUNET_free (aa);
if (old->session_id != 0)
{
"While updating address: had %u ATS elements to add, could only add %u\n",
atsi_count, ats_res);
}
- GNUNET_free (aa->plugin);
- GNUNET_free (aa);
- handle->s_add (handle->solver, handle->addresses, old);
+
+ handle->s_update (handle->solver, handle->addresses, old);
}
const struct GNUNET_ATS_Information *atsi,
uint32_t atsi_count)
{
- struct ATS_Address *old;
+ struct ATS_Address *aa;
uint32_t ats_res;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' for peer `%s'\n",
- "ADDRESS UPDATE",
- GNUNET_i2s (peer));
-
if (GNUNET_NO == handle->running)
return;
GNUNET_assert (NULL != handle->addresses);
/* Get existing address */
- old = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len,
+ aa = lookup_address (peer, plugin_name, plugin_addr, plugin_addr_len,
session_id, atsi, atsi_count);
- if (old == NULL)
+ if (aa == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Tried to update unknown address for peer `%s' `%s' session id %u\n",
GNUNET_i2s (peer), plugin_name, session_id);
return;
}
- if (atsi_count != (ats_res = disassemble_ats_information (atsi, atsi_count, old)))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' for peer `%s' address \n",
+ "ADDRESS UPDATE",
+ GNUNET_i2s (peer), aa);
+
+ if (atsi_count != (ats_res = disassemble_ats_information (atsi, atsi_count, aa)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"While adding address: had %u ATS elements to add, could only add %u\n",
atsi_count, ats_res);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Updated %u ATS elements for address %p\n",
+ ats_res, aa);
/* Tell solver about update */
- handle->s_update (handle->solver, handle->addresses, old);
+ handle->s_update (handle->solver, handle->addresses, aa);
}
* QUOTA_PER_ADDRESS = LAN_TOTAL_OUT / x
*
* Quotas are automatically recalculated and reported back when addresses are
- * added, updated or deleted and can be requested using "get_prefered_address".
+ * - requested
*
*/
*/
unsigned int active_addresses;
+ /**
+ * Number of total addresses for this network
+ */
+ unsigned int total_addresses;
+
struct AddressWrapper *head;
struct AddressWrapper *tail;
};
for (c = 0; c < dest_length; c++)
{
cur = &s->network_entries[c];
+ cur->total_addresses = 0;
cur->active_addresses = 0;
cur->type = network[c];
cur->total_quota_in = in_quota[c];
GNUNET_free (s);
}
+/**
+ * Update the quotas for a network type
+ *
+ * @param network the network type to update
+ * @param address_except address excluded from notifcation, since we suggest
+ * this address
+ */
+
static void
-update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s, struct Network *net)
+update_quota_per_network (struct GAS_SIMPLISTIC_Handle *s,
+ struct Network *net,
+ struct ATS_Address *address_except)
{
unsigned long long quota_in;
unsigned long long quota_out;
struct AddressWrapper *cur;
+ if (net->active_addresses == 0)
+ return; /* no addresses to update */
+
quota_in = net->total_quota_in / net->active_addresses;
quota_out = net->total_quota_out / net->active_addresses;
cur->addr->assigned_bw_in.value__ = htonl (quota_in);
cur->addr->assigned_bw_out.value__ = htonl (quota_out);
/* Notify on change */
- if (GNUNET_YES == cur->addr->active)
+ if ((GNUNET_YES == cur->addr->active) && (cur->addr != address_except))
s->bw_changed (cur->addr);
}
cur = cur->next;
aw = GNUNET_malloc (sizeof (struct AddressWrapper));
aw->addr = address;
GNUNET_CONTAINER_DLL_insert (cur->head, cur->tail, aw);
- cur->active_addresses ++;
+ cur->total_addresses ++;
aw->addr->solver_information = cur;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Adding new address for network type `%s' (now %u total)\n",
cur->desc,
cur->active_addresses);
-
- /* Update quota for this network type */
- update_quota_per_network (s, cur);
}
prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
s->bw_changed (prev); /* notify about bw change, REQUIERED? */
net_cur->active_addresses --;
- update_quota_per_network (s, net_prev);
+ update_quota_per_network (s, net_prev, NULL);
}
cur->active = GNUNET_YES;
net_cur->active_addresses ++;
- update_quota_per_network (s, net_cur);
+ update_quota_per_network (s, net_cur, cur);
return cur;
}
/**
* Test ats info
*/
-struct GNUNET_ATS_Information test_ats_info[2];
+struct GNUNET_ATS_Information test_ats_info[3];
/**
* Test ats count
/* Update address */
/* Prepare ATS Information */
test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
- test_ats_info[0].value = htonl(GNUNET_ATS_NET_LAN);
+ test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
test_ats_info[1].value = htonl(3);
+ test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
+ test_ats_info[1].value = htonl(30);
test_ats_count = 2;
GNUNET_ATS_address_update (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
test_ats_info[1].value = htonl(1);
+ test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
+ test_ats_info[1].value = htonl(10);
test_ats_count = 2;
/* Adding address without session */