* @param plugin_name plugin
* @param plugin_addr address
* @param plugin_addr_len address length
+ * @param local_address_info additional local info for the address
* @param session_id session
* @return the ATS_Address
*/
static struct ATS_Address *
-create_address (const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id)
+create_address (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id)
{
struct ATS_Address *aa = NULL;
int c1;
memcpy (&aa[1], plugin_addr, plugin_addr_len);
aa->plugin = GNUNET_strdup (plugin_name);
aa->session_id = session_id;
+ aa->local_address_info = local_address_info;
aa->active = GNUNET_NO;
aa->used = GNUNET_NO;
aa->solver_information = NULL;
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @return an ATS_address or NULL
*/
static struct ATS_Address *
find_exact_address (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id)
{
struct ATS_Address *aa;
struct ATS_Address *ea;
aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
- session_id);
+ local_address_info, session_id);
/* Get existing address or address with session == 0 */
ea = find_equivalent_address (handle, peer, aa);
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @param atsi performance information for this address
* @param atsi_count number of performance information contained
*/
void
GAS_addresses_add (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct ATS_Address *new_address;
struct ATS_Address *existing_address;
GNUNET_assert(NULL != handle->addresses);
new_address = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
- session_id);
+ local_address_info, session_id);
atsi_delta = NULL;
disassemble_ats_information (new_address, atsi, atsi_count, &atsi_delta,
&atsi_delta_count);
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @param atsi performance information for this address
* @param atsi_count number of performance information contained
*/
void
GAS_addresses_update (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct ATS_Address *aa;
struct GNUNET_ATS_Information *atsi_delta;
/* Get existing address */
aa = find_exact_address (handle, peer, plugin_name, plugin_addr,
- plugin_addr_len, session_id);
+ plugin_addr_len, local_address_info, session_id);
if (aa == NULL )
return;
if (NULL == aa->solver_information)
GNUNET_break(0);
return GNUNET_OK;
}
-
- if (aa->addr_len == 0)
+ if (GNUNET_HELLO_ADDRESS_INFO_INBOUND ==
+ (aa->local_address_info && GNUNET_HELLO_ADDRESS_INFO_INBOUND))
{
/* Inbound connection died, delete full address */
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
*/
void
GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id)
{
struct ATS_Address *ea;
struct DestroyContext dc;
/* Get existing address */
ea = find_exact_address (handle, peer, plugin_name, plugin_addr,
- plugin_addr_len, session_id);
+ plugin_addr_len, local_address_info, session_id);
if (ea == NULL )
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
GNUNET_break(0 < strlen (plugin_name));
dc.handle = handle;
dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
- session_id);
+ local_address_info, session_id);
GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses,
peer,
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @param in_use GNUNET_YES if GNUNET_NO
* @return GNUNET_SYSERR on failure (address unknown ...)
int
GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
+ const void *plugin_addr, size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
int in_use)
{
struct ATS_Address *ea;
return GNUNET_SYSERR;
ea = find_exact_address (handle, peer, plugin_name, plugin_addr,
- plugin_addr_len, session_id);
+ plugin_addr_len, local_address_info, session_id);
if (NULL == ea)
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
}
if (NULL == cur)
{
- cur = GNUNET_malloc (sizeof (struct GAS_Addresses_Suggestion_Requests));
+ cur = GNUNET_new (struct GAS_Addresses_Suggestion_Requests);
cur->id = (*peer);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Adding new address suggestion request for `%s'\n",
aa, GNUNET_i2s (peer));
GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr,
- aa->addr_len, aa->session_id, aa->atsi, aa->atsi_count,
+ aa->addr_len, aa->local_address_info, aa->session_id,
+ aa->atsi, aa->atsi_count,
aa->assigned_bw_out, aa->assigned_bw_in);
aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval,
}
-
static int
-eval_count_active_it (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
+eval_count_active_it (void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ void *obj)
{
int *request_fulfilled = cls;
struct ATS_Address *addr = obj;
/**
* Summary context
*/
-struct SummaryContext {
+struct SummaryContext
+{
/**
* Sum of the utilized inbound bandwidth per network
*/
static int
eval_sum_bw_used (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
{
+ struct SummaryContext *ctx = cls;
struct ATS_Address *addr = obj;
int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
int net;
- struct SummaryContext *ctx = cls;
-
int c;
if (GNUNET_YES == addr->active)
ctx->bandwidth_out_assigned[c] += ntohl (addr->assigned_bw_out.value__);
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Active address in %s with (in/out) %llu/%llu Bps\n",
- GNUNET_ATS_print_network_type(net),
- ntohl (addr->assigned_bw_in.value__),
- ntohl (addr->assigned_bw_out.value__));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Active address in %s with (in/out) %u/%u Bps\n",
+ GNUNET_ATS_print_network_type (net),
+ (unsigned int) ntohl (addr->assigned_bw_in.value__),
+ (unsigned int) ntohl (addr->assigned_bw_out.value__));
}
return GNUNET_OK;
}
+
/**
* Summary context
*/
-struct RelativityContext {
+struct RelativityContext
+{
struct GAS_Addresses_Handle *ah;
};
+
static int
find_active_address (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
{
if (NULL == find_preference_client (handle, client))
{
- pc = GNUNET_malloc (sizeof (struct GAS_Addresses_Preference_Clients));
+ pc = GNUNET_new (struct GAS_Addresses_Preference_Clients);
pc->client = client;
GNUNET_CONTAINER_DLL_insert (handle->preference_clients_head,
handle->preference_clients_tail, pc);
}
if (NULL == cur)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Nobody is interested in peer `%s' :(\n",
- GNUNET_i2s (&address->peer));
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Nobody is interested in peer `%s' :(\n",
+ GNUNET_i2s (&address->peer));
return;
}
if ((0 == ntohl (address->assigned_bw_in.value__))
&& (0 == ntohl (address->assigned_bw_out.value__)))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Telling transport to disconnect peer `%s'\n",
- GNUNET_i2s (&address->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Telling transport to disconnect peer `%s'\n",
+ GNUNET_i2s (&address->peer));
}
else
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Sending bandwidth update for peer `%s': %llu %llu\n",
- GNUNET_i2s (&address->peer), address->assigned_bw_out,
- address->assigned_bw_out);
+ "Sending bandwidth update for peer `%s': %u %u\n",
+ GNUNET_i2s (&address->peer),
+ (unsigned int) ntohl (address->assigned_bw_out.value__),
+ (unsigned int) ntohl (address->assigned_bw_out.value__));
}
/* *Notify scheduling clients about suggestion */
GAS_scheduling_transmit_address_suggestion (&address->peer, address->plugin,
- address->addr, address->addr_len, address->session_id, address->atsi,
+ address->addr, address->addr_len, address->local_address_info,
+ address->session_id, address->atsi,
address->atsi_count, address->assigned_bw_out, address->assigned_bw_in);
}
+
/**
* Initialize address subsystem. The addresses subsystem manages the addresses
* known and current performance information. It has a solver component
char *plugin_short;
int c;
- ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle));
+ ah = GNUNET_new (struct GAS_Addresses_Handle);
ah->running = GNUNET_NO;
ah->stat = (struct GNUNET_STATISTICS_Handle *) stats;
GNUNET_assert(NULL != ah->addresses);
/* Figure out configured solution method */
- plugin_short = NULL;
if (GNUNET_SYSERR
== GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str))
{
for (c = 0; c < strlen (mode_str); c++)
mode_str[c] = toupper (mode_str[c]);
if (0 == strcmp (mode_str, "PROPORTIONAL"))
- {
ah->ats_mode = MODE_PROPORTIONAL;
- plugin_short = "proportional";
- }
else if (0 == strcmp (mode_str, "MLP"))
{
ah->ats_mode = MODE_MLP;
- plugin_short = "mlp";
#if !HAVE_LIBGLPK
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"Assignment method `%s' configured, but GLPK is not available, please install \n",
mode_str);
ah->ats_mode = MODE_PROPORTIONAL;
- plugin_short = "proportional";
#endif
}
else if (0 == strcmp (mode_str, "RIL"))
- {
ah->ats_mode = MODE_RIL;
- plugin_short = "ril";
- }
else
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"Invalid resource assignment method `%s' configured, using proportional approach\n",
mode_str);
ah->ats_mode = MODE_PROPORTIONAL;
- plugin_short = "proportional";
}
GNUNET_free(mode_str);
}
ah->env.in_quota[c] = quotas_in[c];
}
+ switch (ah->ats_mode) {
+ case MODE_PROPORTIONAL:
+ plugin_short = "proportional";
+ break;
+ case MODE_MLP:
+ plugin_short = "mlp";
+ break;
+ case MODE_RIL:
+ plugin_short = "ril";
+ break;
+ default:
+ plugin_short = NULL;
+ break;
+ }
GNUNET_asprintf (&ah->plugin, "libgnunet_plugin_ats_%s", plugin_short);
GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s '`%s'\n"), plugin_short, ah->plugin);
if (NULL == (ah->solver = GNUNET_PLUGIN_load (ah->plugin, &ah->env)))