* on gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex
* use build_txt.sh to generate plaintext output
*
- * ATS addresses : simplistic solver
+ * ATS addresses : proportional solver
*
- * The simplistic solver ("simplistic") distributes the available
+ * The proportional solver ("proportional") distributes the available
* bandwidth fair over all the addresses influenced by the
* preference values. For each available network type an in- and
* outbound quota is configured and the bandwidth available in
* is used to specify network related information as total adresses
* and active addresses in this network and the configured in- and
* outbound quota. Each network also contains a list of addresses
- * added to the solver located in this network. The simplistic
+ * added to the solver located in this network. The proportional
* solver uses the addresses' solver_information field to store the
- * simplistic network it belongs to for each address.
+ * proportional network it belongs to for each address.
*
* 3.2 Initializing
*
- * When the simplistic solver is initialized the solver creates a
+ * When the proportional solver is initialized the solver creates a
* new solver handle and initializes the network structures with
* the quotas passed from addresses and returns the handle solver.
*
* 3.4 Updating an address
*
* The main purpose of address updates is to update the ATS
- * information for addresse selection. Important for the simplistic
+ * information for addresse selection. Important for the proportional
* solver is when an address switches network it is located
* in. This is common because addresses added by transport's
* validation mechanism are commonly located in
* return of payload data transport switches to the real network
* the address is located in. When an address changes networks it
* is first of all removed from the old network using the solver
- * API function GAS_simplistic_address_delete and the network in
+ * API function GAS_proportional_address_delete and the network in
* the address struct is updated. A lookup for the respective new
- * simplistic network is done and stored in the addresse's
+ * proportional network is done and stored in the addresse's
* solver_information field. Next the address is re-added to the
* solver using the solver API function
- * GAS_simplistic_address_add. If the address was marked as in
+ * GAS_proportional_address_add. If the address was marked as in
* active, the solver checks if bandwidth is available in the
* network and if yes sets the address to active and updates the
* bandwidth distribution in this network. If no bandwidth is
*/
const struct GNUNET_CONTAINER_MultiHashMap *addresses;
+ /**
+ * Pending address requests
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *requests;
+
/**
* Bandwidth changed callback
*/
unsigned long long assigned_quota_out = 0;
struct AddressWrapper *cur;
-
if (GNUNET_YES == s->bulk_lock)
{
s->bulk_requests++;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Total bandwidth assigned is (in/out): %llu /%llu\n",
- quota_in_used,
- quota_out_used);
+ "Total bandwidth assigned is (in/out): %llu /%llu\n",
+ quota_in_used,
+ quota_out_used);
if (quota_out_used > net->total_quota_out + 1) /* +1 is required due to rounding errors */
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Total outbound bandwidth assigned is larger than allowed (used/allowed) for %u active addresses: %llu / %llu\n",
- net->active_addresses,
- quota_out_used,
- net->total_quota_out);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Total outbound bandwidth assigned is larger than allowed (used/allowed) for %u active addresses: %llu / %llu\n",
+ net->active_addresses,
+ quota_out_used,
+ net->total_quota_out);
}
if (quota_in_used > net->total_quota_in + 1) /* +1 is required due to rounding errors */
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Total inbound bandwidth assigned is larger than allowed (used/allowed) for %u active addresses: %llu / %llu\n",
- net->active_addresses,
- quota_in_used,
- net->total_quota_in);
+ "Total inbound bandwidth assigned is larger than allowed (used/allowed) for %u active addresses: %llu / %llu\n",
+ net->active_addresses,
+ quota_in_used,
+ net->total_quota_in);
}
}
-/**
- * Extract an ATS performance info from an address
- *
- * @param address the address
- * @param type the type to extract in HBO
- * @return the value in HBO or GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist
- */
-static int
-get_performance_info (struct ATS_Address *address, uint32_t type);
-
-
-
struct FindBestAddressCtx
{
- struct GAS_PROPORTIONAL_Handle *s;
- struct ATS_Address *best;
+ struct GAS_PROPORTIONAL_Handle *s;
+ struct ATS_Address *best;
};
static int
find_property_index (uint32_t type)
{
- int existing_types[] = GNUNET_ATS_QualityProperties;
- int c;
- for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
- if (existing_types[c] == type)
- return c;
- return GNUNET_SYSERR;
+ int existing_types[] = GNUNET_ATS_QualityProperties;
+ int c;
+ for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
+ if (existing_types[c] == type)
+ return c;
+ return GNUNET_SYSERR;
}
/**
static int
find_best_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
{
- struct FindBestAddressCtx *fba_ctx = (struct FindBestAddressCtx *) cls;
+ struct FindBestAddressCtx *fba_ctx = (struct FindBestAddressCtx *) cls;
struct ATS_Address *current = (struct ATS_Address *) value;
struct GNUNET_TIME_Absolute now;
struct Network *net = (struct Network *) current->solver_information;
now = GNUNET_TIME_absolute_get();
- if (current->blocked_until.abs_value == GNUNET_TIME_absolute_max (now, current->blocked_until).abs_value)
+ if (current->blocked_until.abs_value_us == GNUNET_TIME_absolute_max (now, current->blocked_until).abs_value_us)
{
/* This address is blocked for suggestion */
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Address %p blocked for suggestion for %llu ms \n",
- current,
- GNUNET_TIME_absolute_get_difference(now, current->blocked_until).rel_value);
+ "Address %p blocked for suggestion for %s \n",
+ current,
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (now, current->blocked_until),
+ GNUNET_YES));
return GNUNET_OK;
}
if (GNUNET_NO == is_bandwidth_available_in_network (net))
static void
distribute_bandwidth_in_all_networks (struct GAS_PROPORTIONAL_Handle *s)
{
- int i;
-
- for (i = 0; i < s->networks; i++)
- distribute_bandwidth_in_network (s, &s->network_entries[i], NULL);
-
+ int i;
+ for (i = 0; i < s->networks; i++)
+ distribute_bandwidth_in_network (s, &s->network_entries[i], NULL);
}
static int
get_active_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
{
- struct ATS_Address * dest = (struct ATS_Address *) (*(struct ATS_Address **)cls);
- struct ATS_Address * aa = (struct ATS_Address *) value;
+ struct ATS_Address **dest = cls;
+ struct ATS_Address *aa = (struct ATS_Address *) value;
if (GNUNET_YES == aa->active)
{
- if (dest != NULL)
+
+ if (NULL != (*dest))
{
/* should never happen */
LOG (GNUNET_ERROR_TYPE_ERROR, "Multiple active addresses for peer `%s'\n", GNUNET_i2s (&aa->peer));
GNUNET_break (0);
return GNUNET_NO;
}
- dest = aa;
+ (*dest) = aa;
}
return GNUNET_OK;
}
}
-/**
- * Extract an ATS performance info from an address
- *
- * @param address the address
- * @param type the type to extract in HBO
- * @return the value in HBO or GNUNET_ATS_VALUE_UNDEFINED in HBO if value does not exist
- */
-static int
-get_performance_info (struct ATS_Address *address, uint32_t type)
-{
- int c1;
- GNUNET_assert (NULL != address);
-
- if ((NULL == address->atsi) || (0 == address->atsi_count))
- return GNUNET_ATS_VALUE_UNDEFINED;
-
- for (c1 = 0; c1 < address->atsi_count; c1++)
- {
- if (ntohl(address->atsi[c1].type) == type)
- return ntohl(address->atsi[c1].value);
- }
- return GNUNET_ATS_VALUE_UNDEFINED;
-}
-
-
/**
* Solver API functions
* ---------------------------
}
+/**
+ * Get application feedback for a peer
+ *
+ * @param solver the solver handle
+ * @param application the application
+ * @param peer the peer to change the preference for
+ * @param scope the time interval for this feedback: [now - scope .. now]
+ * @param kind the kind to change the preference
+ * @param score the score
+ */
+void
+GAS_proportional_address_preference_feedback (void *solver,
+ void *application,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TIME_Relative scope,
+ enum GNUNET_ATS_PreferenceKind kind,
+ double score)
+{
+ struct GAS_PROPORTIONAL_Handle *s = solver;
+ GNUNET_assert (NULL != solver);
+ GNUNET_assert (NULL != peer);
+
+ GNUNET_assert (NULL != s);
+ GNUNET_break (0);
+}
+
+
/**
* Get the preferred address for a specific peer
*
* @param solver the solver handle
- * @param addresses the address hashmap containing all addresses
* @param peer the identity of the peer
*/
const struct ATS_Address *
GNUNET_assert (s != NULL);
GNUNET_assert (peer != NULL);
+ /* Add to list of pending requests */
+ if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (s->requests, &peer->hashPubKey))
+ GNUNET_CONTAINER_multihashmap_put (s->requests, &peer->hashPubKey,
+ NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+
/* Get address with: stick to current address, lower distance, lower latency */
fba_ctx.s = s;
fba_ctx.best = NULL;
&find_best_address_it, &fba_ctx);
if (NULL == fba_ctx.best)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
+ LOG (GNUNET_ERROR_TYPE_INFO, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer));
return NULL;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Suggesting %s address %p for peer `%s'\n",
+ LOG (GNUNET_ERROR_TYPE_INFO, "Suggesting %s address %p for peer `%s'\n",
(GNUNET_NO == fba_ctx.best->active) ? "inactive" : "active",
fba_ctx.best, GNUNET_i2s (peer));
net_cur = (struct Network *) fba_ctx.best->solver_information;
* - update quota for previous address network
* - update quota for this address network
*/
-
prev = get_active_address (s, (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, peer);
if (NULL != prev)
{
net_prev = (struct Network *) prev->solver_information;
prev->active = GNUNET_NO; /* No active any longer */
- prev->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
- prev->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0); /* no bw assigned */
- s->bw_changed (s->bw_changed_cls, prev); /* notify about bw change, REQUIRED? */
+ prev->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
+ prev->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
if (GNUNET_SYSERR == addresse_decrement (s, net_prev, GNUNET_NO, GNUNET_YES))
GNUNET_break (0);
- distribute_bandwidth_in_network (s, net_prev, NULL);
+ distribute_bandwidth_in_network (s, net_prev, NULL);
}
if (GNUNET_NO == (is_bandwidth_available_in_network (fba_ctx.best->solver_information)))
}
fba_ctx.best->active = GNUNET_YES;
- addresse_increment(s, net_cur, GNUNET_NO, GNUNET_YES);
- distribute_bandwidth_in_network (s, net_cur, fba_ctx.best);
+ addresse_increment (s, net_cur, GNUNET_NO, GNUNET_YES);
+ distribute_bandwidth_in_network (s, net_cur, NULL);
return fba_ctx.best;
}
* Stop notifying about address and bandwidth changes for this peer
*
* @param solver the solver handle
- * @param addresses address hashmap
* @param peer the peer
*/
void
GAS_proportional_stop_get_preferred_address (void *solver,
const struct GNUNET_PeerIdentity *peer)
{
- return;
+ struct GAS_PROPORTIONAL_Handle *s = solver;
+ struct ATS_Address *cur;
+ struct Network *cur_net;
+
+ if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (s->requests, &peer->hashPubKey))
+ GNUNET_CONTAINER_multihashmap_remove (s->requests, &peer->hashPubKey, NULL);
+
+ cur = get_active_address (s, (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, peer);
+ if (NULL != cur)
+ {
+ /* Disabling current address */
+ cur_net = (struct Network *) cur->solver_information;
+ cur->active = GNUNET_NO; /* No active any longer */
+ cur->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
+ cur->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
+ if (GNUNET_SYSERR == addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES))
+ GNUNET_break (0);
+ distribute_bandwidth_in_network (s, cur_net, NULL);
+ }
+ return;
}
* Remove an address from the solver
*
* @param solver the solver handle
- * @param addresses the address hashmap containing all addresses
* @param address the address to remove
* @param session_only delete only session not whole address
*/
{
/* Address was active, remove from network and update quotas*/
address->active = GNUNET_NO;
+ address->assigned_bw_in = BANDWIDTH_ZERO;
+ address->assigned_bw_out = BANDWIDTH_ZERO;
+
if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES))
GNUNET_break (0);
distribute_bandwidth_in_network (s, net, NULL);
struct ATS_Address *address,
uint32_t network);
+
/**
- * Updates a single address in the solver and checks previous values
+ * Transport properties for this address have changed
*
- * @param solver the solver Handle
- * @param addresses the address hashmap containing all addresses
- * @param address the update address
- * @param session the previous session
- * @param in_use the previous address in use state
- * @param prev_ats previous ATS information
- * @param prev_atsi_count the previous atsi count
+ * @param solver solver handle
+ * @param address the address
+ * @param type the ATSI type in HBO
+ * @param abs_value the absolute value of the property
+ * @param rel_value the normalized value
*/
void
-GAS_proportional_address_update (void *solver,
- struct ATS_Address *address,
- uint32_t session,
- int in_use,
- const struct GNUNET_ATS_Information *prev_ats,
- uint32_t prev_atsi_count)
+GAS_proportional_address_property_changed (void *solver,
+ struct ATS_Address *address,
+ uint32_t type,
+ uint32_t abs_value,
+ double rel_value)
{
- struct ATS_Address *new;
- struct GAS_PROPORTIONAL_Handle *s = (struct GAS_PROPORTIONAL_Handle *) solver;
- int i;
- uint32_t prev_value;
- uint32_t prev_type;
- uint32_t addr_net;
- int save_active = GNUNET_NO;
- struct Network *new_net = NULL;
+ struct GAS_PROPORTIONAL_Handle *s;
+ struct Network *n;
- /* Check updates to performance information */
- for (i = 0; i < prev_atsi_count; i++)
- {
- prev_type = ntohl (prev_ats[i].type);
- prev_value = ntohl (prev_ats[i].value);
- switch (prev_type)
- {
- case GNUNET_ATS_UTILIZATION_UP:
- case GNUNET_ATS_UTILIZATION_DOWN:
- case GNUNET_ATS_QUALITY_NET_DELAY:
- case GNUNET_ATS_QUALITY_NET_DISTANCE:
- case GNUNET_ATS_COST_WAN:
- case GNUNET_ATS_COST_LAN:
- case GNUNET_ATS_COST_WLAN:
- /* No actions required here*/
- break;
- case GNUNET_ATS_NETWORK_TYPE:
-
- addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
- if (GNUNET_ATS_VALUE_UNDEFINED == addr_net)
- {
- GNUNET_break (0);
- addr_net = GNUNET_ATS_NET_UNSPECIFIED;
- }
- if (addr_net != prev_value)
- {
- /* Network changed */
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Network type changed, moving %s address from `%s' to `%s'\n",
- (GNUNET_YES == address->active) ? "active" : "inactive",
- GNUNET_ATS_print_network_type(prev_value),
- GNUNET_ATS_print_network_type(addr_net));
-
- save_active = address->active;
- /* remove from old network */
- GAS_proportional_address_delete (solver, address, GNUNET_NO);
-
- /* set new network type */
- new_net = get_network (solver, addr_net);
- if (NULL == new_net)
- {
- /* Address changed to invalid network... */
- LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot find network of type `%u' %s\n"),
- addr_net, GNUNET_ATS_print_network_type (addr_net));
- address->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0);
- address->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0);
- s->bw_changed (s->bw_changed_cls, address);
- return;
- }
- address->solver_information = new_net;
-
- /* Add to new network and update*/
- GAS_proportional_address_add (solver, address, addr_net);
- if (GNUNET_YES == save_active)
- {
- /* check if bandwidth available in new network */
- if (GNUNET_YES == (is_bandwidth_available_in_network (new_net)))
- {
- /* Suggest updated address */
- address->active = GNUNET_YES;
- addresse_increment (s, new_net, GNUNET_NO, GNUNET_YES);
- distribute_bandwidth_in_network (solver, new_net, NULL);
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Not enough bandwidth in new network, suggesting alternative address ..\n");
-
- /* Set old address to zero bw */
- address->assigned_bw_in = GNUNET_BANDWIDTH_value_init (0);
- address->assigned_bw_out = GNUNET_BANDWIDTH_value_init (0);
- s->bw_changed (s->bw_changed_cls, address);
-
- /* Find new address to suggest since no bandwidth in network*/
- new = (struct ATS_Address *) GAS_proportional_get_preferred_address (s, &address->peer);
- if (NULL != new)
- {
- /* Have an alternative address to suggest */
- s->bw_changed (s->bw_changed_cls, new);
- }
- }
- }
- }
- break;
- case GNUNET_ATS_ARRAY_TERMINATOR:
- break;
- default:
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Received unsupported ATS type %u\n", prev_type);
- GNUNET_break (0);
- break;
+ GNUNET_assert (NULL != solver);
+ GNUNET_assert (NULL != address);
- }
+ s = (struct GAS_PROPORTIONAL_Handle *) solver;
+ n = (struct Network *) address->solver_information;
- }
- if (address->session_id != session)
+ if (NULL == n)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Property `%s' for peer `%s' address %p changed to %.2f \n",
+ GNUNET_ATS_print_property_type (type),
+ GNUNET_i2s (&address->peer),
+ address, rel_value);
+ switch (type)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Session changed from %u to %u\n", session, address->session_id);
+ case GNUNET_ATS_UTILIZATION_UP:
+ case GNUNET_ATS_UTILIZATION_DOWN:
+ case GNUNET_ATS_QUALITY_NET_DELAY:
+ case GNUNET_ATS_QUALITY_NET_DISTANCE:
+ case GNUNET_ATS_COST_WAN:
+ case GNUNET_ATS_COST_LAN:
+ case GNUNET_ATS_COST_WLAN:
+ distribute_bandwidth_in_network (s, n, GNUNET_NO);
+ break;
}
- if (address->used != in_use)
+}
+
+
+/**
+ * Transport session for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param cur_session the current session
+ * @param new_session the new session
+ */
+void
+GAS_proportional_address_session_changed (void *solver,
+struct ATS_Address *address,
+uint32_t cur_session,
+uint32_t new_session)
+{
+ if (cur_session!= new_session)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Usage changed from %u to %u\n", in_use, address->used);
+ "Session changed from %u to %u\n", cur_session, new_session);
}
+}
+
+/**
+ * Usage for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param in_use usage state
+ */
+void
+GAS_proportional_address_inuse_changed (void *solver,
+struct ATS_Address *address,
+int in_use)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Usage changed to %s\n",
+ (GNUNET_YES == in_use) ? "USED" : "UNUSED");
}
+/**
+ * Network scope for this address has changed
+ *
+ * NOTE: values in addresses are already updated
+ *
+ * @param solver solver handle
+ * @param address the address
+ * @param current_network the current network
+ * @param new_network the new network
+ */
+void
+GAS_proportional_address_change_network (void *solver,
+ struct ATS_Address *address,
+ uint32_t current_network,
+ uint32_t new_network)
+{
+ struct ATS_Address *new;
+ struct GAS_PROPORTIONAL_Handle *s = (struct GAS_PROPORTIONAL_Handle *) solver;
+ int save_active = GNUNET_NO;
+ struct Network *new_net = NULL;
+
+ if (current_network == new_network)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ /* Network changed */
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Network type changed, moving %s address from `%s' to `%s'\n",
+ (GNUNET_YES == address->active) ? "active" : "inactive",
+ GNUNET_ATS_print_network_type (current_network),
+ GNUNET_ATS_print_network_type (new_network));
+
+ save_active = address->active;
+
+ /* Disable and assign no bandwidth */
+ address->active = GNUNET_NO;
+ address->assigned_bw_in = BANDWIDTH_ZERO; /* no bandwidth assigned */
+ address->assigned_bw_out = BANDWIDTH_ZERO; /* no bandwidth assigned */
+
+ /* Remove from old network */
+ GAS_proportional_address_delete (solver, address, GNUNET_NO);
+
+ /* Set new network type */
+ if (NULL == (new_net = get_network (solver, new_network)))
+ {
+ /* Address changed to invalid network... */
+ LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid network type `%u' `%s': Disconnect!\n"),
+ new_network, GNUNET_ATS_print_network_type (new_network));
+
+ /* Find new address to suggest since no bandwidth in network*/
+ if (NULL == (new = (struct ATS_Address *) GAS_proportional_get_preferred_address (s, &address->peer)))
+ {
+ /* No alternative address found, disconnect peer */
+ s->bw_changed (s->bw_changed_cls, address);
+ }
+ return;
+ }
+
+ /* Add to new network and update*/
+ address->solver_information = new_net;
+ GAS_proportional_address_add (solver, address, new_network);
+ if (GNUNET_YES == save_active)
+ {
+ /* check if bandwidth available in new network */
+ if (GNUNET_YES == (is_bandwidth_available_in_network (new_net)))
+ {
+ /* Assign bandwidth to updated address */
+ address->active = GNUNET_YES;
+ addresse_increment (s, new_net, GNUNET_NO, GNUNET_YES);
+ distribute_bandwidth_in_network (solver, new_net, NULL);
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Not enough bandwidth in new network, suggesting alternative address ..\n");
+ /* Find new address to suggest since no bandwidth in network*/
+ if (NULL == (new = (struct ATS_Address *) GAS_proportional_get_preferred_address (s, &address->peer)))
+ {
+ /* No alternative address found, disconnect peer */
+ s->bw_changed (s->bw_changed_cls, address);
+ }
+ }
+ }
+}
+
/**
* Add a new single address to a network
*
* @param solver the solver Handle
- * @param addresses the address hashmap containing all addresses
* @param address the address to add
* @param network network type of this address
*/
void
GAS_proportional_address_add (void *solver,
- struct ATS_Address *address,
- uint32_t network)
+ struct ATS_Address *address,
+ uint32_t network)
{
struct GAS_PROPORTIONAL_Handle *s = solver;
struct Network *net = NULL;
addresse_increment (s, net, GNUNET_YES, GNUNET_NO);
aw->addr->solver_information = net;
+ if ((GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(s->requests, &address->peer.hashPubKey)) &&
+ (NULL == get_active_address (s,
+ (struct GNUNET_CONTAINER_MultiHashMap *) s->addresses, &address->peer)))
+ GAS_proportional_get_preferred_address (s, &address->peer);
+
LOG (GNUNET_ERROR_TYPE_DEBUG, "After adding address now total %u and active %u addresses in network `%s'\n",
net->total_addresses,
net->active_addresses,
* @param bw_changed_cb_cls cls for callback
* @param get_preference callback to get relative preferences for a peer
* @param get_preference_cls cls for callback to get relative preferences
+ * @param get_properties for callback to get relative properties
+ * @param get_properties_cls cls for callback to get relative properties
* @return handle for the solver on success, NULL on fail
*/
void *
s->bulk_lock = GNUNET_NO;
s->addresses = addresses;
+ s->requests = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_YES);
+
for (c = 0; c < dest_length; c++)
{
cur = &s->network_entries[c];
GNUNET_break (0);
}
GNUNET_free (s->network_entries);
+ GNUNET_CONTAINER_multihashmap_destroy (s->requests);
GNUNET_free (s);
}