total_prefs = 0.0;
for (cur = net->head; NULL != cur; cur = cur->next)
{
- t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey);
- if (NULL == t)
- total_prefs += DEFAULT_PREFERENCE;
- else
- total_prefs += (*t);
+ if (GNUNET_YES == cur->addr->active)
+ {
+ t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey);
+ if (NULL == t)
+ total_prefs += DEFAULT_PREFERENCE;
+ else
+ total_prefs += (*t);
+ }
}
for (cur = net->head; NULL != cur; cur = cur->next)
{
- cur_pref = 0.0;
- t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey);
- if (NULL == t)
- cur_pref = DEFAULT_PREFERENCE;
+ if (GNUNET_YES == cur->addr->active)
+ {
+ cur_pref = 0.0;
+ t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey);
+ if (NULL == t)
+ cur_pref = DEFAULT_PREFERENCE;
+ else
+ cur_pref = (*t);
+ quota_in = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_in;
+ quota_out = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_out;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "New quota for peer `%s' with preference (cur/total) %.3f/%.3f (in/out): %llu /%llu\n",
+ GNUNET_i2s (&cur->addr->peer),
+ cur_pref, total_prefs,
+ quota_in, quota_out);
+ }
else
- cur_pref = (*t);
- quota_in = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_in;
- quota_out = min_bw + (cur_pref / total_prefs) * (float) remaining_quota_out;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "New quota for peer `%s' with preference (cur/total) %.3f/%.3f (in/out): %llu /%llu\n",
- GNUNET_i2s (&cur->addr->peer),
- cur_pref,
- total_prefs,
- quota_in,
- quota_out);
+ {
+ quota_in = 0;
+ quota_out = 0;
+ }
+
quota_in_used += quota_in;
quota_out_used += quota_out;
/* Prevent overflow due to rounding errors */
quota_out_used);
if (quota_out_used > quota_out)
LOG (GNUNET_ERROR_TYPE_WARNING,
- "DEBUG! Total inbount bandwidth assigned is larget than allowed %llu /%llu\n",
+ "DEBUG! Total inbound bandwidth assigned is larget than allowed %llu /%llu\n",
quota_out_used,
quota_out); /* FIXME: Can happen atm, we have some rounding error */
if (quota_in_used > quota_in)
LOG (GNUNET_ERROR_TYPE_WARNING,
- "DEBUG! Total inbount bandwidth assigned is larget than allowed %llu /%llu\n",
+ "DEBUG! Total inbound bandwidth assigned is larget than allowed %llu /%llu\n",
quota_in_used,
quota_in); /* FIXME: Can happen atm, we have some rounding error */
}
{
if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0]))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
+ stage,
GNUNET_i2s (&address->peer));
ret = 0;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
+ stage,
GNUNET_i2s (&address->peer));
ret = 1;
}
if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n",
+ stage);
ret = 1;
}
stage ++;
GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+ GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
+ return;
+ }
+ if (1 == stage)
+ {
+ if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[1], test_session[1]))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
+ stage,
+ GNUNET_i2s (&address->peer));
+ ret = 0;
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
+ stage,
+ GNUNET_i2s (&address->peer));
+ ret = 1;
+ }
+
+ if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n",
+ stage);
+ ret = 1;
+ }
+
+ if (bw_in > wan_quota_in)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n",
+ bw_in, wan_quota_in);
+ ret = 1;
+ }
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n",
+ bw_in, wan_quota_in);
+
+ if (bw_out > wan_quota_out)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n",
+ bw_out, wan_quota_out);
+ ret = 1;
+ }
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n",
+ bw_out, wan_quota_out);
+
+ if (1 == ret)
+ {
+ GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+ GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+ return;
+ }
+
+ stage ++;
+
+ GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
+ GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
GNUNET_SCHEDULER_add_now (&end, NULL);
+
return;
}
}