/*
This file is part of GNUnet.
- Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009-2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
};
-/**
- * Entry in linked list for a try-connect request.
- */
-struct GNUNET_TRANSPORT_TryConnectHandle
-{
- /**
- * For the DLL.
- */
- struct GNUNET_TRANSPORT_TryConnectHandle *prev;
-
- /**
- * For the DLL.
- */
- struct GNUNET_TRANSPORT_TryConnectHandle *next;
-
- /**
- * Peer we should try to connect to.
- */
- struct GNUNET_PeerIdentity pid;
-
- /**
- * Transport service handle this request is part of.
- */
- struct GNUNET_TRANSPORT_Handle *th;
-
- /**
- * Message transmission request to communicate to service.
- */
- struct GNUNET_TRANSPORT_TransmitHandle *tth;
-
- /**
- * Function to call upon completion (of request transmission).
- */
- GNUNET_TRANSPORT_TryConnectCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
-};
-
-
/**
* Entry in linked list for all offer-HELLO requests.
*/
*/
struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
- /**
- * Linked list of pending try connect requests head
- */
- struct GNUNET_TRANSPORT_TryConnectHandle *tc_head;
-
- /**
- * Linked list of pending try connect requests tail
- */
- struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail;
-
/**
* Linked list of pending offer HELLO requests head
*/
* A neighbour has not gotten a SEND_OK in a while. Print a warning.
*
* @param cls the `struct Neighbour`
- * @param tc scheduler context
*/
static void
-do_warn_unready (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_warn_unready (void *cls)
{
struct Neighbour *n = cls;
struct GNUNET_TIME_Relative delay;
* network congestion. Notify the initiator and clean up.
*
* @param cls the `struct GNUNET_TRANSPORT_TransmitHandle`
- * @param tc scheduler context
*/
static void
-timeout_request_due_to_congestion (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_request_due_to_congestion (void *cls)
{
struct GNUNET_TRANSPORT_TransmitHandle *th = cls;
struct Neighbour *n = th->neighbour;
* list or the peer message queues to the service.
*
* @param cls transport service to schedule a transmission for
- * @param tc scheduler context
*/
static void
-schedule_transmission_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+schedule_transmission_task (void *cls)
{
struct GNUNET_TRANSPORT_Handle *h = cls;
size_t size;
* Try again to connect to transport service.
*
* @param cls the handle to the transport service
- * @param tc scheduler context
*/
static void
-reconnect (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+reconnect (void *cls)
{
struct GNUNET_TRANSPORT_Handle *h = cls;
h->reconnect_task = NULL;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- {
- /* shutdown, just give up */
- return;
- }
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to transport service.\n");
GNUNET_assert (NULL == h->client);
}
-/**
- * Send #GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT message to the
- * service.
- *
- * @param cls the `struct GNUNET_TRANSPORT_TryConnectHandle`
- * @param size number of bytes available in @a buf
- * @param buf where to copy the message
- * @return number of bytes copied to @a buf
- */
-static size_t
-send_try_connect (void *cls,
- size_t size,
- void *buf)
-{
- struct GNUNET_TRANSPORT_TryConnectHandle *tch = cls;
- struct TransportRequestConnectMessage msg;
-
- tch->tth = NULL;
- if (NULL == buf)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Discarding REQUEST_CONNECT request to `%s' due to error in transport service connection.\n",
- GNUNET_i2s (&tch->pid));
- if (NULL != tch->cb)
- tch->cb (tch->cb_cls,
- GNUNET_SYSERR);
- GNUNET_TRANSPORT_try_connect_cancel (tch);
- return 0;
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting `%s' request with respect to `%s'.\n",
- "REQUEST_CONNECT",
- GNUNET_i2s (&tch->pid));
- GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage));
- msg.header.size = htons (sizeof (struct TransportRequestConnectMessage));
- msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
- msg.reserved = htonl (0);
- msg.peer = tch->pid;
- memcpy (buf, &msg, sizeof (msg));
- if (NULL != tch->cb)
- tch->cb (tch->cb_cls, GNUNET_OK);
- GNUNET_TRANSPORT_try_connect_cancel (tch);
- return sizeof (struct TransportRequestConnectMessage);
-}
-
-
-/**
- * Ask the transport service to establish a connection to
- * the given peer.
- *
- * @param handle connection to transport service
- * @param target who we should try to connect to
- * @param cb callback to be called when request was transmitted to transport
- * service
- * @param cb_cls closure for the callback
- * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or
- * NULL on failure (cb will not be called)
- */
-struct GNUNET_TRANSPORT_TryConnectHandle *
-GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
- const struct GNUNET_PeerIdentity *target,
- GNUNET_TRANSPORT_TryConnectCallback cb,
- void *cb_cls)
-{
- struct GNUNET_TRANSPORT_TryConnectHandle *tch;
-
- if (NULL == handle->client)
- return NULL;
- tch = GNUNET_new (struct GNUNET_TRANSPORT_TryConnectHandle);
- tch->th = handle;
- tch->pid = *target;
- tch->cb = cb;
- tch->cb_cls = cb_cls;
- tch->tth = schedule_control_transmit (handle,
- sizeof (struct TransportRequestConnectMessage),
- &send_try_connect, tch);
- GNUNET_CONTAINER_DLL_insert (handle->tc_head,
- handle->tc_tail,
- tch);
- return tch;
-}
-
-
-/**
- * Cancel the request to transport to try a connect
- * Callback will not be called
- *
- * @param tch the handle to cancel
- */
-void
-GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch)
-{
- struct GNUNET_TRANSPORT_Handle *th;
-
- th = tch->th;
- if (NULL != tch->tth)
- cancel_control_transmit (th, tch->tth);
- GNUNET_CONTAINER_DLL_remove (th->tc_head,
- th->tc_tail,
- tch);
- GNUNET_free (tch);
-}
-
-
/**
* Send HELLO message to the service.
*
struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls;
struct GNUNET_MessageHeader *msg = ohh->msg;
uint16_t ssize;
- struct GNUNET_SCHEDULER_TaskContext tc;
- tc.read_ready = NULL;
- tc.write_ready = NULL;
- tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
if (NULL == buf)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Timeout while trying to transmit `%s' request.\n",
"HELLO");
if (NULL != ohh->cont)
- ohh->cont (ohh->cls,
- &tc);
+ ohh->cont (ohh->cls);
GNUNET_free (msg);
GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head,
ohh->th->oh_tail,
msg,
ssize);
GNUNET_free (msg);
- tc.reason = GNUNET_SCHEDULER_REASON_READ_READY;
if (NULL != ohh->cont)
- ohh->cont (ohh->cls,
- &tc);
+ ohh->cont (ohh->cls);
GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head,
ohh->th->oh_tail,
ohh);
* Task to call the HelloUpdateCallback of the GetHelloHandle
*
* @param cls the `struct GNUNET_TRANSPORT_GetHelloHandle`
- * @param tc the scheduler task context
*/
static void
-call_hello_update_cb_async (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+call_hello_update_cb_async (void *cls)
{
struct GNUNET_TRANSPORT_GetHelloHandle *ghh = cls;
}
GNUNET_free_non_null (handle->my_hello);
handle->my_hello = NULL;
- GNUNET_assert (NULL == handle->tc_head);
- GNUNET_assert (NULL == handle->tc_tail);
GNUNET_assert (NULL == handle->hwl_head);
GNUNET_assert (NULL == handle->hwl_tail);
GNUNET_CONTAINER_heap_destroy (handle->ready_heap);
n = neighbour_find (handle, target);
if (NULL == n)
{
- /* use GNUNET_TRANSPORT_try_connect first, only use this function
+ /* only use this function
* once a connection has been established */
GNUNET_assert (0);
return NULL;