- unsigned int buckets_in_message;
- struct GNUNET_MQ_Envelope *mqm;
- struct IBFMessage *msg;
-
- buckets_in_message = (1 << ibf_order) - buckets_sent;
- /* limit to maximum */
- if (buckets_in_message > MAX_BUCKETS_PER_MESSAGE)
- buckets_in_message = MAX_BUCKETS_PER_MESSAGE;
-
- mqm = GNUNET_MQ_msg_extra (msg, buckets_in_message * IBF_BUCKET_SIZE,
- GNUNET_MESSAGE_TYPE_SET_P2P_IBF);
- msg->order = ibf_order;
- msg->offset = htons (buckets_sent);
- ibf_write_slice (ibf, buckets_sent,
- buckets_in_message, &msg[1]);
- buckets_sent += buckets_in_message;
- GNUNET_MQ_send (eo->tc->mq, mqm);
+ GNUNET_break_op (0);
+ fail_intersection_operation (op);
+ return;
+ }
+ msg = (const struct BFMessage *) mh;
+ switch (op->state->phase)
+ {
+ case PHASE_INITIAL:
+ GNUNET_break_op (0);
+ fail_intersection_operation (op);
+ break;
+ case PHASE_COUNT_SENT:
+ case PHASE_BF_EXCHANGE:
+ bf_size = ntohl (msg->bloomfilter_total_length);
+ bf_bits_per_element = ntohl (msg->bits_per_element);
+ chunk_size = msize - sizeof (struct BFMessage);
+ op->state->other_xor = msg->element_xor_hash;
+ if (bf_size == chunk_size)
+ {
+ if (NULL != op->state->bf_data)
+ {
+ GNUNET_break_op (0);
+ fail_intersection_operation (op);
+ return;
+ }
+ /* single part, done here immediately */
+ op->state->remote_bf
+ = GNUNET_CONTAINER_bloomfilter_init ((const char*) &msg[1],
+ bf_size,
+ bf_bits_per_element);
+ op->state->salt = ntohl (msg->sender_mutator);
+ op->spec->remote_element_count = ntohl (msg->sender_element_count);
+ process_bf (op);
+ return;
+ }
+ /* multipart chunk */
+ if (NULL == op->state->bf_data)
+ {
+ /* first chunk, initialize */
+ op->state->bf_data = GNUNET_malloc (bf_size);
+ op->state->bf_data_size = bf_size;
+ op->state->bf_bits_per_element = bf_bits_per_element;
+ op->state->bf_data_offset = 0;
+ op->state->salt = ntohl (msg->sender_mutator);
+ op->spec->remote_element_count = ntohl (msg->sender_element_count);
+ }
+ else
+ {
+ /* increment */
+ if ( (op->state->bf_data_size != bf_size) ||
+ (op->state->bf_bits_per_element != bf_bits_per_element) ||
+ (op->state->bf_data_offset + chunk_size > bf_size) ||
+ (op->state->salt != ntohl (msg->sender_mutator)) ||
+ (op->spec->remote_element_count != ntohl (msg->sender_element_count)) )
+ {
+ GNUNET_break_op (0);
+ fail_intersection_operation (op);
+ return;
+ }
+ }
+ GNUNET_memcpy (&op->state->bf_data[op->state->bf_data_offset],
+ (const char*) &msg[1],
+ chunk_size);
+ op->state->bf_data_offset += chunk_size;
+ if (op->state->bf_data_offset == bf_size)
+ {
+ /* last chunk, run! */
+ op->state->remote_bf
+ = GNUNET_CONTAINER_bloomfilter_init (op->state->bf_data,
+ bf_size,
+ bf_bits_per_element);
+ GNUNET_free (op->state->bf_data);
+ op->state->bf_data = NULL;
+ op->state->bf_data_size = 0;
+ process_bf (op);
+ }
+ break;
+ default:
+ GNUNET_break_op (0);
+ fail_intersection_operation (op);
+ break;