/** * Update a bandwidth assignment for a peer. This trivial method currently * simply assigns the same share to all active connections. * * @param cls unused * @param key unused * @param value the 'struct ATS_Address' * @return GNUNET_OK (continue to iterate) */ static int update_bw_simple_it (void *cls, const GNUNET_HashCode * key, void *value) { struct ATS_Address *aa = value; if (GNUNET_YES != aa->active) return GNUNET_OK; GNUNET_assert (active_addr_count > 0); /* Simple method */ aa->assigned_bw_in.value__ = htonl (wan_quota_in / active_addr_count); aa->assigned_bw_out.value__ = htonl (wan_quota_out / active_addr_count); send_bw_notification (aa); return GNUNET_OK; }
static void request_address_mlp (const struct GNUNET_PeerIdentity *peer) { struct ATS_Address *aa; aa = NULL; #if HAVE_GLPK /* Get preferred address from MLP */ struct ATS_PreferedAddress * paddr = NULL; paddr = GAS_mlp_get_preferred_address (mlp, addresses, peer); aa = paddr->address; aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(paddr->bandwidth_out); /* FIXME use bw in value */ paddr->bandwidth_in = paddr->bandwidth_out; aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init (paddr->bandwidth_in); GNUNET_free (paddr); #endif if (aa == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer)); return; } if (aa->active == GNUNET_NO) { aa->active = GNUNET_YES; active_addr_count++; send_bw_notification (aa); } else { /* just to be sure... */ GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr, aa->addr_len, aa->session_id, aa->ats, aa->ats_count, aa->assigned_bw_out, aa->assigned_bw_in); } }