37#define LOG(kind, ...) GNUNET_log_from (kind, "set-union", __VA_ARGS__)
43#define SE_STRATA_COUNT 32
53#define SE_IBF_HASH_NUM 4
58#define MAX_BUCKETS_PER_MESSAGE ((1 << 15) / IBF_BUCKET_SIZE)
65#define MAX_IBF_ORDER (20)
317 "destroying union op\n");
320 if (NULL !=
op->state->remote_ibf)
323 op->state->remote_ibf = NULL;
325 if (NULL !=
op->state->demanded_hashes)
328 op->state->demanded_hashes = NULL;
330 if (NULL !=
op->state->local_ibf)
333 op->state->local_ibf = NULL;
335 if (NULL !=
op->state->se)
338 op->state->se = NULL;
340 if (NULL !=
op->state->key_to_element)
346 op->state->key_to_element = NULL;
351 "destroying union op done\n");
368 "union operation failed\n");
371 msg->request_id = htonl (
op->client_request_id);
372 msg->element_type = htons (0);
466 ctx.hash = *element_hash;
533 x = (x >> s) | (x << (64 - s));
549 x = (x << s) | (x >> (64 - s));
571 "[OP %p] inserting %lx (hash %s) into ibf\n",
576 op->state->salt_send,
649 if (NULL !=
op->state->local_ibf)
652 if (NULL ==
op->state->local_ibf)
655 "Failed to allocate local IBF\n");
678 unsigned int buckets_sent = 0;
689 "sending ibf of size %u\n",
693 char name[64] = { 0 };
694 snprintf (
name,
sizeof(
name),
"# sent IBF (order %u)", ibf_order);
698 ibf =
op->state->local_ibf;
700 while (buckets_sent < (1 << ibf_order))
702 unsigned int buckets_in_message;
706 buckets_in_message = (1 << ibf_order) - buckets_sent;
716 msg->order = ibf_order;
717 msg->offset = htonl (buckets_sent);
718 msg->salt = htonl (
op->state->salt_send);
720 buckets_in_message, &
msg[1]);
721 buckets_sent += buckets_in_message;
723 "ibf chunk size %u, %u/%u sent\n",
747 unsigned int ibf_order;
750 while (((1 << ibf_order) < (
IBF_ALPHA * diff) ||
755 return ibf_order + 1;
780 "Sending element %s\n",
807 "Dedicing to transmit the full set\n");
871 "# bytes of SE received",
879 if (NULL == remote_se)
905 op->state->se = NULL;
907 "got se diff=%d, using ibf size %d\n",
914 set_debug =
getenv (
"GNUNET_SET_BENCHMARK");
915 if ((NULL != set_debug) &&
916 (0 == strcmp (set_debug,
"1")))
918 FILE *f = fopen (
"set.log",
"a");
919 fprintf (f,
"%llu\n", (
unsigned long long) diff);
925 (other_size < op->byzantine_lower_bound))
933 (diff >
op->state->initial_size / 4) ||
937 "Deciding to go for full set transmission (diff=%d, own set=%llu)\n",
939 (
unsigned long long)
op->state->initial_size);
944 if ((
op->state->initial_size <= other_size) ||
954 "Telling other peer that we expect its full set\n");
974 "Failed to send IBF, closing connection\n");
1012 "[OP %p] sending element offer (%s) to peer\n",
1035 op->state->key_to_element,
1056 unsigned int num_decoded;
1063 op->state->remote_ibf->size))
1069 diff_ibf =
ibf_dup (
op->state->local_ibf);
1071 op->state->remote_ibf);
1074 op->state->remote_ibf = NULL;
1077 "decoding IBF (size=%u)\n",
1094 "decoded ibf key %lx\n",
1095 (
unsigned long)
key.key_val);
1097 if ((num_decoded > diff_ibf->
size) ||
1098 ((num_decoded > 1) &&
1102 "detected cyclic ibf (decoded %u/%u)\n",
1113 while (1 << next_order < diff_ibf->
size)
1119 "decoding failed, sending larger ibf (size %u)\n",
1125 op->state->salt_send++;
1131 "Failed to send IBF, closing connection\n");
1140 "# of failed union operations (too large)",
1145 "set union failed: reached ibf limit\n");
1157 "transmitted all values, sending DONE\n");
1170 op->state->salt_receive,
1175 else if (-1 == side)
1185 msg->salt = htonl (
op->state->salt_receive);
1190 "sending element inquiry for IBF key %lx\n",
1191 (
unsigned long)
key.key_val);
1219 unsigned int buckets_in_message;
1226 buckets_in_message = (ntohs (
msg->header.
size) -
sizeof *
msg)
1228 if (0 == buckets_in_message)
1233 if ((ntohs (
msg->header.
size) -
sizeof *
msg) != buckets_in_message
1241 if (ntohl (
msg->offset) !=
op->state->ibf_buckets_received)
1246 if (1 <<
msg->order !=
op->state->remote_ibf->size)
1251 if (ntohl (
msg->salt) !=
op->state->salt_receive)
1282 unsigned int buckets_in_message;
1284 buckets_in_message = (ntohs (
msg->header.
size) -
sizeof *
msg)
1292 "Creating new ibf of size %u\n",
1295 op->state->salt_receive = ntohl (
msg->salt);
1297 "Receiving new IBF with salt %u\n",
1298 op->state->salt_receive);
1299 if (NULL ==
op->state->remote_ibf)
1302 "Failed to parse remote IBF, closing connection\n");
1306 op->state->ibf_buckets_received = 0;
1307 if (0 != ntohl (
msg->offset))
1318 "Received more of IBF\n");
1323 op->state->ibf_buckets_received,
1325 op->state->remote_ibf);
1326 op->state->ibf_buckets_received += buckets_in_message;
1328 if (
op->state->ibf_buckets_received ==
op->state->remote_ibf->size)
1331 "received full ibf\n");
1338 "Failed to decode IBF, closing connection\n");
1364 "sending element (size %u) to client\n",
1378 op->state->key_to_element));
1408 "Union operation failed\n");
1410 "# Union operations failed",
1425 "# Union operations succeeded",
1429 "Signalling client that union operation is done\n");
1436 op->state->key_to_element));
1450 unsigned int num_demanded;
1453 op->state->demanded_hashes);
1458 "In PHASE_FINISH_WAITING, pending %u demands\n",
1460 if (0 == num_demanded)
1475 "In PHASE_FINISH_CLOSING, pending %u demands\n",
1477 if (0 == num_demanded)
1528 uint16_t element_size;
1530 element_size = ntohs (emsg->
header.
size) -
sizeof(
struct
1554 "Got element (size %u, hash %s) from peer\n",
1555 (
unsigned int) element_size,
1559 "# received elements",
1563 "# exchanged elements",
1567 op->state->received_total++;
1575 "# repeated elements",
1584 "Registering new element from remote peer\n");
1585 op->state->received_fresh++;
1588 switch (
op->result_mode)
1605 if ((
op->state->received_total > 8) &&
1606 (
op->state->received_fresh <
op->state->received_total / 3))
1653 uint16_t element_size;
1655 element_size = ntohs (emsg->
header.
size) -
sizeof(
struct
1666 "Got element (full diff, size %u, hash %s) from peer\n",
1667 (
unsigned int) element_size,
1671 "# received elements",
1675 "# exchanged elements",
1679 op->state->received_total++;
1687 "# repeated elements",
1696 "Registering new element from remote peer\n");
1697 op->state->received_fresh++;
1700 switch (
op->result_mode)
1718 (
op->state->received_total > 384 +
op->state->received_fresh * 4) &&
1719 (
op->state->received_fresh <
op->state->received_total / 6))
1723 "Other peer sent only %llu/%llu fresh elements, failing operation\n",
1724 (
unsigned long long)
op->state->received_fresh,
1725 (
unsigned long long)
op->state->received_total);
1746 unsigned int num_keys;
1761 != num_keys *
sizeof(
struct IBF_Key))
1782 const struct IBF_Key *ibf_key;
1783 unsigned int num_keys;
1786 "Received union inquiry\n");
1790 while (0 != num_keys--)
1854 "Received request for full set transmission\n");
1887 switch (
op->state->phase)
1894 "got FULL DONE, sending elements that other peer is missing\n");
1912 "got FULL DONE, finishing\n");
1924 "Handle full done phase is %u\n",
1925 (
unsigned)
op->state->phase);
1947 unsigned int num_hashes;
1981 unsigned int num_hashes;
1988 hash++, num_hashes--)
2012 "[OP %p] Sending demanded element (size %u, hash %s) to peer\n",
2018 "# exchanged elements",
2022 switch (
op->result_mode)
2054 unsigned int num_hashes;
2093 unsigned int num_hashes;
2099 hash++, num_hashes--)
2116 "Skipped sending duplicate demand\n");
2122 op->state->demanded_hashes,
2128 "[OP %p] Requesting element (hash %s)\n",
2160 switch (
op->state->phase)
2167 "got DONE (as passive partner), waiting for our demands to be satisfied\n");
2182 "got DONE (as active partner), waiting to finish\n");
2243 "Initiating union operation evaluation\n");
2245 "# of total union operations",
2249 "# of initiated union operations",
2256 if (NULL != opaque_context)
2258 "sent op request with context message\n");
2261 "sent op request without context message\n");
2266 state->key_to_element);
2289 "accepting set union operation\n");
2291 "# of accepted union operations",
2295 "# of total union operations",
2307 state->key_to_element);
2327 op->set->content->elements));
2349 "union set created\n");
2353 if (NULL == set_state->
se)
2356 "Failed to allocate strata estimator\n");
2403 if (NULL != set_state->
se)
2406 set_state->
se = NULL;
2424 (NULL !=
state->se));
2455 static const struct SetVT union_vt = {
struct GNUNET_MessageHeader * msg
void ibf_subtract(struct InvertibleBloomFilter *ibf1, const struct InvertibleBloomFilter *ibf2)
Subtract ibf2 from ibf1, storing the result in ibf1.
int ibf_decode(struct InvertibleBloomFilter *ibf, int *ret_side, struct IBF_Key *ret_id)
Decode and remove an element from the IBF, if possible.
void ibf_read_slice(const void *buf, uint32_t start, uint32_t count, struct InvertibleBloomFilter *ibf)
Read buckets from a buffer into an ibf.
void ibf_write_slice(const struct InvertibleBloomFilter *ibf, uint32_t start, uint32_t count, void *buf)
Write buckets from an ibf to a buffer.
void ibf_insert(struct InvertibleBloomFilter *ibf, struct IBF_Key key)
Insert a key into an IBF.
struct InvertibleBloomFilter * ibf_dup(const struct InvertibleBloomFilter *ibf)
Create a copy of an IBF, the copy has to be destroyed properly.
struct InvertibleBloomFilter * ibf_create(uint32_t size, uint8_t hash_num)
Create an invertible bloom filter.
void ibf_destroy(struct InvertibleBloomFilter *ibf)
Destroy all resources associated with the invertible bloom filter.
#define IBF_BUCKET_SIZE
Size of one ibf bucket in bytes.
static struct GNUNET_ARM_Operation * op
Current operation.
static int ret
Final status code.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static char * name
Name (label) of the records to list.
static int state
The current state of the parser.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static int status
The program status; 0 for success.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle for our ego lookup.
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
void _GSS_operation_destroy2(struct Operation *op)
This function probably should not exist and be replaced by inlining more specific logic in the variou...
int _GSS_is_element_of_operation(struct ElementEntry *ee, struct Operation *op)
Is element ee part of the set used by op?
struct GNUNET_STATISTICS_Handle * _GSS_statistics
Statistics handle.
void _GSS_operation_destroy(struct Operation *op, int gc)
Destroy the given operation.
common components for the implementation the different set operations
Peer-to-Peer messages for gnunet set.
void handle_union_p2p_strata_estimator(void *cls, const struct StrataEstimatorMessage *msg)
Handle a strata estimator from a remote peer.
void handle_union_p2p_offer(void *cls, const struct GNUNET_MessageHeader *mh)
Handle offers (of struct GNUNET_HashCodes) and respond with demands (of struct GNUNET_HashCodes).
int check_union_p2p_elements(void *cls, const struct GNUNET_SET_ElementMessage *emsg)
Check an element message from a remote peer.
static void union_set_destroy(struct SetState *set_state)
Destroy a set that supports the union operation.
#define MAX_BUCKETS_PER_MESSAGE
Number of buckets that can be transmitted in one message.
static int decode_and_send(struct Operation *op)
Decode which elements are missing on each side, and send the appropriate offers and inquiries.
void handle_union_p2p_ibf(void *cls, const struct IBFMessage *msg)
Handle an IBF message from a remote peer.
static int send_full_element_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Send a set element.
static struct OperationState * union_accept(struct Operation *op)
Accept an union operation request from a remote peer.
static struct OperationState * union_evaluate(struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)
Initiate operation to evaluate a set union with a remote peer.
static void send_full_set(struct Operation *op)
Switch to full set transmission for op.
int check_union_p2p_strata_estimator(void *cls, const struct StrataEstimatorMessage *msg)
Handle a strata estimator from a remote peer.
int check_union_p2p_full_element(void *cls, const struct GNUNET_SET_ElementMessage *emsg)
Check a full element message from a remote peer.
void handle_union_p2p_full_element(void *cls, const struct GNUNET_SET_ElementMessage *emsg)
Handle an element message from a remote peer.
static struct IBF_Key get_ibf_key(const struct GNUNET_HashCode *src)
Derive the IBF key from a hash code and a salt.
static void maybe_finish(struct Operation *op)
Tests if the operation is finished, and if so notify.
static int init_key_to_element_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator for initializing the key-to-element mapping of a union operation.
void handle_union_p2p_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a done message from a remote peer.
static int send_offers_iterator(void *cls, uint32_t key, void *value)
Iterator to send elements to a remote peer.
static struct SetState * union_set_create(void)
Create a new set supporting the union operation.
const struct SetVT * _GSS_union_vt()
Get the table with implementing functions for set union.
#define SE_IBF_SIZE
Size of the IBFs in the strata estimator.
static int send_missing_full_elements_iter(void *cls, uint32_t key, void *value)
Iterator over hash map entries, called to destroy the linked list of colliding ibf key entries.
int check_union_p2p_offer(void *cls, const struct GNUNET_MessageHeader *mh)
Check offer (of struct GNUNET_HashCodes).
void handle_union_p2p_over(void *cls, const struct GNUNET_MessageHeader *mh)
Handle an over message from a remote peer.
static void union_remove(struct SetState *set_state, struct ElementEntry *ee)
Remove the element given in the element message from the set.
static int send_ibf(struct Operation *op, uint16_t ibf_order)
Send an ibf of appropriate size.
static struct SetState * union_copy_state(struct SetState *state)
Copy union-specific set state.
static void union_channel_death(struct Operation *op)
Handle case where channel went down for an operation.
#define IBF_ALPHA
Number of buckets used in the ibf per estimated difference.
static void fail_union_operation(struct Operation *op)
Inform the client that the union operation has failed, and proceed to destroy the evaluate operation.
static void send_client_done(void *cls)
Signal to the client that the operation has finished and destroy the operation.
void handle_union_p2p_inquiry(void *cls, const struct InquiryMessage *msg)
Send offers (for GNUNET_Hash-es) in response to inquiries (for IBF_Key-s).
static void unsalt_key(const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out)
FIXME.
static void salt_key(const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out)
FIXME.
static int prepare_ibf(struct Operation *op, uint32_t size)
Create an ibf with the operation's elements of the specified size.
static void op_register_element(struct Operation *op, struct ElementEntry *ee, int received)
Insert an element into the union operation's key-to-element mapping.
static void union_add(struct SetState *set_state, struct ElementEntry *ee)
Add the element from the given element message to the set.
static void initialize_key_to_element(struct Operation *op)
Initialize the IBF key to element mapping local to this set operation.
void handle_union_p2p_elements(void *cls, const struct GNUNET_SET_ElementMessage *emsg)
Handle an element message from a remote peer.
void handle_union_p2p_demand(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a demand by the other peer for elements based on a list of struct GNUNET_HashCodes.
static void send_offers_for_key(struct Operation *op, struct IBF_Key ibf_key)
Send offers (in the form of GNUNET_Hash-es) to the remote peer for the given IBF key.
void handle_union_p2p_full_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a "full done" message.
static int destroy_key_to_element_iter(void *cls, uint32_t key, void *value)
Iterator over hash map entries, called to destroy the linked list of colliding ibf key entries.
static void union_op_cancel(struct Operation *op)
Destroy the union operation.
#define SE_STRATA_COUNT
Number of IBFs in a strata estimator.
int check_union_p2p_demand(void *cls, const struct GNUNET_MessageHeader *mh)
Check a demand by the other peer for elements based on a list of struct GNUNET_HashCodes.
int check_union_p2p_ibf(void *cls, const struct IBFMessage *msg)
Check an IBF message from a remote peer.
static struct KeyEntry * op_get_element(struct Operation *op, const struct GNUNET_HashCode *element_hash)
Determine whether the given element is already in the operation's element set.
UnionOperationPhase
Current phase we are in for a union operation.
@ PHASE_INVENTORY_PASSIVE
The other peer is decoding the IBF we just sent.
@ PHASE_FINISH_CLOSING
The protocol is almost finished, but we still have to flush our message queue and/or expect some elem...
@ PHASE_DONE
In the ultimate phase, we wait until our demands are satisfied and then quit (sending another DONE me...
@ PHASE_EXPECT_SE
We sent the request message, and expect a strata estimator.
@ PHASE_FINISH_WAITING
In the penultimate phase, we wait until all our demands are satisfied.
@ PHASE_EXPECT_IBF_CONT
Continuation for multi part IBFs.
@ PHASE_FULL_SENDING
After sending the full set, wait for responses with the elements that the local peer is missing.
@ PHASE_EXPECT_IBF
We sent the strata estimator, and expect an IBF.
@ PHASE_INVENTORY_ACTIVE
We are decoding an IBF.
static void send_client_element(struct Operation *op, struct GNUNET_SET_Element *element, int status)
Send a result message to the client indicating that there is a new element.
#define SE_IBF_HASH_NUM
The hash num parameter for the difference digests and strata estimators.
void handle_union_p2p_request_full(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a request for full set transmission.
static int op_get_element_iterator(void *cls, uint32_t key, void *value)
Iterator over the mapping from IBF keys to element entries.
static int prepare_ibf_iterator(void *cls, uint32_t key, void *value)
Insert a key into an ibf.
int check_union_p2p_inquiry(void *cls, const struct InquiryMessage *msg)
Send offers (for GNUNET_Hash-es) in response to inquiries (for IBF_Key-s).
#define MAX_IBF_ORDER
The maximum size of an ibf we use is 2^(MAX_IBF_ORDER).
static unsigned int get_order_from_difference(unsigned int diff)
Compute the necessary order of an ibf from the size of the symmetric set difference.
unsigned int strata_estimator_difference(const struct StrataEstimator *se1, const struct StrataEstimator *se2)
Estimate set difference with two strata estimators, i.e.
struct StrataEstimator * strata_estimator_create(unsigned int strata_count, uint32_t ibf_size, uint8_t ibf_hashnum)
Create a new strata estimator with the given parameters.
void strata_estimator_destroy(struct StrataEstimator *se)
Destroy a strata estimator, free all of its resources.
int strata_estimator_read(const void *buf, size_t buf_len, int is_compressed, struct StrataEstimator *se)
Read strata from the buffer into the given strata estimator.
size_t strata_estimator_write(const struct StrataEstimator *se, void *buf)
Write the given strata estimator to the buffer.
void strata_estimator_insert(struct StrataEstimator *se, struct IBF_Key key)
Add a key to the strata estimator.
struct StrataEstimator * strata_estimator_dup(struct StrataEstimator *se)
Make a copy of a strata estimator.
void strata_estimator_remove(struct StrataEstimator *se, struct IBF_Key key)
Remove a key from the strata estimator.
estimator of set difference
API to create, modify and access statistics.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
#define GNUNET_CRYPTO_hkdf_gnunet(result, out_len, xts, xts_len, skm, skm_len,...)
A peculiar HKDF instantiation that tried to mimic Truncated NMAC.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_msg_header_extra(mh, esize, type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header and extra space.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER
Tell the other peer which hashes match a given IBF key.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY
Tell the other peer to send us a list of hashes that match an IBF key.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE
Strata estimator.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF
Invertible bloom filter.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE
Set operation is done.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC
Compressed strata estimator.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT
Send a set element, not as response to a demand but because we're sending the full set.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL
Demand the whole element from the other peer, given only the hash code.
#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS
Actual set elements.
#define GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
Request a set operation from a remote peer.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND
Demand the whole element from the other peer, given only the hash code.
#define GNUNET_MESSAGE_TYPE_SET_RESULT
Create an empty set.
#define GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE
Request all missing elements from the other peer, based on their sets and the elements we previously ...
void GNUNET_SET_element_hash(const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
@ GNUNET_SET_STATUS_OK
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set,...
@ GNUNET_SET_STATUS_FAILURE
The other peer refused to to the operation with us, or something went wrong.
@ GNUNET_SET_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SET_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SET_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
@ GNUNET_SET_RESULT_SYMMETRIC
Client gets notified of the required changes for both the local and the remote set.
@ GNUNET_SET_RESULT_ADDED
Client gets only elements that have been added to the set.
@ GNUNET_SET_OPERATION_UNION
Set union, return all elements that are in at least one of the sets.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static unsigned int size
Size of the "table".
Information about an element element in the set.
int remote
GNUNET_YES if the element is a remote element, and does not belong to the operation's set.
struct GNUNET_SET_Element element
The actual element.
struct GNUNET_HashCode element_hash
Hash of the element.
Internal representation of the hash map.
Internal representation of the hash map.
Message sent by client to the service to add or remove an element to/from the set.
uint16_t element_type
Type of the element to add or remove.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SET_ADD or GNUNET_MESSAGE_TYPE_SET_REMOVE.
uint16_t reserved
For alignment, always zero.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
uint32_t request_id
id the result belongs to
uint16_t result_status
Was the evaluation successful? Contains an enum GNUNET_SET_Status in NBO.
uint16_t element_type
Type of the element attached to the message, if any.
uint64_t current_size
Current set size.
Context for op_get_element_iterator.
struct GNUNET_HashCode hash
FIXME.
struct KeyEntry * k
FIXME.
Message containing buckets of an invertible bloom filter.
Keys that can be inserted into and removed from an IBF.
estimate_best_mode_of_operation (uint64_t avg_element_size, uint64_t local_set_size,...
Invertible bloom filter (IBF).
uint32_t size
How many cells does this IBF have?
The key entry is used to associate an ibf key with an element.
struct ElementEntry * element
The actual element associated with the key.
struct IBF_Key ibf_key
IBF key for the entry, derived from the current salt.
int received
Did we receive this element? Even if element->is_foreign is false, we might have received the element...
State of an evaluate operation with another peer.
struct InvertibleBloomFilter * remote_ibf
The IBF we currently receive.
enum UnionOperationPhase phase
Current state of the operation.
struct StrataEstimator * se
Copy of the set's strata estimator at the time of creation of this operation.
uint32_t received_total
Total number of elements received from the other peer.
uint32_t salt_send
Salt that we're using for sending IBFs.
uint64_t initial_size
Initial size of our set, just before the operation started.
struct GNUNET_CONTAINER_MultiHashMap * demanded_hashes
Hashes for elements that we have demanded from the other peer.
struct InvertibleBloomFilter * local_ibf
The IBF with the local set's element.
struct GNUNET_CONTAINER_MultiHashMap32 * key_to_element
Maps unsalted IBF-Keys to elements.
uint32_t salt_receive
Salt for the IBF we've received and that we're currently decoding.
unsigned int ibf_buckets_received
Number of ibf buckets already received into the remote_ibf.
int client_done_sent
Did we send the client that we are done?
uint32_t received_fresh
Number of elements we received from the other peer that were not in the local set yet.
Operation context used to execute a set operation.
Used as a closure for sending elements with a specific IBF key.
struct Operation * op
Operation for which the elements should be sent.
struct IBF_Key ibf_key
The IBF key whose matching elements should be sent.
Extra state required for efficient set intersection.
struct StrataEstimator * se
The strata estimator is only generated once for each set.
Dispatch table for a specific set operation.
SetCreateImpl create
Callback for the set creation.
Strata estimator together with the peer's overall set size.
uint64_t set_size
Size of the local set.
A handle to a strata estimator.
unsigned int ibf_size
Size of each IBF stratum (in bytes)
unsigned int strata_count
Size of the IBF array in strata.