+ &peer->hashPubKey, aa,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new address for peer `%s' %X\n",
+ GNUNET_i2s (peer), aa);
+#endif
+ old = aa;
+ }
+ else
+ {
+#if DEBUG_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Updated existing address for peer `%s' %p old session %u new session %u\n",
+ GNUNET_i2s (peer), old,
+ old->session_id, session_id);
+#endif
+ GNUNET_free_non_null (old->ats);
+ old->session_id = session_id;
+ old->ats = NULL;
+ old->ats_count = 0;
+ old->ats = aa->ats;
+ old->ats_count = aa->ats_count;
+ GNUNET_free (aa->plugin);
+ GNUNET_free (aa);
+ }
+ 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