{
struct GNUNET_SERVICE_Client *client = listener->client;
+ GNUNET_MQ_destroy (listener->client_mq);
+ listener->client_mq = NULL;
+
listener->client = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting listener client\n");
GNUNET_SERVICE_client_drop (client);
return;
}
- if (NULL != listener->client_mq)
- {
- GNUNET_MQ_destroy (listener->client_mq);
- listener->client_mq = NULL;
- }
GNUNET_CADET_close_port (listener->open_port);
GNUNET_CONTAINER_DLL_remove (listeners_head,
listeners_tail,
GNUNET_free (op->spec);
op->spec = NULL;
}
- if (NULL != op->mq)
- {
- GNUNET_MQ_destroy (op->mq);
- op->mq = NULL;
- }
if (NULL != (channel = op->channel))
{
op->channel = NULL;
_GSS_operation_destroy (set->ops_head, GNUNET_NO);
set->vt->destroy_set (set->state);
set->state = NULL;
- if (NULL != set->client_mq)
- {
- GNUNET_MQ_destroy (set->client_mq);
- set->client_mq = NULL;
- }
if (NULL != set->iter)
{
GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter);
}
-/**
- * Clean up after a client has disconnected
- *
- * @param cls closure, unused
- * @param client the client to clean up after
- * @param internal_cls our client-specific internal data structure
- */
-static void
-client_disconnect_cb (void *cls,
- struct GNUNET_SERVICE_Client *client,
- void *internal_cls)
-{
- struct Listener *listener;
- struct Set *set;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "client disconnected, cleaning up\n");
- set = set_get (client);
- if (NULL != set)
- {
- set->client = NULL;
- set_destroy (set);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client's set destroyed\n");
- }
- listener = listener_get (client);
- if (NULL != listener)
- {
- listener->client = NULL;
- listener_destroy (listener);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client's listener destroyed\n");
- }
-}
-
-
/**
* Destroy an incoming request from a remote peer
*
GNUNET_free (incoming->spec);
incoming->spec = NULL;
}
- if (NULL != incoming->mq)
- {
- GNUNET_MQ_destroy (incoming->mq);
- incoming->mq = NULL;
- }
if (NULL != (channel = incoming->channel))
{
incoming->channel = NULL;
}
+/**
+ * Clean up after a client has disconnected
+ *
+ * @param cls closure, unused
+ * @param client the client to clean up after
+ * @param internal_cls our client-specific internal data structure
+ */
+static void
+client_disconnect_cb (void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ void *internal_cls)
+{
+ struct Set *set;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "client disconnected, cleaning up\n");
+ set = set_get (client);
+ if (NULL != set)
+ {
+ set->client = NULL;
+ set_destroy (set);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client's set destroyed\n");
+ }
+ struct Listener *listener = listener_get (client);
+ struct Operation *op = incoming_head;
+ if (NULL != listener)
+ {
+ /* destroy all incoming operations whose client just
+ * got destroyed */
+ while (NULL != op)
+ {
+ struct Operation *curr = op;
+ op = op->next;
+ if ( (GNUNET_YES == curr->is_incoming) &&
+ (curr->listener == listener) )
+ incoming_destroy (curr);
+ }
+ listener->client = NULL;
+ listener_destroy (listener);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client's listener destroyed\n");
+ }
+}
+
+
/**
* Suggest the given request to the listener. The listening client can
* then accept or reject the remote request.
listener = op->listener;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received P2P operation request (op %u, port %s) for active listener\n",
- ntohl (msg->operation),
+ (uint32_t) ntohl (msg->operation),
GNUNET_h2s (&listener->app_id));
incoming_suggest (op,
listener);
el.data = &msg[1];
el.element_type = ntohs (msg->element_type);
GNUNET_SET_element_hash (&el, &hash);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client inserts element %s of size %u\n",
- GNUNET_h2s (&hash),
- el.size);
ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements,
&hash);
if (NULL == ee)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client inserts element %s of size %u\n",
+ GNUNET_h2s (&hash),
+ el.size);
ee = GNUNET_malloc (el.size + sizeof *ee);
ee->element.size = el.size;
GNUNET_memcpy (&ee[1],
}
else if (GNUNET_YES == _GSS_is_element_of_set (ee, set))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client inserted element %s of size %u twice (ignored)\n",
+ GNUNET_h2s (&hash),
+ el.size);
+
/* same element inserted twice */
return;
}
.generation = set->current_generation,
.added = GNUNET_YES
};
- GNUNET_array_append (ee->mutations, ee->mutations_size, mut);
+ GNUNET_array_append (ee->mutations,
+ ee->mutations_size,
+ mut);
}
set->vt->add (set->state, ee);
msg = (const struct GNUNET_SET_ElementMessage *) m;
el.size = ntohs (m->size) - sizeof *msg;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client removes element of size %u\n",
- el.size);
el.data = &msg[1];
el.element_type = ntohs (msg->element_type);
GNUNET_SET_element_hash (&el, &hash);
if (NULL == ee)
{
/* Client tried to remove non-existing element. */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client removes non-existing element of size %u\n",
+ el.size);
return;
}
if (GNUNET_NO == _GSS_is_element_of_set (ee, set))
{
/* Client tried to remove element twice */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client removed element of size %u twice (ignored)\n",
+ el.size);
return;
}
else
.generation = set->current_generation,
.added = GNUNET_NO
};
- GNUNET_array_append (ee->mutations, ee->mutations_size, mut);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client removes element of size %u\n",
+ el.size);
+
+ GNUNET_array_append (ee->mutations,
+ ee->mutations_size,
+ mut);
}
set->vt->remove (set->state, ee);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client created new set (operation %u)\n",
- ntohl (msg->operation));
+ (uint32_t) ntohl (msg->operation));
if (NULL != set_get (client))
{
/* There can only be one set per client */
*
* @param cls closure
* @param channel new handle to the channel
- * @param initiator peer that started the channel
- * @param port Port this channel is for.
- * @param options Unused.
+ * @param source peer that started the channel
* @return initial channel context for the channel
* returns NULL on error
*/
static void *
channel_new_cb (void *cls,
struct GNUNET_CADET_Channel *channel,
- const struct GNUNET_PeerIdentity *initiator,
- const struct GNUNET_HashCode *port,
- enum GNUNET_CADET_ChannelOption options)
+ const struct GNUNET_PeerIdentity *source)
{
static const struct SetVT incoming_vt = {
.msg_handler = &handle_incoming_msg,
incoming = GNUNET_new (struct Operation);
incoming->listener = listener;
incoming->is_incoming = GNUNET_YES;
- incoming->peer = *initiator;
+ incoming->peer = *source;
incoming->channel = channel;
- incoming->mq = GNUNET_CADET_mq_create (incoming->channel);
+ incoming->mq = GNUNET_CADET_get_mq (incoming->channel);
incoming->vt = &incoming_vt;
incoming->timeout_task
= GNUNET_SCHEDULER_add_delayed (INCOMING_CHANNEL_TIMEOUT,
}
+/**
+ * Function called whenever a channel is destroyed. Should clean up
+ * any associated state. It must NOT call
+ * GNUNET_CADET_channel_destroy() on the channel.
+ *
+ * The peer_disconnect function is part of a a virtual table set initially either
+ * when a peer creates a new channel with us, or once we create
+ * a new channel ourselves (evaluate).
+ *
+ * Once we know the exact type of operation (union/intersection), the vt is
+ * replaced with an operation specific instance (_GSS_[op]_vt).
+ *
+ * @param channel_ctx place where local state associated
+ * with the channel is stored
+ * @param channel connection to the other end (henceforth invalid)
+ */
+static void
+channel_end_cb (void *channel_ctx,
+ const struct GNUNET_CADET_Channel *channel)
+{
+ struct Operation *op = channel_ctx;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "channel_end_cb called\n");
+ op->channel = NULL;
+ op->keep++;
+ /* the vt can be null if a client already requested canceling op. */
+ if (NULL != op->vt)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "calling peer disconnect due to channel end\n");
+ op->vt->peer_disconnect (op);
+ }
+ op->keep--;
+ if (0 == op->keep)
+ {
+ /* cadet will never call us with the context again! */
+ GNUNET_free (op);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "channel_end_cb finished\n");
+}
+
+
+/**
+ * Function called whenever an MQ-channel's transmission window size changes.
+ *
+ * The first callback in an outgoing channel will be with a non-zero value
+ * and will mean the channel is connected to the destination.
+ *
+ * For an incoming channel it will be called immediately after the
+ * #GNUNET_CADET_ConnectEventHandler, also with a non-zero value.
+ *
+ * @param cls Channel closure.
+ * @param channel Connection to the other end (henceforth invalid).
+ * @param window_size New window size. If the is more messages than buffer size
+ * this value will be negative..
+ */
+static void
+channel_window_cb (void *cls,
+ const struct GNUNET_CADET_Channel *channel,
+ int window_size)
+{
+ /* FIXME: not implemented, we could do flow control here... */
+}
+
+/**
+ * FIXME: hack-job. Migrate to proper handler array use!
+ *
+ * @param cls local state associated with the channel.
+ * @param message The actual message.
+ */
+static int
+check_p2p_message (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * FIXME: hack-job. Migrate to proper handler array use!
+ *
+ * Functions with this signature are called whenever a message is
+ * received via a cadet channel.
+ *
+ * The msg_handler is a virtual table set in initially either when a peer
+ * creates a new channel with us, or once we create a new channel
+ * ourselves (evaluate).
+ *
+ * Once we know the exact type of operation (union/intersection), the vt is
+ * replaced with an operation specific instance (_GSS_[op]_vt).
+ *
+ * @param cls local state associated with the channel.
+ * @param message The actual message.
+ */
+static void
+handle_p2p_message (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct Operation *op = cls;
+ int ret;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Dispatching cadet message (type: %u)\n",
+ ntohs (message->type));
+ /* do this before the handler, as the handler might kill the channel */
+ GNUNET_CADET_receive_done (op->channel);
+ if (NULL != op->vt)
+ ret = op->vt->msg_handler (op,
+ message);
+ else
+ ret = GNUNET_SYSERR;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Handled cadet message (type: %u)\n",
+ ntohs (message->type));
+ if (GNUNET_OK != ret)
+ GNUNET_CADET_channel_destroy (op->channel);
+}
+
+
/**
* Called when a client wants to create a new listener.
*
const struct GNUNET_SET_ListenMessage *msg)
{
struct GNUNET_SERVICE_Client *client = cls;
+ struct GNUNET_MQ_MessageHandler cadet_handlers[] = {
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };
struct Listener *listener;
- struct Operation *op;
if (NULL != listener_get (client))
{
GNUNET_CONTAINER_DLL_insert_tail (listeners_head,
listeners_tail,
listener);
- listener->open_port = GNUNET_CADET_open_port (cadet,
- &msg->app_id,
- &channel_new_cb,
- listener);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New listener created (op %u, port %s)\n",
listener->operation,
GNUNET_h2s (&listener->app_id));
-
+ listener->open_port = GNUNET_CADET_open_porT (cadet,
+ &msg->app_id,
+ &channel_new_cb,
+ listener,
+ &channel_window_cb,
+ &channel_end_cb,
+ cadet_handlers);
/* check for existing incoming requests the listener might be interested in */
- for (op = incoming_head; NULL != op; op = op->next)
+ for (struct Operation *op = incoming_head; NULL != op; op = op->next)
{
if (NULL == op->spec)
continue; /* no details available yet */
pm = GNUNET_new (struct PendingMutation);
pm->mutation_message = GNUNET_copy_message (m);
pm->set = set;
- GNUNET_CONTAINER_DLL_insert (set->content->pending_mutations_head,
- set->content->pending_mutations_tail,
- pm);
+ GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head,
+ set->content->pending_mutations_tail,
+ pm);
return;
}
execute_mutation (set, m);
const struct GNUNET_SET_EvaluateMessage *msg)
{
struct GNUNET_SERVICE_Client *client = cls;
+ struct Operation *op = GNUNET_new (struct Operation);
+ const struct GNUNET_MQ_MessageHandler cadet_handlers[] = {
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_handler_end ()
+ };
struct Set *set;
struct OperationSpecification *spec;
- struct Operation *op;
const struct GNUNET_MessageHeader *context;
set = set_get (client);
if (NULL == set)
{
GNUNET_break (0);
+ GNUNET_free (op);
GNUNET_SERVICE_client_drop (client);
return;
}
spec->set = set;
spec->result_mode = ntohl (msg->result_mode);
spec->client_request_id = ntohl (msg->request_id);
+ spec->byzantine = msg->byzantine;
+ spec->byzantine_lower_bound = msg->byzantine_lower_bound;
+ spec->force_full = msg->force_full;
+ spec->force_delta = msg->force_delta;
context = GNUNET_MQ_extract_nested_mh (msg);
- op = GNUNET_new (struct Operation);
op->spec = spec;
// Advance generation values, so that
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating new CADET channel to port %s\n",
GNUNET_h2s (&msg->app_id));
- op->channel = GNUNET_CADET_channel_create (cadet,
+ op->channel = GNUNET_CADET_channel_creatE (cadet,
op,
&msg->target_peer,
&msg->app_id,
- GNUNET_CADET_OPTION_RELIABLE);
- op->mq = GNUNET_CADET_mq_create (op->channel);
+ GNUNET_CADET_OPTION_RELIABLE,
+ &channel_window_cb,
+ &channel_end_cb,
+ cadet_handlers);
+ op->mq = GNUNET_CADET_get_mq (op->channel);
set->vt->evaluate (op,
context);
GNUNET_SERVICE_client_continue (client);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client requested cancel for op %u\n",
- ntohl (msg->request_id));
+ (uint32_t) ntohl (msg->request_id));
found = GNUNET_NO;
for (op = set->ops_head; NULL != op; op = op->next)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client accepting request %u\n",
- ntohl (msg->accept_reject_id));
+ (uint32_t) ntohl (msg->accept_reject_id));
GNUNET_assert (GNUNET_YES == op->is_incoming);
op->is_incoming = GNUNET_NO;
GNUNET_CONTAINER_DLL_remove (incoming_head,
op);
op->spec->client_request_id = ntohl (msg->request_id);
op->spec->result_mode = ntohl (msg->result_mode);
+ op->spec->byzantine = msg->byzantine;
+ op->spec->byzantine_lower_bound = msg->byzantine_lower_bound;
+ op->spec->force_full = msg->force_full;
+ op->spec->force_delta = msg->force_delta;
// Advance generation values, so that
// mutations won't interfer with the running operation.
}
-/**
- * Function called whenever a channel is destroyed. Should clean up
- * any associated state. It must NOT call
- * GNUNET_CADET_channel_destroy() on the channel.
- *
- * The peer_disconnect function is part of a a virtual table set initially either
- * when a peer creates a new channel with us, or once we create
- * a new channel ourselves (evaluate).
- *
- * Once we know the exact type of operation (union/intersection), the vt is
- * replaced with an operation specific instance (_GSS_[op]_vt).
- *
- * @param cls closure (set from GNUNET_CADET_connect())
- * @param channel connection to the other end (henceforth invalid)
- * @param channel_ctx place where local state associated
- * with the channel is stored
- */
-static void
-channel_end_cb (void *cls,
- const struct GNUNET_CADET_Channel *channel,
- void *channel_ctx)
-{
- struct Operation *op = channel_ctx;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "channel_end_cb called\n");
- op->channel = NULL;
- op->keep++;
- /* the vt can be null if a client already requested canceling op. */
- if (NULL != op->vt)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "calling peer disconnect due to channel end\n");
- op->vt->peer_disconnect (op);
- }
- op->keep--;
- if (0 == op->keep)
- {
- /* cadet will never call us with the context again! */
- GNUNET_free (op);
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "channel_end_cb finished\n");
-}
-
-
-/**
- * Functions with this signature are called whenever a message is
- * received via a cadet channel.
- *
- * The msg_handler is a virtual table set in initially either when a peer
- * creates a new channel with us, or once we create a new channel
- * ourselves (evaluate).
- *
- * Once we know the exact type of operation (union/intersection), the vt is
- * replaced with an operation specific instance (_GSS_[op]_vt).
- *
- * @param cls Closure (set from GNUNET_CADET_connect()).
- * @param channel Connection to the other end.
- * @param channel_ctx Place to store local state associated with the channel.
- * @param message The actual message.
- * @return #GNUNET_OK to keep the channel open,
- * #GNUNET_SYSERR to close it (signal serious error).
- */
-static int
-dispatch_p2p_message (void *cls,
- struct GNUNET_CADET_Channel *channel,
- void **channel_ctx,
- const struct GNUNET_MessageHeader *message)
-{
- struct Operation *op = *channel_ctx;
- int ret;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Dispatching cadet message (type: %u)\n",
- ntohs (message->type));
- /* do this before the handler, as the handler might kill the channel */
- GNUNET_CADET_receive_done (channel);
- if (NULL != op->vt)
- ret = op->vt->msg_handler (op,
- message);
- else
- ret = GNUNET_SYSERR;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Handled cadet message (type: %u)\n",
- ntohs (message->type));
- return ret;
-}
-
-
/**
* Function called by the service's run
* method to run service-specific setup code.
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_SERVICE_Handle *service)
{
- static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, 0},
- { &dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, 0},
- {NULL, 0, 0}
- };
-
configuration = cfg;
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
NULL);
_GSS_statistics = GNUNET_STATISTICS_create ("set", cfg);
- cadet = GNUNET_CADET_connect (cfg,
- NULL,
- &channel_end_cb,
- cadet_handlers);
+ cadet = GNUNET_CADET_connecT (cfg);
if (NULL == cadet)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,