From e8b773abf7135fc6657621a39d0a4720b7680a64 Mon Sep 17 00:00:00 2001 From: Christian Fuchs Date: Mon, 16 Dec 2013 16:30:13 +0000 Subject: - begin work on enhanced multipart receiving - added msg handlers for multipart bfs --- src/set/gnunet-service-set.c | 1 + src/set/gnunet-service-set_intersection.c | 36 ++++++++++++++++++++++++++----- 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, {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, 0}, {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, 0}, {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, 0}, + {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF_PART, 0}, {NULL, 0, 0} }; 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 @@ -53,6 +53,10 @@ enum IntersectionOperationPhase * until one notices the their element count is equal */ PHASE_BF_EXCHANGE, + /** + * Multipart continuation of BF_exchange + */ + PHASE_BF_AWAIT_MULTIPART, /** * if both peers have an equal peercount, they enter this state for * one more turn, to see if they actually have agreed on a correct set. @@ -421,7 +425,7 @@ send_bloomfilter (struct Operation *op) op); // send our bloomfilter - if (GNUNET_SERVER_MAX_MESSAGE_SIZE <= bf_size + sizeof (struct BFMessage)) { + if (GNUNET_SERVER_MAX_MESSAGE_SIZE > bf_size + sizeof (struct BFMessage)) { // singlepart chunk_size = bf_size; ev = GNUNET_MQ_msg_extra (msg, chunk_size, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF); @@ -452,9 +456,8 @@ send_bloomfilter (struct Operation *op) GNUNET_MQ_send (op->mq, ev); - if (op->state->local_bf_data) { + if (op->state->local_bf_data) send_bloomfilter_multipart (op, chunk_size); - } } @@ -537,6 +540,26 @@ send_peer_done (struct Operation *op) GNUNET_MQ_send (op->mq, ev); } +/** + * Handle an BF multipart message from a remote peer. + * + * @param cls the intersection operation + * @param mh the header of the message + */ +static void +handle_p2p_bf_part (void *cls, const struct GNUNET_MessageHeader *mh) +{ + struct Operation *op = cls; + const struct BFPart *msg = (const struct BFPart *) mh; + + if (op->state->phase != PHASE_BF_AWAIT_MULTIPART){ + GNUNET_break_op (0); + fail_intersection_operation(op); + return; + } + + +} /** * Handle an BF message from a remote peer. @@ -556,8 +579,8 @@ handle_p2p_bf (void *cls, const struct GNUNET_MessageHeader *mh) op->spec->salt = ntohl (msg->sender_mutator); op->state->remote_bf = GNUNET_CONTAINER_bloomfilter_init ((const char*) &msg[1], - ntohl (msg->bloomfilter_length), - GNUNET_CONSTANTS_BLOOMFILTER_K); + ntohl (msg->bloomfilter_total_length), + ntohl (msg->bits_per_element)); op->state->local_bf = GNUNET_CONTAINER_bloomfilter_init (NULL, BLOOMFILTER_SIZE, GNUNET_CONSTANTS_BLOOMFILTER_K); @@ -856,6 +879,9 @@ intersection_handle_p2p_message (struct Operation *op, case GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF: handle_p2p_bf (op, mh); break; + case GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF_PART: + handle_p2p_bf_part (op, mh); + break; case GNUNET_MESSAGE_TYPE_SET_P2P_DONE: handle_p2p_done (op, mh); break; -- cgit v1.2.3