+static void
+ats_performance_info_cb (void *cls,
+ const struct GNUNET_HELLO_Address *address,
+ int address_active,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+ struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+ const struct GNUNET_ATS_Information *ats,
+ uint32_t ats_count)
+{
+ struct BenchmarkPeer *me = cls;
+ struct BenchmarkPartner *p;
+ int c_a;
+ int log;
+ char *peer_id;
+
+ p = find_partner (me, &address->peer);
+ if (NULL == p)
+ {
+ /* This is not one of my partners
+ * Will happen since the peers will connect to each other due to gossiping
+ */
+ return;
+ }
+ peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
+
+ log = GNUNET_NO;
+ if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
+ (p->bandwidth_out != ntohl (bandwidth_out.value__)))
+ log = GNUNET_YES;
+ p->bandwidth_in = ntohl (bandwidth_in.value__);
+ p->bandwidth_out = ntohl (bandwidth_out.value__);
+
+ for (c_a = 0; c_a < ats_count; c_a++)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n",
+ (GNUNET_YES == p->me->master) ? "Master" : "Slave",
+ p->me->no,
+ GNUNET_i2s (&p->dest->id),
+ GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)),
+ ntohl(ats[c_a].value));
+ switch (ntohl (ats[c_a].type ))
+ {
+ case GNUNET_ATS_ARRAY_TERMINATOR:
+ break;
+ case GNUNET_ATS_UTILIZATION_OUT:
+ if (p->ats_utilization_up != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_utilization_up = ntohl (ats[c_a].value);
+
+ break;
+ case GNUNET_ATS_UTILIZATION_IN:
+ if (p->ats_utilization_down != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_utilization_down = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_NETWORK_TYPE:
+ if (p->ats_network_type != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_network_type = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_QUALITY_NET_DELAY:
+ if (p->ats_delay != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_delay = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_QUALITY_NET_DISTANCE:
+ if (p->ats_distance != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_distance = ntohl (ats[c_a].value);
+ GNUNET_break (0);
+ break;
+ case GNUNET_ATS_COST_WAN:
+ if (p->ats_cost_wan != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_cost_wan = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_COST_LAN:
+ if (p->ats_cost_lan != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_cost_lan = ntohl (ats[c_a].value);
+ break;
+ case GNUNET_ATS_COST_WLAN:
+ if (p->ats_cost_wlan != ntohl (ats[c_a].value))
+ log = GNUNET_YES;
+ p->ats_cost_wlan = ntohl (ats[c_a].value);
+ break;
+ default:
+ break;
+ }
+ }
+ if (GNUNET_YES == log)
+ top->ats_perf_cb (cls, address, address_active, bandwidth_out, bandwidth_in,
+ ats, ats_count);
+ GNUNET_free(peer_id);
+}
+