From a4ae4a97527fc6532aa9b7a0f20d1a2f5d7b73ba Mon Sep 17 00:00:00 2001 From: Christian Fuchs Date: Wed, 18 Dec 2013 16:24:35 +0000 Subject: - implemented output mode GNUNET_SET_RESULT_REMOVED in intersection --- src/set/gnunet-service-set_intersection.c | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/set') diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index a12b30c86..1bfda430a 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c @@ -156,6 +156,37 @@ struct SetState }; +/** + * Send a result message to the client indicating + * we removed an element + * + * @param op union operation + * @param element element to send + */ +static void +send_client_element (struct Operation *op, + struct GNUNET_SET_Element *element) +{ + struct GNUNET_MQ_Envelope *ev; + struct GNUNET_SET_ResultMessage *rm; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending removed element (size %u) to client\n", element->size); + GNUNET_assert (0 != op->spec->client_request_id); + ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); + if (NULL == ev) + { + GNUNET_MQ_discard (ev); + GNUNET_break (0); + return; + } + rm->result_status = htons (GNUNET_SET_STATUS_OK); + rm->request_id = htonl (op->spec->client_request_id); + rm->element_type = element->type; + memcpy (&rm[1], element->data, element->size); + GNUNET_MQ_send (op->spec->set->client_mq, ev); +} + + /** * Alice's version: * @@ -188,8 +219,11 @@ iterator_initialization_by_alice (void *cls, op->spec->salt, &mutated_hash); if (GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf, - &mutated_hash)) + &mutated_hash)){ + if (GNUNET_SET_RESULT_REMOVED == op->spec->result_mode) + send_client_element (op, &ee->element); return GNUNET_YES; + } op->state->my_element_count++; GNUNET_assert (GNUNET_YES == @@ -263,6 +297,8 @@ iterator_bf_reduce (void *cls, GNUNET_CONTAINER_multihashmap_remove (op->state->my_elements, &ee->element_hash, ee)); + if (GNUNET_SET_RESULT_REMOVED == op->spec->result_mode) + send_client_element (op, &ee->element); } return GNUNET_YES; -- cgit v1.2.3