diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-12-09 16:17:19 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-12-09 16:17:19 +0000 |
commit | 119238db5e4b71e477a0ea2c9085eaa4251e026a (patch) | |
tree | 0d59dfb8e06603bdb066bfa3110a8b196f40b235 /src/set | |
parent | 7bdfa2135fd5cb638162dd19356e54ec9702c462 (diff) | |
download | gnunet-119238db5e4b71e477a0ea2c9085eaa4251e026a.tar.gz gnunet-119238db5e4b71e477a0ea2c9085eaa4251e026a.zip |
- more multipart fun
- Make it so
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 35 | ||||
-rw-r--r-- | src/set/set_protocol.h | 7 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index 45d670c92..627b96fda 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -341,6 +341,40 @@ send_operation_request (struct Operation *op) | |||
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | static void | ||
345 | send_bloomfilter_multipart (struct Operation *op, uint32_t offset) | ||
346 | { | ||
347 | struct GNUNET_MQ_Envelope *ev; | ||
348 | struct BFMessage *msg; | ||
349 | uint32_t chunk_size = (GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct BFMessage)); | ||
350 | uint32_t todo_size = op->state->local_bf_data_size - offset; | ||
351 | |||
352 | if (todo_size < chunk_size) | ||
353 | // we probably need many chunks, thus we assume a maximum packet size by default | ||
354 | chunk_size = todo_size; | ||
355 | |||
356 | ev = GNUNET_MQ_msg_extra (msg, chunk_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); | ||
357 | |||
358 | msg->reserved = 0; | ||
359 | msg->sender_element_count = htonl (op->state->my_element_count); | ||
360 | msg->bloomfilter_total_length = htonl (op->state->local_bf_data_size); | ||
361 | msg->bloomfilter_length = htonl (chunk_size); | ||
362 | msg->bloomfilter_offset = htonl (offset); | ||
363 | msg->sender_mutator = htonl (op->spec->salt); | ||
364 | |||
365 | GNUNET_MQ_send (op->mq, ev); | ||
366 | |||
367 | if (op->state->local_bf_data_size == offset + chunk_size) | ||
368 | { | ||
369 | // done | ||
370 | GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf); | ||
371 | GNUNET_free(op->state->local_bf_data); | ||
372 | op->state->local_bf = NULL; | ||
373 | return; | ||
374 | } | ||
375 | |||
376 | send_bloomfilter_multipart (op, offset + chunk_size); | ||
377 | } | ||
344 | 378 | ||
345 | /** | 379 | /** |
346 | * Send a bloomfilter to our peer. | 380 | * Send a bloomfilter to our peer. |
@@ -378,6 +412,7 @@ send_bloomfilter (struct Operation *op) | |||
378 | GNUNET_MQ_send (op->mq, ev); | 412 | GNUNET_MQ_send (op->mq, ev); |
379 | } | 413 | } |
380 | else { | 414 | else { |
415 | //multipart | ||
381 | op->state->local_bf_data = (char *)GNUNET_malloc(bf_size); | 416 | op->state->local_bf_data = (char *)GNUNET_malloc(bf_size); |
382 | GNUNET_assert (GNUNET_SYSERR != | 417 | GNUNET_assert (GNUNET_SYSERR != |
383 | GNUNET_CONTAINER_bloomfilter_get_raw_data (op->state->local_bf, | 418 | GNUNET_CONTAINER_bloomfilter_get_raw_data (op->state->local_bf, |
diff --git a/src/set/set_protocol.h b/src/set/set_protocol.h index 310cb202c..632e45963 100644 --- a/src/set/set_protocol.h +++ b/src/set/set_protocol.h | |||
@@ -116,7 +116,12 @@ struct BFMessage | |||
116 | uint32_t sender_mutator GNUNET_PACKED; | 116 | uint32_t sender_mutator GNUNET_PACKED; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * Length of the bloomfilter data block | 119 | * Length of the bloomfilter data |
120 | */ | ||
121 | uint32_t bloomfilter_total_length GNUNET_PACKED; | ||
122 | |||
123 | /** | ||
124 | * Length of the appended bloomfilter data block | ||
120 | */ | 125 | */ |
121 | uint32_t bloomfilter_length GNUNET_PACKED; | 126 | uint32_t bloomfilter_length GNUNET_PACKED; |
122 | 127 | ||