two-peer set operations More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet-service-set.h"
#include "ibf.h"
#include "gnunet-service-set_union.h"
#include "gnunet-service-set_union_strata_estimator.h"
#include "gnunet-service-set_protocol.h"
#include <gcrypt.h>
Go to the source code of this file.
Data Structures | |
struct | OperationState |
State of an evaluate operation with another peer. More... | |
struct | KeyEntry |
The key entry is used to associate an ibf key with an element. More... | |
struct | SendElementClosure |
Used as a closure for sending elements with a specific IBF key. More... | |
struct | SetState |
Extra state required for efficient set intersection. More... | |
struct | GetElementContext |
Context for op_get_element_iterator. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "set-union", __VA_ARGS__) |
#define | SE_STRATA_COUNT 32 |
Number of IBFs in a strata estimator. More... | |
#define | SE_IBF_SIZE 80 |
Size of the IBFs in the strata estimator. More... | |
#define | SE_IBF_HASH_NUM 4 |
The hash num parameter for the difference digests and strata estimators. More... | |
#define | MAX_BUCKETS_PER_MESSAGE ((1 << 15) / IBF_BUCKET_SIZE) |
Number of buckets that can be transmitted in one message. More... | |
#define | MAX_IBF_ORDER (20) |
The maximum size of an ibf we use is 2^(MAX_IBF_ORDER). More... | |
#define | IBF_ALPHA 4 |
Number of buckets used in the ibf per estimated difference. More... | |
Enumerations | |
enum | UnionOperationPhase { PHASE_EXPECT_SE , PHASE_EXPECT_IBF , PHASE_EXPECT_IBF_CONT , PHASE_INVENTORY_ACTIVE , PHASE_INVENTORY_PASSIVE , PHASE_FINISH_CLOSING , PHASE_FINISH_WAITING , PHASE_DONE , PHASE_FULL_SENDING , PHASE_EXPECT_SE , PHASE_EXPECT_IBF , PHASE_EXPECT_IBF_LAST , PHASE_ACTIVE_DECODING , PHASE_PASSIVE_DECODING , PHASE_FINISH_CLOSING , PHASE_FINISH_WAITING , PHASE_FINISHED , PHASE_FULL_SENDING , PHASE_FULL_RECEIVING } |
Current phase we are in for a union operation. More... | |
Functions | |
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. More... | |
static void | union_op_cancel (struct Operation *op) |
Destroy the union operation. More... | |
static void | fail_union_operation (struct Operation *op) |
Inform the client that the union operation has failed, and proceed to destroy the evaluate operation. More... | |
static struct IBF_Key | get_ibf_key (const struct GNUNET_HashCode *src) |
Derive the IBF key from a hash code and a salt. More... | |
static int | op_get_element_iterator (void *cls, uint32_t key, void *value) |
Iterator over the mapping from IBF keys to element entries. More... | |
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. More... | |
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. More... | |
static void | salt_key (const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out) |
FIXME. More... | |
static void | unsalt_key (const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out) |
FIXME. More... | |
static int | prepare_ibf_iterator (void *cls, uint32_t key, void *value) |
Insert a key into an ibf. More... | |
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. More... | |
static void | initialize_key_to_element (struct Operation *op) |
Initialize the IBF key to element mapping local to this set operation. More... | |
static int | prepare_ibf (struct Operation *op, uint32_t size) |
Create an ibf with the operation's elements of the specified size. More... | |
static int | send_ibf (struct Operation *op, uint16_t ibf_order) |
Send an ibf of appropriate size. More... | |
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. More... | |
static int | send_full_element_iterator (void *cls, const struct GNUNET_HashCode *key, void *value) |
Send a set element. More... | |
static void | send_full_set (struct Operation *op) |
Switch to full set transmission for op. More... | |
int | check_union_p2p_strata_estimator (void *cls, const struct StrataEstimatorMessage *msg) |
Handle a strata estimator from a remote peer. More... | |
void | handle_union_p2p_strata_estimator (void *cls, const struct StrataEstimatorMessage *msg) |
Handle a strata estimator from a remote peer. More... | |
static int | send_offers_iterator (void *cls, uint32_t key, void *value) |
Iterator to send elements to a remote peer. More... | |
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. More... | |
static int | decode_and_send (struct Operation *op) |
Decode which elements are missing on each side, and send the appropriate offers and inquiries. More... | |
int | check_union_p2p_ibf (void *cls, const struct IBFMessage *msg) |
Check an IBF message from a remote peer. More... | |
void | handle_union_p2p_ibf (void *cls, const struct IBFMessage *msg) |
Handle an IBF message from a remote peer. More... | |
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. More... | |
static void | send_client_done (void *cls) |
Signal to the client that the operation has finished and destroy the operation. More... | |
static void | maybe_finish (struct Operation *op) |
Tests if the operation is finished, and if so notify. More... | |
int | check_union_p2p_elements (void *cls, const struct GNUNET_SET_ElementMessage *emsg) |
Check an element message from a remote peer. More... | |
void | handle_union_p2p_elements (void *cls, const struct GNUNET_SET_ElementMessage *emsg) |
Handle an element message from a remote peer. More... | |
int | check_union_p2p_full_element (void *cls, const struct GNUNET_SET_ElementMessage *emsg) |
Check a full element message from a remote peer. More... | |
void | handle_union_p2p_full_element (void *cls, const struct GNUNET_SET_ElementMessage *emsg) |
Handle an element message from a remote peer. More... | |
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). More... | |
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). More... | |
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. More... | |
void | handle_union_p2p_request_full (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle a request for full set transmission. More... | |
void | handle_union_p2p_full_done (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle a "full done" message. More... | |
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_HashCode s. More... | |
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_HashCode s. More... | |
int | check_union_p2p_offer (void *cls, const struct GNUNET_MessageHeader *mh) |
Check offer (of struct GNUNET_HashCode s). More... | |
void | handle_union_p2p_offer (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle offers (of struct GNUNET_HashCode s) and respond with demands (of struct GNUNET_HashCode s). More... | |
void | handle_union_p2p_done (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle a done message from a remote peer. More... | |
void | handle_union_p2p_over (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle an over message from a remote peer. More... | |
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. More... | |
static struct OperationState * | union_accept (struct Operation *op) |
Accept an union operation request from a remote peer. More... | |
static struct SetState * | union_set_create (void) |
Create a new set supporting the union operation. More... | |
static void | union_add (struct SetState *set_state, struct ElementEntry *ee) |
Add the element from the given element message to the set. More... | |
static void | union_remove (struct SetState *set_state, struct ElementEntry *ee) |
Remove the element given in the element message from the set. More... | |
static void | union_set_destroy (struct SetState *set_state) |
Destroy a set that supports the union operation. More... | |
static struct SetState * | union_copy_state (struct SetState *state) |
Copy union-specific set state. More... | |
static void | union_channel_death (struct Operation *op) |
Handle case where channel went down for an operation. More... | |
const struct SetVT * | _GSS_union_vt () |
Get the table with implementing functions for set union. More... | |
two-peer set operations
Definition in file gnunet-service-set_union.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "set-union", __VA_ARGS__) |
Definition at line 37 of file gnunet-service-set_union.c.
#define SE_STRATA_COUNT 32 |
Number of IBFs in a strata estimator.
Definition at line 43 of file gnunet-service-set_union.c.
#define SE_IBF_SIZE 80 |
Size of the IBFs in the strata estimator.
Definition at line 48 of file gnunet-service-set_union.c.
#define SE_IBF_HASH_NUM 4 |
The hash num parameter for the difference digests and strata estimators.
Definition at line 53 of file gnunet-service-set_union.c.
#define MAX_BUCKETS_PER_MESSAGE ((1 << 15) / IBF_BUCKET_SIZE) |
Number of buckets that can be transmitted in one message.
Definition at line 58 of file gnunet-service-set_union.c.
#define MAX_IBF_ORDER (20) |
The maximum size of an ibf we use is 2^(MAX_IBF_ORDER).
Choose this value so that computing the IBF is still cheaper than transmitting all values.
Definition at line 65 of file gnunet-service-set_union.c.
#define IBF_ALPHA 4 |
Number of buckets used in the ibf per estimated difference.
Definition at line 71 of file gnunet-service-set_union.c.
enum UnionOperationPhase |
Current phase we are in for a union operation.
Definition at line 77 of file gnunet-service-set_union.c.
|
static |
Iterator over hash map entries, called to destroy the linked list of colliding ibf key entries.
cls | closure |
key | current key code |
value | value in the hash map |
Definition at line 290 of file gnunet-service-set_union.c.
References KeyEntry::element, GNUNET_assert, GNUNET_free, GNUNET_YES, ElementEntry::remote, and value.
Referenced by union_op_cancel().
|
static |
Destroy the union operation.
Only things specific to the union operation are destroyed.
op | union operation to destroy |
Definition at line 314 of file gnunet-service-set_union.c.
References destroy_key_to_element_iter(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, ibf_destroy(), LOG, op, and strata_estimator_destroy().
Referenced by _GSS_union_vt().
|
static |
Inform the client that the union operation has failed, and proceed to destroy the evaluate operation.
op | the union operation to fail |
Definition at line 362 of file gnunet-service-set_union.c.
References _GSS_operation_destroy(), GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_SET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SET_STATUS_FAILURE, GNUNET_YES, LOG, msg, and op.
Referenced by decode_and_send(), handle_union_p2p_demand(), handle_union_p2p_done(), handle_union_p2p_elements(), handle_union_p2p_full_done(), handle_union_p2p_full_element(), handle_union_p2p_ibf(), handle_union_p2p_request_full(), and handle_union_p2p_strata_estimator().
|
static |
Derive the IBF key from a hash code and a salt.
src | the hash code |
Definition at line 387 of file gnunet-service-set_union.c.
References GNUNET_assert, GNUNET_CRYPTO_kdf(), GNUNET_OK, key, and salt.
Referenced by op_get_element(), op_register_element(), union_add(), and union_remove().
|
static |
Iterator over the mapping from IBF keys to element entries.
Checks if we have an element with a given GNUNET_HashCode.
cls | closure |
key | current key code |
value | value in the hash map |
Definition at line 429 of file gnunet-service-set_union.c.
References ctx, KeyEntry::element, ElementEntry::element_hash, GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_NO, GNUNET_YES, and value.
Referenced by op_get_element().
|
static |
Determine whether the given element is already in the operation's element set.
op | operation that should be tested for 'element_hash' |
element_hash | hash of the element to look for |
Definition at line 456 of file gnunet-service-set_union.c.
References ctx, get_ibf_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get_multiple(), GNUNET_SYSERR, IBF_Key::key_val, op, op_get_element_iterator(), and ret.
Referenced by handle_union_p2p_elements(), and handle_union_p2p_full_element().
|
static |
Insert an element into the union operation's key-to-element mapping.
Takes ownership of 'ee'. Note that this does not insert the element in the set, only in the operation's key-element mapping. This is done to speed up re-tried operations, if some elements were transmitted, and then the IBF fails to decode.
XXX: clarify ownership, doesn't sound right.
op | the union operation |
ee | the element entry |
received | was this element received from the remote peer? |
Definition at line 496 of file gnunet-service-set_union.c.
References KeyEntry::element, ElementEntry::element_hash, get_ibf_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_new, GNUNET_OK, KeyEntry::ibf_key, IBF_Key::key_val, op, and KeyEntry::received.
Referenced by handle_union_p2p_elements(), handle_union_p2p_full_element(), and init_key_to_element_iterator().
FIXME.
Definition at line 520 of file gnunet-service-set_union.c.
References IBF_Key::key_val, and salt.
Referenced by prepare_ibf_iterator().
|
static |
FIXME.
Definition at line 537 of file gnunet-service-set_union.c.
References IBF_Key::key_val, and salt.
Referenced by decode_and_send(), and handle_union_p2p_inquiry().
|
static |
Insert a key into an ibf.
cls | the ibf |
key | unused |
value | the key entry to get the key from |
Definition at line 557 of file gnunet-service-set_union.c.
References KeyEntry::element, ElementEntry::element_hash, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_YES, ibf_insert(), KeyEntry::ibf_key, IBF_Key::key_val, LOG, op, salt_key(), and value.
Referenced by prepare_ibf().
|
static |
Iterator for initializing the key-to-element mapping of a union operation.
cls | the union operation struct Operation * |
key | unused |
value | the struct ElementEntry * to insert into the key-to-element mapping |
Definition at line 589 of file gnunet-service-set_union.c.
References _GSS_is_element_of_operation(), GNUNET_assert, GNUNET_NO, GNUNET_YES, op, op_register_element(), ElementEntry::remote, and value.
Referenced by initialize_key_to_element().
|
static |
Initialize the IBF key to element mapping local to this set operation.
op | the set union operation |
Definition at line 617 of file gnunet-service-set_union.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), init_key_to_element_iterator(), and op.
Referenced by union_accept(), and union_evaluate().
|
static |
Create an ibf with the operation's elements of the specified size.
op | the union operation |
size | size of the ibf to create |
Definition at line 639 of file gnunet-service-set_union.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, ibf_create(), ibf_destroy(), op, prepare_ibf_iterator(), SE_IBF_HASH_NUM, and size.
Referenced by decode_and_send(), and send_ibf().
|
static |
Send an ibf of appropriate size.
Fragments the IBF into multiple messages if necessary.
op | the union operation |
ibf_order | order of the ibf to send, size=2^order |
Definition at line 670 of file gnunet-service-set_union.c.
References _GSS_statistics, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, IBF_BUCKET_SIZE, ibf_write_slice(), LOG, MAX_BUCKETS_PER_MESSAGE, msg, name, op, PHASE_INVENTORY_PASSIVE, and prepare_ibf().
Referenced by decode_and_send(), and handle_union_p2p_strata_estimator().
|
static |
Compute the necessary order of an ibf from the size of the symmetric set difference.
diff | the difference |
Definition at line 740 of file gnunet-service-set_union.c.
References IBF_ALPHA, MAX_IBF_ORDER, and SE_IBF_HASH_NUM.
Referenced by handle_union_p2p_strata_estimator().
|
static |
Send a set element.
cls | the union operation struct Operation * |
key | unused |
value | the struct ElementEntry * to insert into the key-to-element mapping |
Definition at line 764 of file gnunet-service-set_union.c.
References el, ElementEntry::element, GNUNET_SET_ElementMessage::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, key, LOG, op, and value.
Referenced by send_full_set().
|
static |
Switch to full set transmission for op.
op | operation to switch to full set transmission. |
Definition at line 796 of file gnunet-service-set_union.c.
References GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), LOG, op, PHASE_FULL_SENDING, and send_full_element_iterator().
Referenced by handle_union_p2p_request_full(), and handle_union_p2p_strata_estimator().
int check_union_p2p_strata_estimator | ( | void * | cls, |
const struct StrataEstimatorMessage * | msg | ||
) |
Handle a strata estimator from a remote peer.
cls | the union operation |
msg | the message |
Definition at line 821 of file gnunet-service-set_union.c.
References GNUNET_break, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, IBF_BUCKET_SIZE, msg, op, PHASE_EXPECT_SE, SE_IBF_SIZE, SE_STRATA_COUNT, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
void handle_union_p2p_strata_estimator | ( | void * | cls, |
const struct StrataEstimatorMessage * | msg | ||
) |
Handle a strata estimator from a remote peer.
cls | the union operation |
msg | the message |
Definition at line 853 of file gnunet-service-set_union.c.
References _GSS_statistics, removetrailingwhitespace::f, fail_union_operation(), get_order_from_difference(), getenv(), GNUNET_assert, GNUNET_break, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_YES, LOG, msg, op, PHASE_EXPECT_IBF, SE_IBF_HASH_NUM, SE_IBF_SIZE, SE_STRATA_COUNT, send_full_set(), send_ibf(), GNUNET_MessageHeader::size, strata_estimator_create(), strata_estimator_destroy(), strata_estimator_difference(), strata_estimator_read(), and GNUNET_MessageHeader::type.
|
static |
Iterator to send elements to a remote peer.
cls | closure with the element key and the union operation |
key | ignored |
value | the key entry |
Definition at line 986 of file gnunet-service-set_union.c.
References KeyEntry::element, ElementEntry::element_hash, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, GNUNET_MQ_msg_header_extra, GNUNET_MQ_send(), GNUNET_YES, KeyEntry::ibf_key, SendElementClosure::ibf_key, IBF_Key::key_val, LOG, mh, op, SendElementClosure::op, and value.
Referenced by send_offers_for_key().
Send offers (in the form of GNUNET_Hash-es) to the remote peer for the given IBF key.
op | union operation |
ibf_key | IBF key of interest |
Definition at line 1022 of file gnunet-service-set_union.c.
References GNUNET_CONTAINER_multihashmap32_get_multiple(), SendElementClosure::ibf_key, op, SendElementClosure::op, and send_offers_iterator().
Referenced by decode_and_send(), and handle_union_p2p_inquiry().
|
static |
Decode which elements are missing on each side, and send the appropriate offers and inquiries.
op | union operation |
Definition at line 1046 of file gnunet-service-set_union.c.
References _GSS_statistics, fail_union_operation(), GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, GNUNET_MQ_msg_extra, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, ibf_decode(), ibf_destroy(), ibf_dup(), ibf_subtract(), key, IBF_Key::key_val, LOG, MAX_IBF_ORDER, msg, op, PHASE_INVENTORY_ACTIVE, prepare_ibf(), res, send_ibf(), send_offers_for_key(), InvertibleBloomFilter::size, size, and unsalt_key().
Referenced by handle_union_p2p_ibf().
int check_union_p2p_ibf | ( | void * | cls, |
const struct IBFMessage * | msg | ||
) |
Check an IBF message from a remote peer.
Reassemble the IBF from multiple pieces, and process the whole IBF once possible.
cls | the union operation |
msg | the header of the message |
Definition at line 1210 of file gnunet-service-set_union.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, IBF_BUCKET_SIZE, msg, op, PHASE_EXPECT_IBF, PHASE_EXPECT_IBF_CONT, PHASE_INVENTORY_PASSIVE, and GNUNET_MessageHeader::size.
void handle_union_p2p_ibf | ( | void * | cls, |
const struct IBFMessage * | msg | ||
) |
Handle an IBF message from a remote peer.
Reassemble the IBF from multiple pieces, and process the whole IBF once possible.
cls | the union operation |
msg | the header of the message |
Definition at line 1273 of file gnunet-service-set_union.c.
References decode_and_send(), fail_union_operation(), GNUNET_assert, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, IBF_BUCKET_SIZE, ibf_create(), ibf_read_slice(), LOG, msg, op, PHASE_EXPECT_IBF, PHASE_EXPECT_IBF_CONT, PHASE_INVENTORY_ACTIVE, PHASE_INVENTORY_PASSIVE, SE_IBF_HASH_NUM, and GNUNET_MessageHeader::size.
|
static |
Send a result message to the client indicating that there is a new element.
op | union operation |
element | element to send |
status | status to send with the new element |
Definition at line 1351 of file gnunet-service-set_union.c.
References GNUNET_SET_ResultMessage::current_size, GNUNET_SET_Element::data, GNUNET_SET_ResultMessage::element_type, GNUNET_SET_Element::element_type, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_RESULT, GNUNET_MQ_discard(), GNUNET_MQ_msg_extra, GNUNET_MQ_send(), LOG, op, GNUNET_SET_ResultMessage::request_id, GNUNET_SET_ResultMessage::result_status, GNUNET_SET_Element::size, and status.
Referenced by handle_union_p2p_demand(), handle_union_p2p_elements(), and handle_union_p2p_full_element().
|
static |
Signal to the client that the operation has finished and destroy the operation.
cls | operation to destroy |
Definition at line 1389 of file gnunet-service-set_union.c.
References _GSS_statistics, GNUNET_SET_ResultMessage::current_size, GNUNET_SET_ResultMessage::element_type, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_SET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SET_STATUS_DONE, GNUNET_SET_STATUS_FAILURE, GNUNET_STATISTICS_update(), GNUNET_YES, LOG, op, PHASE_DONE, GNUNET_SET_ResultMessage::request_id, and GNUNET_SET_ResultMessage::result_status.
Referenced by handle_union_p2p_full_done(), handle_union_p2p_over(), maybe_finish(), and union_channel_death().
|
static |
Tests if the operation is finished, and if so notify.
op | operation to check |
Definition at line 1443 of file gnunet-service-set_union.c.
References _GSS_operation_destroy2(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), LOG, op, PHASE_DONE, PHASE_FINISH_CLOSING, PHASE_FINISH_WAITING, and send_client_done().
Referenced by handle_union_p2p_done(), and handle_union_p2p_elements().
int check_union_p2p_elements | ( | void * | cls, |
const struct GNUNET_SET_ElementMessage * | emsg | ||
) |
Check an element message from a remote peer.
cls | the union operation |
emsg | the message |
Definition at line 1489 of file gnunet-service-set_union.c.
References GNUNET_break_op, GNUNET_CONTAINER_multihashmap_size(), GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, and op.
void handle_union_p2p_elements | ( | void * | cls, |
const struct GNUNET_SET_ElementMessage * | emsg | ||
) |
Handle an element message from a remote peer.
Sent by the other peer either because we decoded an IBF and placed a demand, or because the other peer switched to full set transmission.
cls | the union operation |
emsg | the message |
Definition at line 1517 of file gnunet-service-set_union.c.
References _GSS_statistics, GNUNET_SET_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SET_ElementMessage::element_type, GNUNET_SET_Element::element_type, fail_union_operation(), GNUNET_break, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SET_element_hash(), GNUNET_SET_RESULT_ADDED, GNUNET_SET_RESULT_SYMMETRIC, GNUNET_SET_STATUS_ADD_LOCAL, GNUNET_SET_STATUS_OK, GNUNET_STATISTICS_update(), GNUNET_YES, GNUNET_SET_ElementMessage::header, LOG, maybe_finish(), op, op_get_element(), op_register_element(), KeyEntry::received, ElementEntry::remote, send_client_element(), GNUNET_MessageHeader::size, and GNUNET_SET_Element::size.
int check_union_p2p_full_element | ( | void * | cls, |
const struct GNUNET_SET_ElementMessage * | emsg | ||
) |
Check a full element message from a remote peer.
cls | the union operation |
emsg | the message |
Definition at line 1620 of file gnunet-service-set_union.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, and op.
void handle_union_p2p_full_element | ( | void * | cls, |
const struct GNUNET_SET_ElementMessage * | emsg | ||
) |
Handle an element message from a remote peer.
cls | the union operation |
emsg | the message |
Definition at line 1642 of file gnunet-service-set_union.c.
References _GSS_statistics, GNUNET_SET_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SET_ElementMessage::element_type, GNUNET_SET_Element::element_type, fail_union_operation(), GNUNET_break, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SET_element_hash(), GNUNET_SET_RESULT_ADDED, GNUNET_SET_RESULT_SYMMETRIC, GNUNET_SET_STATUS_ADD_LOCAL, GNUNET_SET_STATUS_OK, GNUNET_STATISTICS_update(), GNUNET_YES, GNUNET_SET_ElementMessage::header, LOG, op, op_get_element(), op_register_element(), KeyEntry::received, ElementEntry::remote, send_client_element(), GNUNET_MessageHeader::size, and GNUNET_SET_Element::size.
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).
cls | the union operation |
msg | the message |
Definition at line 1737 of file gnunet-service-set_union.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, msg, op, PHASE_INVENTORY_PASSIVE, and GNUNET_MessageHeader::size.
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).
cls | the union operation |
msg | the message |
Definition at line 1773 of file gnunet-service-set_union.c.
References GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, LOG, msg, op, send_offers_for_key(), GNUNET_MessageHeader::size, and unsalt_key().
|
static |
Iterator over hash map entries, called to destroy the linked list of colliding ibf key entries.
cls | closure |
key | current key code |
value | value in the hash map |
Definition at line 1811 of file gnunet-service-set_union.c.
References GNUNET_SET_Element::data, ElementEntry::element, KeyEntry::element, GNUNET_SET_ElementMessage::element_type, GNUNET_SET_Element::element_type, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, op, KeyEntry::received, GNUNET_SET_Element::size, and value.
Referenced by handle_union_p2p_full_done().
void handle_union_p2p_request_full | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Handle a request for full set transmission.
cls | closure, a set union operation |
mh | the demand message |
Definition at line 1843 of file gnunet-service-set_union.c.
References fail_union_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SET_OPERATION_UNION, LOG, op, PHASE_EXPECT_IBF, and send_full_set().
void handle_union_p2p_full_done | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Handle a "full done" message.
cls | closure, a set union operation |
mh | the demand message |
Definition at line 1877 of file gnunet-service-set_union.c.
References _GSS_operation_destroy2(), fail_union_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), LOG, op, PHASE_DONE, PHASE_EXPECT_IBF, PHASE_FULL_SENDING, send_client_done(), and send_missing_full_elements_iter().
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_HashCode
s.
cls | closure, a set union operation |
mh | the demand message |
Definition at line 1938 of file gnunet-service-set_union.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, mh, and op.
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_HashCode
s.
cls | closure, a set union operation |
mh | the demand message |
Definition at line 1969 of file gnunet-service-set_union.c.
References _GSS_is_element_of_operation(), _GSS_statistics, GNUNET_SET_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SET_ElementMessage::element_type, GNUNET_SET_Element::element_type, fail_union_operation(), GNUNET_break, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SET_RESULT_ADDED, GNUNET_SET_RESULT_SYMMETRIC, GNUNET_SET_STATUS_ADD_REMOTE, GNUNET_STATISTICS_update(), LOG, mh, op, GNUNET_SET_ElementMessage::reserved, send_client_element(), and GNUNET_SET_Element::size.
int check_union_p2p_offer | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Check offer (of struct GNUNET_HashCode
s).
cls | the union operation |
mh | the message |
Definition at line 2045 of file gnunet-service-set_union.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, mh, op, PHASE_INVENTORY_ACTIVE, and PHASE_INVENTORY_PASSIVE.
void handle_union_p2p_offer | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Handle offers (of struct GNUNET_HashCode
s) and respond with demands (of struct GNUNET_HashCode
s).
cls | the union operation |
mh | the message |
Definition at line 2083 of file gnunet-service-set_union.c.
References _GSS_is_element_of_operation(), GNUNET_assert, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, GNUNET_MQ_msg_header_extra, GNUNET_MQ_send(), GNUNET_OK, GNUNET_YES, LOG, mh, and op.
void handle_union_p2p_done | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Handle a done message from a remote peer.
cls | the union operation |
mh | the message |
Definition at line 2144 of file gnunet-service-set_union.c.
References fail_union_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SET_OPERATION_UNION, LOG, maybe_finish(), op, PHASE_FINISH_CLOSING, PHASE_FINISH_WAITING, PHASE_INVENTORY_ACTIVE, and PHASE_INVENTORY_PASSIVE.
void handle_union_p2p_over | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Handle an over message from a remote peer.
cls | the union operation |
mh | the message |
Definition at line 2198 of file gnunet-service-set_union.c.
References send_client_done().
|
static |
Initiate operation to evaluate a set union with a remote peer.
op | operation to perform (to be initialized) |
opaque_context | message to be transmitted to the listener to convince it to accept, may be NULL |
Definition at line 2213 of file gnunet-service-set_union.c.
References _GSS_statistics, GNUNET_break, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, GNUNET_MQ_msg_nested_mh, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_SET_OPERATION_UNION, GNUNET_STATISTICS_update(), initialize_key_to_element(), LOG, msg, op, PHASE_EXPECT_SE, state, and strata_estimator_dup().
Referenced by _GSS_union_vt().
|
static |
Accept an union operation request from a remote peer.
Only initializes the private operation state.
op | operation that will be accepted as a union operation |
Definition at line 2273 of file gnunet-service-set_union.c.
References _GSS_statistics, GNUNET_CONTAINER_multihashmap32_size(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_htonll(), GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), IBF_BUCKET_SIZE, StrataEstimator::ibf_size, initialize_key_to_element(), LOG, op, PHASE_EXPECT_IBF, StrataEstimatorMessage::set_size, state, StrataEstimator::strata_count, strata_estimator_dup(), strata_estimator_write(), and type.
Referenced by _GSS_union_vt().
|
static |
Create a new set supporting the union operation.
We maintain one strata estimator per set and then manipulate it over the lifetime of the set, as recreating a strata estimator would be expensive.
Definition at line 2339 of file gnunet-service-set_union.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, LOG, SetState::se, SE_IBF_HASH_NUM, SE_IBF_SIZE, SE_STRATA_COUNT, and strata_estimator_create().
Referenced by _GSS_union_vt().
|
static |
Add the element from the given element message to the set.
set_state | state of the set want to add to |
ee | the element to add to the set |
Definition at line 2366 of file gnunet-service-set_union.c.
References ElementEntry::element_hash, get_ibf_key(), SetState::se, and strata_estimator_insert().
Referenced by _GSS_union_vt().
|
static |
Remove the element given in the element message from the set.
Only marks the element as removed, so that older set operations can still exchange it.
set_state | state of the set to remove from |
ee | set element to remove |
Definition at line 2382 of file gnunet-service-set_union.c.
References ElementEntry::element_hash, get_ibf_key(), SetState::se, and strata_estimator_remove().
Referenced by _GSS_union_vt().
|
static |
Destroy a set that supports the union operation.
set_state | the set to destroy |
Definition at line 2396 of file gnunet-service-set_union.c.
References GNUNET_free, SetState::se, and strata_estimator_destroy().
Referenced by _GSS_union_vt().
Copy union-specific set state.
state | source state for copying the union state |
Definition at line 2414 of file gnunet-service-set_union.c.
References GNUNET_assert, GNUNET_new, SetState::se, state, and strata_estimator_dup().
Referenced by _GSS_union_vt().
|
static |
Handle case where channel went down for an operation.
op | operation that lost the channel |
Definition at line 2433 of file gnunet-service-set_union.c.
References _GSS_operation_destroy(), GNUNET_YES, op, and send_client_done().
Referenced by _GSS_union_vt().
const struct SetVT * _GSS_union_vt | ( | void | ) |
Get the table with implementing functions for set union.
Definition at line 2448 of file gnunet-service-set_union.c.
References SetVT::create, union_accept(), union_add(), union_channel_death(), union_copy_state(), union_evaluate(), union_op_cancel(), union_remove(), union_set_create(), and union_set_destroy().
Referenced by handle_client_copy_lazy_connect(), and handle_client_create_set().