* This option will turn on the DEBUG loglevel for
* all processes controlled by this ARM!
*/
-#define DEBUG_ARM GNUNET_NO
+#define DEBUG_ARM GNUNET_YES
#endif
/**
* How long until we give up on transmitting the message?
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 150)
static int ok;
#include "gnunet_util_lib.h"
-#define DEBUG_TOPOLOGY GNUNET_YES
+#define DEBUG_TOPOLOGY GNUNET_NO
/**
* For how long do we blacklist a peer after a failed
#if DEBUG_TOPOLOGY
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core told us that we connected to `%s'\n",
+ "Core told us that we are connecting to `%s'\n",
GNUNET_i2s (peer));
#endif
connection_count++;
*/
struct NeighbourList *neighbour;
- /**
- * Opaque handle (specific to the plugin) for the
- * connection to our target; can be NULL.
- */
- void *plugin_handle;
-
/**
* What was the last latency observed for this plugin
* and peer? Invalid if connected is GNUNET_NO.
"Transmission to peer `%s' failed, marking connection as down.\n",
GNUNET_i2s(target));
rl->connected = GNUNET_NO;
- rl->plugin_handle = NULL;
}
if (!mq->internal_msg)
rl->transmit_ready = GNUNET_YES;
ntohs (mq->message->type),
GNUNET_i2s (&neighbour->id), rl->plugin->short_name);
#endif
- rl->plugin_handle
- = rl->plugin->api->send (rl->plugin->api->cls,
- rl->plugin_handle,
- rl,
- &neighbour->id,
- mq->priority,
- mq->message,
- GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &transmit_send_continuation, mq);
+ rl->plugin->api->send (rl->plugin->api->cls,
+ rl,
+ &neighbour->id,
+ mq->priority,
+ mq->message,
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &transmit_send_continuation, mq);
}
GNUNET_assert (rpos->neighbour == n);
if (GNUNET_YES == rpos->connected)
rpos->plugin->api->cancel (rpos->plugin->api->cls,
- rpos->plugin_handle,
rpos,
&n->id);
GNUNET_free (rpos);
* and generally forward to our receive callback.
*
* @param cls the "struct TransportPlugin *" we gave to the plugin
- * @param plugin_context value to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing)
* @param service_context value passed to the transport-service
* to identify the neighbour; will be NULL on the first
* call for a given peer
*/
static struct ReadyList *
plugin_env_receive (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
struct GNUNET_TIME_Relative latency,
const struct GNUNET_PeerIdentity *peer,
GNUNET_i2s(&n->id));
#endif
/* TODO: call stats */
- if ((service_context != NULL) &&
- (service_context->plugin_handle == plugin_context))
- {
- service_context->connected = GNUNET_NO;
- service_context->plugin_handle = NULL;
- }
+ if (service_context != NULL)
+ service_context->connected = GNUNET_NO;
disconnect_neighbour (n, GNUNET_YES);
return NULL;
}
}
service_context->timeout
= GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- service_context->plugin_handle = plugin_context;
service_context->latency = latency;
}
/* update traffic received amount ... */
* message to signal that the other peer disconnected.
*
* @param cls closure
- * @param plugin_context value to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing)
* @param service_context value passed to the transport-service
* to identify the neighbour; will be NULL on the first
* call for a given peer
*/
typedef struct ReadyList *
(*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
- void *plugin_context,
struct ReadyList *
service_context,
struct GNUNET_TIME_Relative
* a fresh connection to another peer.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL
* @param service_context value passed to the transport-service
* to identify the neighbour; NULL is used to indicate
* an urgent message. If the urgent message can not be
* for the next transmission call; or if the
* peer disconnected...); can be NULL
* @param cont_cls closure for cont
- * @return plugin_context that should be used next time for
- * sending messages to the specified peer
*/
-typedef void *
+typedef void
(*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
- void *plugin_context,
struct ReadyList * service_context,
const struct GNUNET_PeerIdentity *
target,
* closed after a getting this call.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL (if
- * NULL was returned from the transmit function); note
- * that use of NULL is dangerous since then this call may
- * cancel any session with the target peer (including
- * HELLO validation sessions), which is likely not what
- * is intended.
* @param service_context must correspond to the service context
* of the corresponding Transmit call; the plugin should
* not cancel a send call made with a different service
*/
typedef void
(*GNUNET_TRANSPORT_CancelFunction) (void *cls,
- void *plugin_context,
struct ReadyList * service_context,
const struct GNUNET_PeerIdentity *
target);
*/
struct GNUNET_SERVER_MessageHandler *handlers;
+ /**
+ * Handle for request of hostname resolution, non-NULL if pending.
+ */
+ struct GNUNET_RESOLVER_RequestHandle *hostname_dns;
+
/**
* ID of task used to update our addresses when one expires.
*/
};
-
-/**
- * Handle for request of hostname resolution, non-NULL if pending.
- */
-static struct GNUNET_RESOLVER_RequestHandle *hostname_dns;
-
-
/**
* Find the session handle for the given peer.
*/
know about this one, so we need to
notify transport service about disconnect */
session->plugin->env->receive (session->plugin->env->cls,
- session,
session->service_context,
GNUNET_TIME_UNIT_ZERO,
&session->target, NULL);
* a message using the plugin.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL
* @param service_context value passed to the transport-service
* to identify the neighbour
* @param target who should receive this message
* for the next transmission call; or if the
* peer disconnected...)
* @param cont_cls closure for cont
- * @return plugin_context that should be used next time for
- * sending messages to the specified peer
*/
-static void *
+static void
tcp_plugin_send (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
struct Plugin *plugin = cls;
- struct Session *session = plugin_context;
+ struct Session *session;
struct PendingMessage *pm;
struct PendingMessage *pme;
- if (session == NULL)
- session = find_session_by_target (plugin, target);
+ session = find_session_by_target (plugin, target);
pm = GNUNET_malloc (sizeof (struct PendingMessage) + ntohs (msg->size));
pm->msg = (struct GNUNET_MessageHeader *) &pm[1];
memcpy (pm->msg, msg, ntohs (msg->size));
plugin->env->sched,
target,
0, timeout, &session_try_connect, session);
- return session;
+ return;
}
GNUNET_assert (session != NULL);
GNUNET_assert (session->client != NULL);
"tcp", "Asked to transmit, added message to list.\n");
#endif
process_pending_messages (session);
- return session;
}
* closed after a getting this call.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL (if
- * NULL was returned from the transmit function); note
- * that use of NULL is dangerous since then this call may
- * cancel any session with the target peer (including
- * HELLO validation sessions), which is likely not what
- * is intended.
* @param service_context must correspond to the service context
* of the corresponding Transmit call; the plugin should
* not cancel a send call made with a different service
*/
static void
tcp_plugin_cancel (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
- struct Session *session = plugin_context;
+ struct Session *session;
struct PendingMessage *pm;
- if (session == NULL)
- {
-#if DEBUG_TCP
- GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
- "tcp",
- "Asked to cancel with `%4s' without specification of specifics; will try to find an applicable session\n",
- GNUNET_i2s(target));
-#endif
- session = find_session_by_target (plugin, target);
- }
+ session = find_session_by_target (plugin, target);
if (session == NULL)
{
GNUNET_break (0);
#endif
session->service_context
= plugin->env->receive (plugin->env->cls,
- session,
session->service_context,
latency, &session->target, msg);
/* update bandwidth used */
if (addr == NULL)
{
- hostname_dns = NULL;
+ plugin->hostname_dns = NULL;
return;
}
process_interfaces (plugin,
GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify,
plugin);
GNUNET_OS_network_interfaces_list (&process_interfaces, plugin);
- hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched,
- env->cfg,
- AF_UNSPEC,
- HOSTNAME_RESOLVE_TIMEOUT,
- &process_hostname_ips, plugin);
+ plugin->hostname_dns = GNUNET_RESOLVER_hostname_resolve (env->sched,
+ env->cfg,
+ AF_UNSPEC,
+ HOSTNAME_RESOLVE_TIMEOUT,
+ &process_hostname_ips, plugin);
return api;
}
while (NULL != (session = plugin->sessions))
disconnect_session (session);
- if (NULL != hostname_dns)
+ if (NULL != plugin->hostname_dns)
{
- GNUNET_RESOLVER_request_cancel (hostname_dns);
- hostname_dns = NULL;
+ GNUNET_RESOLVER_request_cancel (plugin->hostname_dns);
+ plugin->hostname_dns = NULL;
}
GNUNET_SERVICE_stop (plugin->service);
GNUNET_free (plugin->handlers);
* a message using the plugin.
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL
* @param service_context value passed to the transport-service
* to identify the neighbour
* @param target who should receive this message
* for the next transmission call; or if the
* peer disconnected...)
* @param cont_cls closure for cont
- * @return plugin_context that should be used next time for
- * sending messages to the specified peer
*/
-static void *
+static void
template_plugin_send (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
void *cont_cls)
{
// struct Plugin *plugin = cls;
- return NULL;
}
/**
+ * Function that can be used to force the plugin to disconnect
+ * from the given peer and cancel all previous transmissions
+ * (and their continuationc).
*
* @param cls closure
- * @param plugin_context value we were asked to pass to this plugin
- * to respond to the given peer (use is optional,
- * but may speed up processing), can be NULL (if
- * NULL was returned from the transmit function)
* @param service_context must correspond to the service context
* of the corresponding Transmit call; the plugin should
* not cancel a send call made with a different service
*/
static void
template_plugin_cancel (void *cls,
- void *plugin_context,
struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target)
{