aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-12-16 16:30:13 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-12-16 16:30:13 +0000
commite8b773abf7135fc6657621a39d0a4720b7680a64 (patch)
tree9b61490b83ce0b71d07035d9b0f1b385045435c3 /src/set
parent5787e0651116f7785097e5b38979c0cb86efa4e5 (diff)
downloadgnunet-e8b773abf7135fc6657621a39d0a4720b7680a64.tar.gz
gnunet-e8b773abf7135fc6657621a39d0a4720b7680a64.zip
- begin work on enhanced multipart receiving
- added msg handlers for multipart bfs
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c1
-rw-r--r--src/set/gnunet-service-set_intersection.c36
2 files changed, 32 insertions, 5 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index bfbc959c3..9cc2e56f6 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -1381,6 +1381,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1381 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, 0}, 1381 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, 0},
1382 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, 0}, 1382 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, 0},
1383 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, 0}, 1383 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, 0},
1384 {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF_PART, 0},
1384 {NULL, 0, 0} 1385 {NULL, 0, 0}
1385 }; 1386 };
1386 static const uint32_t mesh_ports[] = {GNUNET_APPLICATION_TYPE_SET, 0}; 1387 static const uint32_t mesh_ports[] = {GNUNET_APPLICATION_TYPE_SET, 0};
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c
index 0e2ac4863..7152eec06 100644
--- a/src/set/gnunet-service-set_intersection.c
+++ b/src/set/gnunet-service-set_intersection.c
@@ -54,6 +54,10 @@ enum IntersectionOperationPhase
54 */ 54 */
55 PHASE_BF_EXCHANGE, 55 PHASE_BF_EXCHANGE,
56 /** 56 /**
57 * Multipart continuation of BF_exchange
58 */
59 PHASE_BF_AWAIT_MULTIPART,
60 /**
57 * if both peers have an equal peercount, they enter this state for 61 * if both peers have an equal peercount, they enter this state for
58 * one more turn, to see if they actually have agreed on a correct set. 62 * one more turn, to see if they actually have agreed on a correct set.
59 * if a peer finds the same element count after the next iteration, 63 * if a peer finds the same element count after the next iteration,
@@ -421,7 +425,7 @@ send_bloomfilter (struct Operation *op)
421 op); 425 op);
422 426
423 // send our bloomfilter 427 // send our bloomfilter
424 if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= bf_size + sizeof (struct BFMessage)) { 428 if (GNUNET_SERVER_MAX_MESSAGE_SIZE > bf_size + sizeof (struct BFMessage)) {
425 // singlepart 429 // singlepart
426 chunk_size = bf_size; 430 chunk_size = bf_size;
427 ev = GNUNET_MQ_msg_extra (msg, chunk_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); 431 ev = GNUNET_MQ_msg_extra (msg, chunk_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF);
@@ -452,9 +456,8 @@ send_bloomfilter (struct Operation *op)
452 456
453 GNUNET_MQ_send (op->mq, ev); 457 GNUNET_MQ_send (op->mq, ev);
454 458
455 if (op->state->local_bf_data) { 459 if (op->state->local_bf_data)
456 send_bloomfilter_multipart (op, chunk_size); 460 send_bloomfilter_multipart (op, chunk_size);
457 }
458} 461}
459 462
460 463
@@ -537,6 +540,26 @@ send_peer_done (struct Operation *op)
537 GNUNET_MQ_send (op->mq, ev); 540 GNUNET_MQ_send (op->mq, ev);
538} 541}
539 542
543/**
544 * Handle an BF multipart message from a remote peer.
545 *
546 * @param cls the intersection operation
547 * @param mh the header of the message
548 */
549static void
550handle_p2p_bf_part (void *cls, const struct GNUNET_MessageHeader *mh)
551{
552 struct Operation *op = cls;
553 const struct BFPart *msg = (const struct BFPart *) mh;
554
555 if (op->state->phase != PHASE_BF_AWAIT_MULTIPART){
556 GNUNET_break_op (0);
557 fail_intersection_operation(op);
558 return;
559 }
560
561
562}
540 563
541/** 564/**
542 * Handle an BF message from a remote peer. 565 * Handle an BF message from a remote peer.
@@ -556,8 +579,8 @@ handle_p2p_bf (void *cls, const struct GNUNET_MessageHeader *mh)
556 op->spec->salt = ntohl (msg->sender_mutator); 579 op->spec->salt = ntohl (msg->sender_mutator);
557 580
558 op->state->remote_bf = GNUNET_CONTAINER_bloomfilter_init ((const char*) &msg[1], 581 op->state->remote_bf = GNUNET_CONTAINER_bloomfilter_init ((const char*) &msg[1],
559 ntohl (msg->bloomfilter_length), 582 ntohl (msg->bloomfilter_total_length),
560 GNUNET_CONSTANTS_BLOOMFILTER_K); 583 ntohl (msg->bits_per_element));
561 op->state->local_bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 584 op->state->local_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
562 BLOOMFILTER_SIZE, 585 BLOOMFILTER_SIZE,
563 GNUNET_CONSTANTS_BLOOMFILTER_K); 586 GNUNET_CONSTANTS_BLOOMFILTER_K);
@@ -856,6 +879,9 @@ intersection_handle_p2p_message (struct Operation *op,
856 case GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF: 879 case GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF:
857 handle_p2p_bf (op, mh); 880 handle_p2p_bf (op, mh);
858 break; 881 break;
882 case GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF_PART:
883 handle_p2p_bf_part (op, mh);
884 break;
859 case GNUNET_MESSAGE_TYPE_SET_P2P_DONE: 885 case GNUNET_MESSAGE_TYPE_SET_P2P_DONE:
860 handle_p2p_done (op, mh); 886 handle_p2p_done (op, mh);
861 break; 887 break;