aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-11-08 17:08:51 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-11-08 17:08:51 +0000
commit7aa5296249e4c1b029ffe5a53e4c9e001e5c2949 (patch)
tree3167d9a2521f7a044c852a4956afa2836d443ae3 /src/set
parent656aba44ab3cc71e88d76edcc8955835c4e6f037 (diff)
downloadgnunet-7aa5296249e4c1b029ffe5a53e4c9e001e5c2949.tar.gz
gnunet-7aa5296249e4c1b029ffe5a53e4c9e001e5c2949.zip
added functionality to send a BF
BF size is now sizeof(GNUNET_hashcode)
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set_intersection.c74
-rw-r--r--src/set/set_protocol.h14
2 files changed, 28 insertions, 60 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c
index 9c21f3b56..0e0450bd1 100644
--- a/src/set/gnunet-service-set_intersection.c
+++ b/src/set/gnunet-service-set_intersection.c
@@ -108,7 +108,7 @@ struct OperationState
108 /** 108 /**
109 * Current element count contained within contained_elements 109 * Current element count contained within contained_elements
110 */ 110 */
111 uint64_t contained_elements_count; 111 uint32_t contained_elements_count;
112 112
113 /** 113 /**
114 * Iterator for sending elements on the key to element mapping to the client. 114 * Iterator for sending elements on the key to element mapping to the client.
@@ -353,6 +353,7 @@ send_client_done_and_destroy (struct OperationState *eo)
353 intersection_operation_destroy (eo); 353 intersection_operation_destroy (eo);
354} 354}
355 355
356
356/** 357/**
357 * Send a bloomfilter to our peer. 358 * Send a bloomfilter to our peer.
358 * that the operation is over. 359 * that the operation is over.
@@ -362,49 +363,27 @@ send_client_done_and_destroy (struct OperationState *eo)
362 * @param eo intersection operation 363 * @param eo intersection operation
363 */ 364 */
364static void 365static void
365send_bloomfilter (struct Operation *op){ 366send_bloomfilter (struct Operation *op)
366 //get number of all elements still in the set 367{
367
368 // send the bloomfilter
369 unsigned int buckets_sent = 0;
370 struct BloomFilter *bf; 368 struct BloomFilter *bf;
371 //TODO: 369 struct GNUNET_MQ_Envelope *ev;
372 // add all our elements to the bloomfilter 370 struct BFMessage *msg;
373 // create new bloomfilter for all our elements & count elements
374 //GNUNET_CONTAINER_multihashmap32_remove
375 //eo->local_bf = GNUNET_CONTAINER_multihashmap32_iterate(eo->set->elements, add);
376 371
377 op->state->local_bf;
378
379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending bf of size %u\n", 1<<ibf_order);
380
381 bf = eo->local_bf;
382 372
383 while (buckets_sent < (1 << bf_order)) 373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending bf of size %u\n", );
384 { 374
385 unsigned int buckets_in_message; 375 ev = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF);
386 struct GNUNET_MQ_Envelope *ev; 376 msg->reserved = 0;
387 struct IBFMessage *msg; 377 msg->sender_mutator = htonl (op->spec->salt);
388 378 msg->sender_element_count = htonl (op->state->contained_elements_count);
389 buckets_in_message = (1 << bf_order) - buckets_sent; 379 GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_bloomfilter_get_raw_data(
390 /* limit to maximum */ 380 op->state->local_bf,
391 if (buckets_in_message > MAX_BUCKETS_PER_MESSAGE) 381 &msg->bf_data,
392 buckets_in_message = MAX_BUCKETS_PER_MESSAGE; 382 GNUNET_CRYPTO_HASH_LENGTH));
393 383
394 ev = GNUNET_MQ_msg_extra (msg, buckets_in_message * IBF_BUCKET_SIZE, 384 GNUNET_MQ_send (op->mq, ev);
395 GNUNET_MESSAGE_TYPE_SET_P2P_BF);
396 msg->reserved = 0;
397 msg->order = bf_order;
398 msg->offset = htons (buckets_sent);
399 ibf_write_slice (ibf, buckets_sent,
400 buckets_in_message, &msg[1]);
401 buckets_sent += buckets_in_message;
402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ibf chunk size %u, %u/%u sent\n",
403 buckets_in_message, buckets_sent, 1<<ibf_order);
404 GNUNET_MQ_send (eo->mq, ev);
405 }
406 385
407 eo->phase = PHASE_BF_EXCHANGE; 386 op->state->phase = PHASE_BF_EXCHANGE;
408} 387}
409 388
410/** 389/**
@@ -616,22 +595,13 @@ intersection_accept (struct Operation *op)
616 op->state = GNUNET_new (struct OperationState); 595 op->state = GNUNET_new (struct OperationState);
617 596
618 op->state->contained_elements = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES); 597 op->state->contained_elements = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES);
598 op->state-> = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_YES);
599
600 op->state->local_bf = GNUNET_CONTAINER_bloomfilter_init(NULL, , GNUNET_CONSTANTS_BLOOMFILTER_K);
619 601
620 GNUNET_CONTAINER_multihashmap_iterate(op->spec->set->elements, 602 GNUNET_CONTAINER_multihashmap_iterate(op->spec->set->elements,
621 &intersection_iterator_set_to_contained_bob, 603 &intersection_iterator_set_to_contained_bob,
622 op); 604 op);
623
624
625 op->state->local_bf = GNUNET_CONTAINER_bloomfilter_init(NULL, sizeof(struct GNUNET_HashCode), GNUNET_CONSTANTS_BLOOMFILTER_K);
626
627 if (NULL != op->state->remote_bf){
628 // run the set through the remote bloomfilter
629 ;
630 }
631
632 //
633 op->state->local_bf;
634
635 /* kick off the operation */ 605 /* kick off the operation */
636 send_bloomfilter (op); 606 send_bloomfilter (op);
637} 607}
diff --git a/src/set/set_protocol.h b/src/set/set_protocol.h
index 21b7358d6..4741eb5c2 100644
--- a/src/set/set_protocol.h
+++ b/src/set/set_protocol.h
@@ -101,21 +101,19 @@ struct BFMessage
101 uint8_t reserved; 101 uint8_t reserved;
102 102
103 /** 103 /**
104 * Offset of the bloomfilter in the rest of the message
105 */
106 uint16_t offset GNUNET_PACKED;
107
108 /**
109 * mutator used with this bloomfilter. 104 * mutator used with this bloomfilter.
110 */ 105 */
111 uint64_t my_element_count; 106 uint64_t sender_element_count;
112 107
113 /** 108 /**
114 * mutator used with this bloomfilter. 109 * mutator used with this bloomfilter.
115 */ 110 */
116 uint32_t my_mutator; 111 uint32_t sender_mutator;
117 112
118 /* rest: bloomfilter */ 113 /**
114 * the sender's bloomfilter
115 */
116 char sender_bf_data[GNUNET_CRYPTO_HASH_LENGTH];
119}; 117};
120 118
121GNUNET_NETWORK_STRUCT_END 119GNUNET_NETWORK_STRUCT_END