/*
This file is part of GNUnet
- Copyright (C) 2013-2015 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013-2015 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
*/
/**
* @file set/gnunet-service-set_union.c
+
* @brief two-peer set operations
* @author Florian Dold
*/
* Choose this value so that computing the IBF is still cheaper
* than transmitting all values.
*/
-#define MAX_IBF_ORDER (16)
+#define MAX_IBF_ORDER (20)
/**
* Number of buckets used in the ibf per estimated
{
int s = salt % 64;
uint64_t x = k_in->key_val;
+ /* rotate ibf key */
x = (x >> s) | (x << (64 - s));
k_out->key_val = x;
}
uint32_t salt,
struct IBF_Key *k_out)
{
- int s = -(salt % 64);
+ int s = salt % 64;
uint64_t x = k_in->key_val;
- x = (x >> s) | (x << (64 - s));
+ x = (x << s) | (x >> (64 - s));
k_out->key_val = x;
}
ev = GNUNET_MQ_msg_extra (msg,
buckets_in_message * IBF_BUCKET_SIZE,
GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF);
- msg->reserved = 0;
+ msg->reserved1 = 0;
+ msg->reserved2 = 0;
msg->order = ibf_order;
- msg->offset = htons (buckets_sent);
+ msg->offset = htonl (buckets_sent);
msg->salt = htonl (op->state->salt_send);
ibf_write_slice (ibf, buckets_sent,
buckets_in_message, &msg[1]);
if (GNUNET_OK !=
prepare_ibf (op, op->state->remote_ibf->size))
{
+ GNUNET_break (0);
/* allocation failed */
return GNUNET_SYSERR;
}
1 << msg->order);
op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM);
op->state->salt_receive = ntohl (msg->salt);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Receiving new IBF with salt %u\n", op->state->salt_receive);
if (NULL == op->state->remote_ibf)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
return GNUNET_SYSERR;
}
op->state->ibf_buckets_received = 0;
- if (0 != ntohs (msg->offset))
+ if (0 != ntohl (msg->offset))
{
GNUNET_break_op (0);
fail_union_operation (op);
}
else if (op->state->phase == PHASE_EXPECT_IBF_CONT)
{
- if ( (ntohs (msg->offset) != op->state->ibf_buckets_received) ||
- (1<<msg->order != op->state->remote_ibf->size) ||
- (ntohl (msg->salt) != op->state->salt_receive))
+ if (ntohl (msg->offset) != op->state->ibf_buckets_received)
+ {
+ GNUNET_break_op (0);
+ fail_union_operation (op);
+ return GNUNET_SYSERR;
+ }
+ if (1<<msg->order != op->state->remote_ibf->size)
+ {
+ GNUNET_break_op (0);
+ fail_union_operation (op);
+ return GNUNET_SYSERR;
+ }
+ if (ntohl (msg->salt) != op->state->salt_receive)
{
GNUNET_break_op (0);
fail_union_operation (op);