+ for (i = 0; i < atsi_count; i++)
+ switch (ntohl (atsi[i].type))
+ {
+ case GNUNET_ATS_UTILIZATION_UP:
+ old->atsp_utilization_out.value__ = atsi[i].value;
+ break;
+ case GNUNET_ATS_UTILIZATION_DOWN:
+ old->atsp_utilization_in.value__ = atsi[i].value;
+ break;
+ case GNUNET_ATS_QUALITY_NET_DELAY:
+ old->atsp_latency.rel_value = ntohl (atsi[i].value);
+ break;
+ case GNUNET_ATS_QUALITY_NET_DISTANCE:
+ old->atsp_distance = ntohl (atsi[i].value);
+ break;
+ case GNUNET_ATS_COST_WAN:
+ old->atsp_cost_wan = ntohl (atsi[i].value);
+ break;
+ case GNUNET_ATS_COST_LAN:
+ old->atsp_cost_lan = ntohl (atsi[i].value);
+ break;
+ case GNUNET_ATS_COST_WLAN:
+ old->atsp_cost_wlan = ntohl (atsi[i].value);
+ break;
+ case GNUNET_ATS_NETWORK_TYPE:
+ old->atsp_network_type = ntohl (atsi[i].value);
+ break;
+
+ default:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Received unsupported ATS type %u\n", ntohl (atsi[i].type));
+ GNUNET_break (0);
+ break;
+ }
+#if HAVE_LIBGLPK
+ if (ats_mode == MLP)
+ GAS_mlp_address_update (mlp, addresses, old);
+#endif
+}
+
+
+/**
+ * Delete an address
+ *
+ * If session != 0, just the session is deleted, the address itself still exists
+ * If session == 0, remove full address
+ * If session == 0 and addrlen == 0, destroy inbound address
+ *
+ * @param cls unused
+ * @param key unused
+ * @param value the 'struct ATS_Address'
+ * @return GNUNET_OK (continue to iterate)
+ */
+static int
+destroy_by_session_id (void *cls, const GNUNET_HashCode * key, void *value)
+{
+ const struct ATS_Address *info = cls;
+ struct ATS_Address *aa = value;
+
+ GNUNET_assert (0 ==
+ memcmp (&aa->peer, &info->peer,
+ sizeof (struct GNUNET_PeerIdentity)));
+ /* session == 0, remove full address */
+ if ((info->session_id == 0) && (0 == strcmp (info->plugin, aa->plugin)) &&
+ (aa->addr_len == info->addr_len) &&
+ (0 == memcmp (info->addr, aa->addr, aa->addr_len)))
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Deleting address for peer `%s': `%s' %u\n",
+ GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
+#endif
+ if (GNUNET_YES == destroy_address (aa))
+ recalculate_assigned_bw ();
+ return GNUNET_OK;
+ }
+ /* session != 0, just remove session */
+ if (aa->session_id != info->session_id)
+ return GNUNET_OK; /* irrelevant */
+ if (aa->session_id != 0)
+ GNUNET_break (0 == strcmp (info->plugin, aa->plugin));
+ /* session died */
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Deleting session for peer `%s': `%s' %u\n",
+ GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
+#endif
+ aa->session_id = 0;
+
+ if (GNUNET_YES == aa->active)
+ {
+ aa->active = GNUNET_NO;
+ active_addr_count--;
+ recalculate_assigned_bw ();
+ }
+
+ /* session == 0 and addrlen == 0 : destroy address */
+ if (aa->addr_len == 0)
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Deleting session and address for peer `%s': `%s' %u\n",
+ GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
+#endif
+ (void) destroy_address (aa);
+ }
+ else
+ {
+ /* session was set to 0, update address */
+#if HAVE_LIBGLPK
+ if (ats_mode == MLP)
+ GAS_mlp_address_update (mlp, addresses, aa);
+#endif
+ }
+
+ return GNUNET_OK;
+}
+
+void
+GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name, const void *plugin_addr,
+ size_t plugin_addr_len, uint32_t session_id)
+{
+ struct ATS_Address *aa;