GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
struct GNUNET_MessageHeader *context_msg;
/**
- * Tunnel context for the peer we
- * evaluate the union operation with.
+ * Tunnel to the other peer.
*/
- struct TunnelContext *tc;
+ struct GNUNET_MESH_Tunnel *tunnel;
/**
* Request ID to multiplex set operations to
* was created.
*/
unsigned int generation_created;
-
+
/**
* Evaluate operations are held in
* a linked list.
*/
struct IntersectionEvaluateOperation *next;
-
+
/**
* Evaluate operations are held in
* a linked list.
int removed;
/**
- * Generation the element was removed by the client.
+ * Generation the element was removed by the client.
* Operations of later generations will not consider the element.
* Only valid if is_removed is GNUNET_YES.
*/
* Operation for which the elements
* should be sent.
*/
- struct UnionEvaluateOperation *eo;
+ struct IntersectionEvaluateOperation *eo;
};
* Evaluate operations are held in
* a linked list.
*/
- struct UnionEvaluateOperation *ops_head;
+ struct IntersectionEvaluateOperation *ops_head;
/**
* Evaluate operations are held in
* a linked list.
*/
- struct UnionEvaluateOperation *ops_tail;
+ struct IntersectionEvaluateOperation *ops_tail;
/**
* Current generation, that is, number of
void *value)
{
struct KeyEntry *k = value;
-
+
while (NULL != k)
{
struct KeyEntry *k_tmp = k;
_GSS_union_operation_destroy (struct UnionEvaluateOperation *eo)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "destroying union op\n");
-
- if (NULL != eo->tc)
+
+ if (NULL != eo->tunnel)
{
- GNUNET_MQ_destroy (eo->tc->mq);
- GNUNET_MESH_tunnel_destroy (eo->tc->tunnel);
- GNUNET_free (eo->tc);
- eo->tc = NULL;
+ GNUNET_MESH_tunnel_destroy (eo->tunnel);
+ /* wait for the final destruction by the tunnel cleaner */
+ return;
}
if (NULL != eo->remote_ibf)
eo);
GNUNET_free (eo);
-
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "destroying union op done\n");
-
/* FIXME: do a garbage collection of the set generations */
}
/**
- * Derive the IBF key from a hash code and
+ * Derive the IBF key from a hash code and
* a salt.
*
* @param src the hash code
* @param eo operation with the other peer
*/
static void
-send_operation_request (struct UnionEvaluateOperation *eo)
+send_operation_request (struct IntersectionEvaluateOperation *eo)
{
struct GNUNET_MQ_Envelope *mqm;
struct OperationRequestMessage *msg;
GNUNET_SERVER_client_disconnect (eo->set->client);
return;
}
- msg->operation = htons (GNUNET_SET_OPERATION_UNION);
+ msg->operation = htons (GNUNET_SET_OPERATION_INTERSECTION);
msg->app_id = eo->app_id;
GNUNET_MQ_send (eo->tc->mq, mqm);
* @param eo the union operation with the remote peer
*/
static void
-send_strata_estimator (struct UnionEvaluateOperation *eo)
+send_strata_estimator (struct IntersectionEvaluateOperation *eo)
{
struct GNUNET_MQ_Envelope *mqm;
struct GNUNET_MessageHeader *strata_msg;
mqm = GNUNET_MQ_msg_header_extra (strata_msg,
SE_STRATA_COUNT * IBF_BUCKET_SIZE * SE_IBF_SIZE,
GNUNET_MESSAGE_TYPE_SET_P2P_SE);
- strata_estimator_write (eo->set->state.u->se, &strata_msg[1]);
+ strata_estimator_write (eo->set->state.i->se, &strata_msg[1]);
GNUNET_MQ_send (eo->tc->mq, mqm);
eo->phase = PHASE_EXPECT_IBF;
}
next_order++;
if (next_order <= MAX_IBF_ORDER)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"decoding failed, sending larger ibf (size %u)\n",
1<<next_order);
send_ibf (eo, next_order);
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"set union failed: reached ibf limit\n");
}
break;
fail_union_operation (eo);
return;
}
-
+
ibf_read_slice (&msg[1], eo->ibf_buckets_received, buckets_in_message, eo->remote_ibf);
eo->ibf_buckets_received += buckets_in_message;
return;
}
element_size = ntohs (mh->size) - sizeof (struct GNUNET_MessageHeader);
- ee = GNUNET_malloc (sizeof *eo + element_size);
+ ee = GNUNET_malloc (sizeof *ee + element_size);
memcpy (&ee[1], &mh[1], element_size);
ee->element.data = &ee[1];
ee->remote = GNUNET_YES;
/**
* Handle a done message from a remote peer
- *
+ *
* @param cls the union operation
* @param mh the message
*/
* @param set the set to evaluate the operation with
*/
void
-_GSS_union_evaluate (struct GNUNET_SET_EvaluateMessage *m, struct Set *set)
+_GSS_intersection_evaluate (struct GNUNET_SET_EvaluateMessage *m, struct Set *set)
{
struct IntersectionEvaluateOperation *eo;
struct GNUNET_MessageHeader *context_msg;
eo->se = strata_estimator_dup (set->state.i->se);
eo->salt = ntohs (m->salt);
eo->app_id = m->app_id;
-
+
context_msg = GNUNET_MQ_extract_nested_mh (m);
if (NULL != context_msg)
{
eo->context_msg = GNUNET_copy_message (context_msg);
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "evaluating intersection operation, (app %s)\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "evaluating intersection operation, (app %s)\n",
GNUNET_h2s (&eo->app_id));
eo->tc = GNUNET_new (struct TunnelContext);
* @param incoming information about the requesting remote peer
*/
void
-_GSS_union_accept (struct GNUNET_SET_AcceptRejectMessage *m, struct Set *set,
+_GSS_intersection_accept (struct GNUNET_SET_AcceptRejectMessage *m, struct Set *set,
struct Incoming *incoming)
{
- struct UnionEvaluateOperation *eo;
+ struct IntersectionEvaluateOperation *eo;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "accepting set union operation\n");
- eo = GNUNET_new (struct UnionEvaluateOperation);
+ eo = GNUNET_new (struct IntersectionEvaluateOperation);
eo->tc = incoming->tc;
- eo->generation_created = set->state.u->current_generation++;
+ eo->generation_created = set->state.i->current_generation++;
eo->set = set;
eo->salt = ntohs (incoming->salt);
GNUNET_assert (0 != ntohl (m->request_id));
eo->request_id = ntohl (m->request_id);
- eo->se = strata_estimator_dup (set->state.u->se);
+ eo->se = strata_estimator_dup (set->state.i->se);
/* transfer ownership of mq and socket from incoming to eo */
- GNUNET_CONTAINER_DLL_insert (eo->set->state.u->ops_head,
- eo->set->state.u->ops_tail,
+ GNUNET_CONTAINER_DLL_insert (eo->set->state.i->ops_head,
+ eo->set->state.i->ops_tail,
eo);
/* kick off the operation */
send_strata_estimator (eo);
struct Set *set;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "intersection set created\n");
-
+
set = GNUNET_malloc (sizeof (struct Set) + sizeof (struct IntersectionState));
set->state.i = (struct IntersectionState *) &set[1];
set->operation = GNUNET_SET_OPERATION_INTERSECTION;
* want the hash map to copy them */
set->state.i->elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES);
set->state.i->se = strata_estimator_create (SE_STRATA_COUNT,
- SE_IBF_SIZE, SE_IBF_HASH_NUM);
+ SE_IBF_SIZE, SE_IBF_HASH_NUM);
return set;
}
/**
* Destroy a set that supports the union operation
*
- * @param the set to destroy, must be of type GNUNET_SET_OPERATION_UNION
+ * @param set the set to destroy, must be of type GNUNET_SET_OPERATION_UNION
*/
void
_GSS_union_set_destroy (struct Set *set)
* @param cls closure
* @param tunnel mesh tunnel
* @param tunnel_ctx tunnel context
- * @param sender ???
* @param mh message to process
* @return ???
*/
_GSS_union_handle_p2p_message (void *cls,
struct GNUNET_MESH_Tunnel *tunnel,
void **tunnel_ctx,
- const struct GNUNET_PeerIdentity *sender,
const struct GNUNET_MessageHeader *mh)
{
struct TunnelContext *tc = *tunnel_ctx;
if (CONTEXT_OPERATION_UNION != tc->type)
{
- /* FIXME: kill the tunnel */
/* never kill mesh */
return GNUNET_OK;
}