+
+#if 0
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Found exact address: %s base address: %s\n",
+ (cac.exact_address != NULL) ? "YES" : "NO",
+ (cac.base_address != NULL) ? "YES" : "NO");
+#endif
+ if (cac.exact_address == NULL)
+ return cac.base_address;
+ return cac.exact_address;
+}
+
+
+static struct ATS_Address *
+lookup_address (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)
+{
+ struct ATS_Address *aa;
+ struct ATS_Address *old;
+
+ aa = create_address (peer,
+ plugin_name,
+ plugin_addr, plugin_addr_len,
+ session_id);
+
+ aa->mlp_information = NULL;
+ aa->ats = GNUNET_malloc (atsi_count * sizeof (struct GNUNET_ATS_Information));
+ aa->ats_count = atsi_count;
+ memcpy (aa->ats, atsi, atsi_count * sizeof (struct GNUNET_ATS_Information));
+
+ /* Get existing address or address with session == 0 */
+ old = find_address (peer, aa);
+ free_address (aa);
+ if (old == NULL)
+ {
+ return NULL;
+ }
+ else if (old->session_id != session_id)
+ {
+ return NULL;
+ }
+ return old;
+}
+
+
+#if 0
+static int
+compare_address_session_it (void *cls, const struct GNUNET_HashCode * key, void *value)
+{
+ struct CompareAddressContext *cac = cls;
+ struct ATS_Address *aa = value;
+
+ if ((aa->addr_len == cac->search->addr_len) && (0 == strcmp (aa->plugin, cac->search->plugin)))
+ {
+ if ((0 == memcmp (aa->addr, cac->search->addr, aa->addr_len)) && (aa->session_id == cac->search->session_id))
+ {
+ cac->exact_address = aa;
+ return GNUNET_NO;
+ }
+ }
+ return GNUNET_YES;