aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-service-set_intersection.c
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-12-09 16:17:19 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-12-09 16:17:19 +0000
commit119238db5e4b71e477a0ea2c9085eaa4251e026a (patch)
tree0d59dfb8e06603bdb066bfa3110a8b196f40b235 /src/set/gnunet-service-set_intersection.c
parent7bdfa2135fd5cb638162dd19356e54ec9702c462 (diff)
downloadgnunet-119238db5e4b71e477a0ea2c9085eaa4251e026a.tar.gz
gnunet-119238db5e4b71e477a0ea2c9085eaa4251e026a.zip
- more multipart fun
- Make it so
Diffstat (limited to 'src/set/gnunet-service-set_intersection.c')
-rw-r--r--src/set/gnunet-service-set_intersection.c35
1 files changed, 35 insertions, 0 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
344static void
345send_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,