- GNUNET_SCHEDULER_cancel(sh->interface_task);
- sh->interface_task = NULL;
- }
- GNUNET_array_grow (sh->session_array, sh->session_array_size, 0);
- GNUNET_free (sh);
- sh = NULL;
-}
-
-/**
- * We would like to reset the address suggestion block time for this
- * peer
- *
- * @param sh handle
- * @param peer identity of the peer we want to reset
- */
-void
-GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct GNUNET_PeerIdentity *peer)
-{
- struct PendingMessage *p;
- struct ResetBackoffMessage *m;
-
- p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct ResetBackoffMessage));
- p->size = sizeof (struct ResetBackoffMessage);
- p->is_init = GNUNET_NO;
- m = (struct ResetBackoffMessage *) &p[1];
- m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF);
- m->header.size = htons (sizeof (struct ResetBackoffMessage));
- m->reserved = htonl (0);
- m->peer = *peer;
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
- do_transmit (sh);
-}
-
-/**
- * We would like to receive address suggestions for a peer. ATS will
- * respond with a call to the continuation immediately containing an address or
- * no address if none is available. ATS can suggest more addresses until we call
- * #GNUNET_ATS_suggest_address_cancel.
- *
- *
- * @param sh handle
- * @param peer identity of the peer we need an address for
- * @param cont the continuation to call with the address
- * @param cont_cls the cls for the continuation
- * @return suggest handle
- */
-struct GNUNET_ATS_SuggestHandle *
-GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct GNUNET_PeerIdentity *peer,
- GNUNET_ATS_AddressSuggestionCallback cont,
- void *cont_cls)
-{
- struct PendingMessage *p;
- struct RequestAddressMessage *m;
- struct GNUNET_ATS_SuggestHandle *s;
-
- // FIXME: ATS needs to remember this in case of
- // a disconnect!
- p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct RequestAddressMessage));
- p->size = sizeof (struct RequestAddressMessage);
- p->is_init = GNUNET_NO;
- m = (struct RequestAddressMessage *) &p[1];
- m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS);
- m->header.size = htons (sizeof (struct RequestAddressMessage));
- m->reserved = htonl (0);
- m->peer = *peer;
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
- do_transmit (sh);
- s = GNUNET_new (struct GNUNET_ATS_SuggestHandle);
- s->id = (*peer);
- GNUNET_CONTAINER_DLL_insert_tail (sh->sug_head, sh->sug_tail, s);
- return s;
-}
-
-
-/**
- * We would like to stop receiving address updates for this peer
- *
- * @param sh handle
- * @param peer identity of the peer
- */
-void
-GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct GNUNET_PeerIdentity *peer)
-{
- struct PendingMessage *p;
- struct RequestAddressMessage *m;
- struct GNUNET_ATS_SuggestHandle *s;
-
- for (s = sh->sug_head; NULL != s; s = s->next)
- if (0 == memcmp(peer, &s->id, sizeof (s->id)))
- break;
- if (NULL == s)
- {
- GNUNET_break (0);
- return;
- }
- else
- {
- GNUNET_CONTAINER_DLL_remove (sh->sug_head, sh->sug_tail, s);
- GNUNET_free (s);
- }
-
- p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct RequestAddressMessage));
- p->size = sizeof (struct RequestAddressMessage);
- p->is_init = GNUNET_NO;
- m = (struct RequestAddressMessage *) &p[1];
- m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL);
- m->header.size = htons (sizeof (struct RequestAddressMessage));
- m->reserved = htonl (0);
- m->peer = *peer;
- GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
- do_transmit (sh);
-}
-
-
-/**
- * Test if a address and a session is known to ATS
- *
- * @param sh the scheduling handle
- * @param address the address
- * @param session the session
- * @return GNUNET_YES or GNUNET_NO
- */
-int
-GNUNET_ATS_session_known (struct GNUNET_ATS_SchedulingHandle *sh,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session)
-{
- int s;
- if (NULL != session)
- {
- if (NOT_FOUND != (s = find_session_id (sh, session, &address->peer)))