struct Network *net,
struct ATS_Address *address_except)
{
- unsigned long long quota_in;
- unsigned long long quota_out;
+ unsigned long long quota_in = 0;
+ unsigned long long quota_out = 0;
struct AddressWrapper *cur;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n",
+ net->desc, net->active_addresses, quota_in, quota_out);
+
if (net->active_addresses == 0)
return; /* no addresses to update */
{
struct GAS_SIMPLISTIC_Handle *s = solver;
struct Network *net;
+ struct AddressWrapper *aw;
+
/* Remove an adress completely, we have to:
* - Remove from specific network
- * - Decrease number of total addresses */
- net = (struct Network *) address->solver_information;
+ * - Decrease number of total addresses
+ * - If active:
+ * - decrease number of active addreses
+ * - update quotas
+ */
- GNUNET_break (0 < net->total_addresses);
+ net = (struct Network *) address->solver_information;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s address %p for peer `%s' from network `%s' (total: %u/ active: %u)\n",
+ (GNUNET_NO == address->active) ? "inactive" : "active",
+ address, GNUNET_i2s (&address->peer),
+ net->desc, net->total_addresses, net->active_addresses);
+ GNUNET_break (0 < net->total_addresses);
+ net->total_addresses --;
if (GNUNET_YES == address->active)
{
update_quota_per_network (s, net, NULL);
}
+ for (aw = net->head; NULL != aw; aw = aw->next)
+ {
+ if (aw->addr == address)
+ break;
+ }
+ GNUNET_CONTAINER_DLL_remove (net->head, net->tail, aw);
+ GNUNET_free (aw);
+
}
*/
static void *test_session;
+/**
+ * Test ats info
+ */
+struct GNUNET_ATS_Information test_ats_info[2];
+
+/**
+ * Test ats count
+ */
+uint32_t test_ats_count;
+
+
+
static void
create_test_address (struct Test_Address *dest, char * plugin, void *session, void *addr, size_t addrlen)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
GNUNET_i2s_full(&p.id));
+ /* Prepare ATS Information */
+ test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+ 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_count = 2;
+
/* Adding address without session */
test_session = NULL;
create_test_address (&test_addr, "test", test_session, "test", strlen ("test") + 1);
test_hello_address.transport_name = test_addr.plugin;
test_hello_address.address = test_addr.addr;
test_hello_address.address_length = test_addr.addr_len;
- GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, NULL, 0);
+ GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, 2);
/* Request address */
GNUNET_ATS_suggest_address (sched_ats, &p.id);