diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-12-09 15:48:51 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-12-09 15:48:51 +0000 |
commit | 7bdfa2135fd5cb638162dd19356e54ec9702c462 (patch) | |
tree | 6495e7f12e6f43770154e8a5a90cba27ed9e04a1 /src/set | |
parent | d2a74d2e853132270b4fdb54a3f7568982aca236 (diff) | |
download | gnunet-7bdfa2135fd5cb638162dd19356e54ec9702c462.tar.gz gnunet-7bdfa2135fd5cb638162dd19356e54ec9702c462.zip |
towards multipart msging for bloomfilters in set intersection
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 44 | ||||
-rw-r--r-- | src/set/set_protocol.h | 5 |
2 files changed, 38 insertions, 11 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index 39c94592b..45d670c92 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -76,6 +76,16 @@ struct OperationState | |||
76 | * BF of the set's element. | 76 | * BF of the set's element. |
77 | */ | 77 | */ |
78 | struct GNUNET_CONTAINER_BloomFilter *local_bf; | 78 | struct GNUNET_CONTAINER_BloomFilter *local_bf; |
79 | |||
80 | /** | ||
81 | * for multipart msgs we have to store the bloomfilter-data until we fully sent it. | ||
82 | */ | ||
83 | char * local_bf_data; | ||
84 | |||
85 | /** | ||
86 | * for multipart msgs we have to store the bloomfilter-data until we fully sent it. | ||
87 | */ | ||
88 | uint32_t local_bf_data_size; | ||
79 | 89 | ||
80 | /** | 90 | /** |
81 | * Current state of the operation. | 91 | * Current state of the operation. |
@@ -351,19 +361,31 @@ send_bloomfilter (struct Operation *op) | |||
351 | 361 | ||
352 | // send our bloomfilter | 362 | // send our bloomfilter |
353 | bf_size = GNUNET_CONTAINER_bloomfilter_get_size (op->state->local_bf); | 363 | bf_size = GNUNET_CONTAINER_bloomfilter_get_size (op->state->local_bf); |
354 | 364 | if ( GNUNET_SERVER_MAX_MESSAGE_SIZE <= bf_size + sizeof(struct BFMessage)) | |
355 | ev = GNUNET_MQ_msg_extra (msg, bf_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); | 365 | { |
356 | msg->reserved = 0; | 366 | // singlepart |
357 | msg->sender_element_count = htonl (op->state->my_element_count); | 367 | ev = GNUNET_MQ_msg_extra (msg, bf_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); |
358 | msg->bloomfilter_length = htonl (bf_size); | 368 | |
359 | msg->sender_mutator = htonl (op->spec->salt); | 369 | GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf); |
360 | GNUNET_assert (GNUNET_SYSERR != | 370 | op->state->local_bf = NULL; |
371 | |||
372 | msg->reserved = 0; | ||
373 | msg->sender_element_count = htonl (op->state->my_element_count); | ||
374 | msg->bloomfilter_length = htonl (bf_size); | ||
375 | msg->bloomfilter_offset = htonl (0); | ||
376 | msg->sender_mutator = htonl (op->spec->salt); | ||
377 | |||
378 | GNUNET_MQ_send (op->mq, ev); | ||
379 | } | ||
380 | else { | ||
381 | op->state->local_bf_data = (char *)GNUNET_malloc(bf_size); | ||
382 | GNUNET_assert (GNUNET_SYSERR != | ||
361 | GNUNET_CONTAINER_bloomfilter_get_raw_data (op->state->local_bf, | 383 | GNUNET_CONTAINER_bloomfilter_get_raw_data (op->state->local_bf, |
362 | (char *) &msg[1], | 384 | op->state->local_bf_data, |
363 | bf_size)); | 385 | bf_size)); |
364 | GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf); | 386 | op->state->local_bf_data_size = bf_size; |
365 | op->state->local_bf = NULL; | 387 | send_bloomfilter_multipart (op, 0); |
366 | GNUNET_MQ_send (op->mq, ev); | 388 | } |
367 | } | 389 | } |
368 | 390 | ||
369 | 391 | ||
diff --git a/src/set/set_protocol.h b/src/set/set_protocol.h index d37551d2e..310cb202c 100644 --- a/src/set/set_protocol.h +++ b/src/set/set_protocol.h | |||
@@ -121,6 +121,11 @@ struct BFMessage | |||
121 | uint32_t bloomfilter_length GNUNET_PACKED; | 121 | uint32_t bloomfilter_length GNUNET_PACKED; |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * offset in the bloolfilter data block, if multipart message | ||
125 | */ | ||
126 | uint32_t bloomfilter_offset GNUNET_PACKED; | ||
127 | |||
128 | /** | ||
124 | * rest: the sender's bloomfilter | 129 | * rest: the sender's bloomfilter |
125 | */ | 130 | */ |
126 | }; | 131 | }; |