[core]
PORT = 12970
DEBUG = YES
-#PREFIX = xterm -e xterm -e valgrind --tool=memcheck
+PREFIX = valgrind --tool=memcheck
[testing]
WEAKRANDOM = YES
[core]
PORT = 22970
DEBUG = YES
-#PREFIX = xterm -e xterm -e valgrind --tool=memcheck
+PREFIX = valgrind --tool=memcheck
[testing]
WEAKRANDOM = YES
*/
static void
transmit_send_continuation (void *cls,
- struct ReadyList *rl,
const struct GNUNET_PeerIdentity *target,
int result)
{
struct MessageQueue *mq = cls;
+ struct ReadyList *rl;
struct SendOkMessage send_ok_msg;
struct NeighbourList *n;
GNUNET_assert (0 ==
memcmp (&n->id, target,
sizeof (struct GNUNET_PeerIdentity)));
- if (rl == NULL)
- {
- rl = n->plugins;
- while ((rl != NULL) && (rl->plugin != mq->plugin))
- rl = rl->next;
- GNUNET_assert (rl != NULL);
- }
+ rl = n->plugins;
+ while ((rl != NULL) && (rl->plugin != mq->plugin))
+ rl = rl->next;
+ GNUNET_assert (rl != NULL);
if (result == GNUNET_OK)
{
rl->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
GNUNET_i2s (&neighbour->id), rl->plugin->short_name);
#endif
rl->plugin->api->send (rl->plugin->api->cls,
- rl,
&neighbour->id,
mq->priority,
mq->message,
n->plugins = rpos->next;
GNUNET_assert (rpos->neighbour == n);
if (GNUNET_YES == rpos->connected)
- rpos->plugin->api->cancel (rpos->plugin->api->cls,
- rpos,
- &n->id);
+ rpos->plugin->api->disconnect (rpos->plugin->api->cls,
+ &n->id);
GNUNET_free (rpos);
}
* and generally forward to our receive callback.
*
* @param cls the "struct TransportPlugin *" we gave to the plugin
- * @param service_context value passed to the transport-service
- * to identify the neighbour; will be NULL on the first
- * call for a given peer
* @param latency estimated latency for communicating with the
* given peer
* @param peer (claimed) identity of the other peer
* for future receive calls for messages from this
* particular peer
*/
-static struct ReadyList *
+static void
plugin_env_receive (void *cls,
- struct ReadyList *service_context,
struct GNUNET_TIME_Relative latency,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
htons (sizeof (struct GNUNET_MessageHeader)),
htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ACK)
};
+ struct ReadyList *service_context;
struct TransportPlugin *plugin = cls;
struct TransportClient *cpos;
struct InboundMessage *im;
uint16_t msize;
struct NeighbourList *n;
- if (service_context != NULL)
- {
- n = service_context->neighbour;
- GNUNET_assert (n != NULL);
- }
- else
+ n = find_neighbour (peer);
+ if (n == NULL)
{
- n = find_neighbour (peer);
- if (n == NULL)
- {
- if (message == NULL)
- return NULL; /* disconnect of peer already marked down */
- n = setup_new_neighbour (peer);
- }
- service_context = n->plugins;
- while ((service_context != NULL) && (plugin != service_context->plugin))
- service_context = service_context->next;
- GNUNET_assert ((plugin->api->send == NULL) ||
- (service_context != NULL));
+ if (message == NULL)
+ return; /* disconnect of peer already marked down */
+ n = setup_new_neighbour (peer);
}
+ service_context = n->plugins;
+ while ( (service_context != NULL) &&
+ (plugin != service_context->plugin) )
+ service_context = service_context->next;
+ GNUNET_assert ((plugin->api->send == NULL) ||
+ (service_context != NULL));
if (message == NULL)
{
#if DEBUG_TRANSPORT
if (service_context != NULL)
service_context->connected = GNUNET_NO;
disconnect_neighbour (n, GNUNET_YES);
- return NULL;
+ return;
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
/* TODO: call stats */
GNUNET_assert ( (service_context == NULL) ||
(NULL != service_context->neighbour) );
- return service_context;
+ return;
}
switch (ntohs (message->type))
{
}
GNUNET_assert ( (service_context == NULL) ||
(NULL != service_context->neighbour) );
- return service_context;
}
#include "gnunet_scheduler_lib.h"
#include "gnunet_transport_service.h"
-/**
- * Opaque internal context for a particular peer of the transport
- * service. Plugins will be given a pointer to this type and, if
- * cheaply possible, should pass this pointer back to the transport
- * service whenever additional messages from the same peer are
- * received.
- */
-struct ReadyList;
-
/**
* Function called by the transport for each received message.
* This function should also be called with "NULL" for the
* message to signal that the other peer disconnected.
*
* @param cls closure
- * @param service_context value passed to the transport-service
- * to identify the neighbour; will be NULL on the first
- * call for a given peer
* @param latency estimated latency for communicating with the
* given peer; should be set to GNUNET_TIME_UNIT_FOREVER_REL
* until the transport has seen messages transmitted in
* using this one plugin actually works
* @param peer (claimed) identity of the other peer
* @param message the message, NULL if peer was disconnected
- * @return the new service_context that the plugin should use
- * for future receive calls for messages from this
- * particular peer
*/
-typedef struct ReadyList *
- (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
- struct ReadyList *
- service_context,
- struct GNUNET_TIME_Relative
- latency,
- const struct GNUNET_PeerIdentity
- * peer,
- const struct GNUNET_MessageHeader
- * message);
+typedef void (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls,
+ struct GNUNET_TIME_Relative
+ latency,
+ const struct GNUNET_PeerIdentity
+ * peer,
+ const struct GNUNET_MessageHeader
+ * message);
/**
* upon "completion".
*
* @param cls closure
- * @param service_context value passed to the transport-service
- * to identify the neighbour
* @param target who was the recipient of the message?
* @param result GNUNET_OK on success
* GNUNET_SYSERR if the target disconnected;
*/
typedef void
(*GNUNET_TRANSPORT_TransmitContinuation) (void *cls,
- struct ReadyList *
- service_context,
const struct GNUNET_PeerIdentity *
target, int result);
+
/**
* Function that can be used by the transport service to transmit
* a message using the plugin. Note that in the case of a
* a fresh connection to another peer.
*
* @param cls closure
- * @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
- * scheduled for immediate transmission, the plugin is to
- * call the continuation with failure immediately
* @param target who should receive this message
* @param priority how important is the message?
* @param msg the message to transmit
*/
typedef void
(*GNUNET_TRANSPORT_TransmitFunction) (void *cls,
- struct ReadyList * service_context,
const struct GNUNET_PeerIdentity *
target,
unsigned int priority,
* closed after a getting this call.
*
* @param cls closure
- * @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
- * context pointer! Never NULL.
* @param target peer for which the last transmission is
* to be cancelled
*/
typedef void
- (*GNUNET_TRANSPORT_CancelFunction) (void *cls,
- struct ReadyList * service_context,
- const struct GNUNET_PeerIdentity *
- target);
+ (*GNUNET_TRANSPORT_DisconnectFunction) (void *cls,
+ const struct GNUNET_PeerIdentity *
+ target);
/**
GNUNET_TRANSPORT_TransmitFunction send;
/**
- * Function that can be used to force the plugin to disconnect
- * from the given peer and cancel all previous transmissions
- * (and their continuationc).
+ * Function that can be used to force the plugin to disconnect from
+ * the given peer and cancel all previous transmissions (and their
+ * continuations). Note that if the transport does not have
+ * sessions / persistent connections (for example, UDP), this
+ * function may very well do nothing.
*/
- GNUNET_TRANSPORT_CancelFunction cancel;
+ GNUNET_TRANSPORT_DisconnectFunction disconnect;
/**
* Function to pretty-print addresses. NOTE: this function is not
*/
struct GNUNET_SERVER_Client *client;
- /**
- * gnunet-service-transport context for this connection.
- */
- struct ReadyList *service_context;
-
/**
* Messages currently pending for transmission
* to this peer, if any.
#endif
if (pm->transmit_cont != NULL)
pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
&session->target, GNUNET_SYSERR);
GNUNET_free (pm);
}
session->pending_messages = pm->next;
if (pm->transmit_cont != NULL)
pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
&session->target, GNUNET_OK);
GNUNET_free (pm);
session->gen_time[session->out_msg_counter % ACK_LOG_SIZE]
session->pending_messages = pm->next;
if (NULL != pm->transmit_cont)
pm->transmit_cont (pm->transmit_cont_cls,
- session->service_context,
&session->target, GNUNET_SYSERR);
GNUNET_free (pm);
}
know about this one, so we need to
notify transport service about disconnect */
session->plugin->env->receive (session->plugin->env->cls,
- session->service_context,
GNUNET_TIME_UNIT_ZERO,
&session->target, NULL);
}
*/
static void
tcp_plugin_send (void *cls,
- struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
const struct GNUNET_MessageHeader *msg,
session->quota_in = plugin->env->default_quota_in;
session->expecting_welcome = GNUNET_YES;
session->pending_messages = pm;
- session->service_context = service_context;
session->ic = GNUNET_PEERINFO_iterate (plugin->env->cfg,
plugin->env->sched,
target,
}
GNUNET_assert (session != NULL);
GNUNET_assert (session->client != NULL);
- session->service_context = service_context;
/* append pm to pending_messages list */
pme = session->pending_messages;
if (pme == NULL)
* closed after a getting this call.
*
* @param cls closure
- * @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
- * context pointer! Never NULL.
* @param target peer for which the last transmission is
* to be cancelled
*/
static void
-tcp_plugin_cancel (void *cls,
- struct ReadyList *service_context,
- const struct GNUNET_PeerIdentity *target)
+tcp_plugin_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
struct Session *session;
pm->transmit_cont_cls = NULL;
pm = pm->next;
}
- session->service_context = NULL;
if (session->client != NULL)
{
GNUNET_SERVER_client_drop (session->client);
"Forwarding data of type %u to transport service.\n",
ntohs (msg->type));
#endif
- session->service_context
- = plugin->env->receive (plugin->env->cls,
- session->service_context,
- latency, &session->target, msg);
+ plugin->env->receive (plugin->env->cls,
+ latency, &session->target, msg);
/* update bandwidth used */
session->last_received += msize;
update_quota (session, GNUNET_NO);
api->cls = plugin;
api->validate = &tcp_plugin_validate;
api->send = &tcp_plugin_send;
- api->cancel = &tcp_plugin_cancel;
+ api->disconnect = &tcp_plugin_disconnect;
api->address_pretty_printer = &tcp_plugin_address_pretty_printer;
api->set_receive_quota = &tcp_plugin_set_receive_quota;
api->address_suggested = &tcp_plugin_address_suggested;
* a message using the plugin.
*
* @param cls closure
- * @param service_context value passed to the transport-service
- * to identify the neighbour
* @param target who should receive this message
* @param priority how important is the message
* @param msg the message to transmit
*/
static void
template_plugin_send (void *cls,
- struct ReadyList *service_context,
const struct GNUNET_PeerIdentity *target,
unsigned int priority,
const struct GNUNET_MessageHeader *msg,
* (and their continuationc).
*
* @param cls closure
- * @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
- * context pointer! Never NULL.
- * @param target peer for which the last transmission is
- * to be cancelled
+ * @param target peer from which to disconnect
*/
static void
-template_plugin_cancel (void *cls,
- struct ReadyList *service_context,
- const struct GNUNET_PeerIdentity *target)
+template_plugin_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *target)
{
// struct Plugin *plugin = cls;
// FIXME
api->cls = plugin;
api->validate = &template_plugin_validate;
api->send = &template_plugin_send;
- api->cancel = &template_plugin_cancel;
+ api->disconnect = &template_plugin_disconnect;
api->address_pretty_printer = &template_plugin_address_pretty_printer;
api->set_receive_quota = &template_plugin_set_receive_quota;
api->address_suggested = &template_plugin_address_suggested;
/**
* Initialize Environment for this plugin
*/
-struct ReadyList *
+static void
receive(void *cls,
- struct ReadyList *
- service_context,
struct GNUNET_TIME_Relative
latency,
const struct GNUNET_PeerIdentity
const struct GNUNET_MessageHeader
* message)
{
- return NULL;
+ /* do nothing */
}
void notify_address(void *cls,