/*
This file is part of GNUnet.
- Copyright (C) 2013, 2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013, 2014, 2016 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
*/
struct GNUNET_SET_OperationHandle *intersection_op;
+ /**
+ * CADET port we are listening on.
+ */
+ struct GNUNET_CADET_Port *port;
+
/**
* a(Alice)
*/
*/
struct CadetIncomingSession *cadet;
- /**
- * The computed scalar
- */
- gcry_mpi_t product;
-
/**
* How many elements will be supplied in total from the client.
*/
GNUNET_free (s->r_prime);
s->r_prime = NULL;
}
- if (NULL != s->product)
- {
- gcry_mpi_release (s->product);
- s->product = NULL;
- }
+ GNUNET_CADET_close_port (s->port);
GNUNET_free (s);
}
struct ClientResponseMessage *msg;
struct GNUNET_MQ_Envelope *e;
+ if (NULL == session->client_mq)
+ return; /* no client left to be notified */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending session-end notification with status %d to client for session %s\n",
session->status,
"Peer disconnected, terminating session %s with peer %s\n",
GNUNET_h2s (&in->session_id),
GNUNET_i2s (&in->peer));
- if (NULL != in->cadet_mq)
- {
- GNUNET_MQ_destroy (in->cadet_mq);
- in->cadet_mq = NULL;
- }
- in->channel = NULL;
if (NULL != (s = in->s))
{
if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
prepare_client_end_notification (s);
}
}
+ if (NULL != in->cadet_mq)
+ {
+ GNUNET_MQ_destroy (in->cadet_mq);
+ in->cadet_mq = NULL;
+ }
+ in->channel = NULL;
destroy_cadet_session (in);
}
for (i = s->cadet_transmitted_element_count, j = 0; i < s->cadet_transmitted_element_count + todo_count; i++)
{
//r[i][p] and r[i][q]
- memcpy (&payload[j++],
+ GNUNET_memcpy (&payload[j++],
&s->r[i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
- memcpy (&payload[j++],
+ GNUNET_memcpy (&payload[j++],
&s->r_prime[i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
}
(unsigned int) s->used_element_count);
payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
- memcpy (&payload[0],
+ GNUNET_memcpy (&payload[0],
&s->s,
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
- memcpy (&payload[1],
+ GNUNET_memcpy (&payload[1],
&s->s_prime,
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
for (i = 0; i < s->cadet_transmitted_element_count; i++)
{
//k[i][p] and k[i][q]
- memcpy (&payload[i * 2],
+ GNUNET_memcpy (&payload[i * 2],
&s->r[i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
- memcpy (&payload[i * 2 + 1],
+ GNUNET_memcpy (&payload[i * 2 + 1],
&s->r_prime[i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
}
if (NULL == s->e_a)
s->e_a = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) *
max);
- memcpy (&s->e_a[s->cadet_received_element_count],
+ GNUNET_memcpy (&s->e_a[s->cadet_received_element_count],
payload,
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * contained_elements);
s->cadet_received_element_count += contained_elements;
struct BobServiceSession *s;
const struct ServiceRequestMessage *msg;
- if (ntohs (message->size) != sizeof (struct ServiceRequestMessage))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
msg = (const struct ServiceRequestMessage *) message;
if (GNUNET_YES == in->in_map)
{
* preliminary initialization, more happens after we get Alice's first
* message.
*
- * @param cls closure
+ * @param cls closure with the `struct BobServiceSession`
* @param channel new handle to the channel
* @param initiator peer that started the channel
* @param port unused
cb_channel_incoming (void *cls,
struct GNUNET_CADET_Channel *channel,
const struct GNUNET_PeerIdentity *initiator,
- uint32_t port,
+ const struct GNUNET_HashCode *port,
enum GNUNET_CADET_ChannelOption options)
{
struct CadetIncomingSession *in;
for (i = 0; i < contained_count; i++)
{
elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
- memcpy (elem,
+ GNUNET_memcpy (elem,
&elements[i],
sizeof (struct GNUNET_SCALARPRODUCT_Element));
if (GNUNET_SYSERR ==
GNUNET_SYSERR);
return;
}
- if (NULL != find_matching_client_session (&msg->session_key))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
- return;
- }
s = GNUNET_new (struct BobServiceSession);
s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE;
s->total = total_count;
s->client_received_element_count = contained_count;
s->session_id = msg->session_key;
+ s->port = GNUNET_CADET_open_port (my_cadet,
+ &msg->session_key,
+ &cb_channel_incoming,
+ s);
+ if (NULL == s->port)
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client,
+ GNUNET_SYSERR);
+ GNUNET_free (s);
+ return;
+ }
+
GNUNET_break (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (client_sessions,
&s->session_id,
if (0 == GNUNET_ntohll (elements[i].value))
continue;
elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
- memcpy (elem,
+ GNUNET_memcpy (elem,
&elements[i],
sizeof (struct GNUNET_SCALARPRODUCT_Element));
if (GNUNET_SYSERR ==
* Task run during shutdown.
*
* @param cls unused
- * @param tc unused
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shutting down, initiating cleanup.\n");
if (NULL == client)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client disconnected from us.\n",
- client);
+ "Client disconnected from us.\n");
s = GNUNET_SERVER_client_get_user_context (client,
struct BobServiceSession);
if (NULL == s)
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB,
0},
{ &GSS_handle_bob_client_message_multipart, NULL,
- GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MUTLIPART_BOB,
+ GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB,
0},
{ NULL, NULL, 0, 0}
};
0},
{ NULL, 0, 0}
};
- static const uint32_t ports[] = {
- GNUNET_APPLICATION_TYPE_SCALARPRODUCT,
- 0
- };
cfg = c;
/*
cadet_sessions = GNUNET_CONTAINER_multihashmap_create (128,
GNUNET_YES);
my_cadet = GNUNET_CADET_connect (cfg, NULL,
- &cb_channel_incoming,
&cb_channel_destruction,
- cadet_handlers,
- ports);
+ cadet_handlers);
if (NULL == my_cadet)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
}