![]() |
GNUnet
0.11.x
|
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_CONT, PHASE_INVENTORY_ACTIVE, PHASE_INVENTORY_PASSIVE, PHASE_FINISH_CLOSING, PHASE_FINISH_WAITING, PHASE_DONE, PHASE_FULL_SENDING } |
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 a 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.
Referenced by decode_and_send(), fail_union_operation(), 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_inquiry(), handle_union_p2p_offer(), handle_union_p2p_request_full(), handle_union_p2p_strata_estimator(), maybe_finish(), prepare_ibf_iterator(), send_client_done(), send_client_element(), send_full_element_iterator(), send_full_set(), send_ibf(), send_offers_iterator(), union_accept(), union_evaluate(), union_op_cancel(), and union_set_create().
#define SE_STRATA_COUNT 32 |
Number of IBFs in a strata estimator.
Definition at line 43 of file gnunet-service-set_union.c.
Referenced by check_union_p2p_strata_estimator(), handle_union_p2p_strata_estimator(), and union_set_create().
#define SE_IBF_SIZE 80 |
Size of the IBFs in the strata estimator.
Definition at line 48 of file gnunet-service-set_union.c.
Referenced by check_union_p2p_strata_estimator(), handle_union_p2p_strata_estimator(), and union_set_create().
#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.
Referenced by get_order_from_difference(), handle_union_p2p_ibf(), handle_union_p2p_strata_estimator(), prepare_ibf(), and union_set_create().
#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.
Referenced by send_ibf().
#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.
Referenced by decode_and_send(), and get_order_from_difference().
#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.
Referenced by get_order_from_difference().
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 OperationState::demanded_hashes, 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(), OperationState::key_to_element, OperationState::local_ibf, LOG, OperationState::remote_ibf, OperationState::se, Operation::state, 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(), Operation::client_request_id, Set::cs, GNUNET_SET_ResultMessage::element_type, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_SET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SET_STATUS_FAILURE, GNUNET_YES, LOG, ClientState::mq, msg, GNUNET_SET_ResultMessage::request_id, GNUNET_SET_ResultMessage::result_status, and Operation::set.
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 OperationState::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, GetElementContext::hash, GetElementContext::k, 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 get_ibf_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap32_get_multiple(), GNUNET_SYSERR, GetElementContext::hash, GetElementContext::k, OperationState::key_to_element, IBF_Key::key_val, op_get_element_iterator(), ret, and Operation::state.
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, OperationState::key_to_element, IBF_Key::key_val, KeyEntry::received, and Operation::state.
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.
Referenced by prepare_ibf_iterator().
|
static |
FIXME.
Definition at line 537 of file gnunet-service-set_union.c.
References IBF_Key::key_val.
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, OperationState::local_ibf, LOG, op, salt_key(), OperationState::salt_send, Operation::state, 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 Set::content, SetContent::elements, GNUNET_assert, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), init_key_to_element_iterator(), OperationState::key_to_element, len, Operation::set, and Operation::state.
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(), OperationState::key_to_element, OperationState::local_ibf, prepare_ibf_iterator(), SE_IBF_HASH_NUM, and Operation::state.
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(), OperationState::local_ibf, LOG, MAX_BUCKETS_PER_MESSAGE, Operation::mq, msg, name, IBFMessage::offset, IBFMessage::order, OperationState::phase, PHASE_INVENTORY_PASSIVE, prepare_ibf(), IBFMessage::reserved1, IBFMessage::reserved2, IBFMessage::salt, OperationState::salt_send, and Operation::state.
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 GNUNET_SET_Element::data, el, ElementEntry::element, GNUNET_SET_Element::element_type, 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, LOG, Operation::mq, op, GNUNET_SET_Element::size, 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 Set::content, SetContent::elements, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), LOG, Operation::mq, OperationState::phase, PHASE_FULL_SENDING, send_full_element_iterator(), Operation::set, and Operation::state.
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, StrataEstimatorMessage::header, IBF_BUCKET_SIZE, len, op, OperationState::phase, PHASE_EXPECT_SE, SE_IBF_SIZE, SE_STRATA_COUNT, GNUNET_MessageHeader::size, Operation::state, 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, Operation::byzantine, Operation::channel, removetrailingwhitespace::f, fail_union_operation(), Operation::force_full, 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, StrataEstimatorMessage::header, OperationState::initial_size, len, LOG, Operation::mq, op, OperationState::phase, PHASE_EXPECT_IBF, OperationState::se, SE_IBF_HASH_NUM, SE_IBF_SIZE, SE_STRATA_COUNT, send_full_set(), send_ibf(), StrataEstimatorMessage::set_size, GNUNET_MessageHeader::size, Operation::state, 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, Operation::mq, 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, OperationState::key_to_element, op, SendElementClosure::op, send_offers_iterator(), and Operation::state.
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, OperationState::local_ibf, LOG, MAX_IBF_ORDER, Operation::mq, msg, OperationState::phase, PHASE_INVENTORY_ACTIVE, prepare_ibf(), OperationState::remote_ibf, res, InquiryMessage::salt, OperationState::salt_receive, OperationState::salt_send, send_ibf(), send_offers_for_key(), size, InvertibleBloomFilter::size, Operation::state, 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, IBFMessage::header, IBF_BUCKET_SIZE, OperationState::ibf_buckets_received, msg, IBFMessage::offset, op, Set::operation, IBFMessage::order, OperationState::phase, PHASE_EXPECT_IBF, PHASE_EXPECT_IBF_CONT, PHASE_INVENTORY_PASSIVE, OperationState::remote_ibf, IBFMessage::salt, OperationState::salt_receive, Operation::set, InvertibleBloomFilter::size, GNUNET_MessageHeader::size, and Operation::state.
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 Operation::channel, 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, IBFMessage::header, IBF_BUCKET_SIZE, OperationState::ibf_buckets_received, ibf_create(), ibf_read_slice(), LOG, msg, IBFMessage::offset, op, IBFMessage::order, OperationState::phase, PHASE_EXPECT_IBF, PHASE_EXPECT_IBF_CONT, PHASE_INVENTORY_ACTIVE, PHASE_INVENTORY_PASSIVE, OperationState::remote_ibf, IBFMessage::salt, OperationState::salt_receive, SE_IBF_HASH_NUM, InvertibleBloomFilter::size, GNUNET_MessageHeader::size, and Operation::state.
|
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 Operation::client_request_id, Set::cs, GNUNET_SET_ResultMessage::current_size, GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_SET_ResultMessage::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(), OperationState::key_to_element, LOG, ClientState::mq, GNUNET_SET_ResultMessage::request_id, GNUNET_SET_ResultMessage::result_status, Operation::set, GNUNET_SET_Element::size, and Operation::state.
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, OperationState::client_done_sent, Operation::client_request_id, Set::cs, 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, OperationState::key_to_element, LOG, ClientState::mq, op, OperationState::phase, PHASE_DONE, GNUNET_SET_ResultMessage::request_id, GNUNET_SET_ResultMessage::result_status, Operation::set, and Operation::state.
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(), OperationState::demanded_hashes, GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), LOG, Operation::mq, OperationState::phase, PHASE_DONE, PHASE_FINISH_CLOSING, PHASE_FINISH_WAITING, send_client_done(), and Operation::state.
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 OperationState::demanded_hashes, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_size(), GNUNET_OK, GNUNET_SET_OPERATION_UNION, GNUNET_SYSERR, op, Set::operation, Operation::set, and Operation::state.
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, Operation::channel, GNUNET_SET_Element::data, OperationState::demanded_hashes, ElementEntry::element, ElementEntry::element_hash, element_size, GNUNET_SET_Element::element_type, GNUNET_SET_ElementMessage::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, OperationState::received_fresh, OperationState::received_total, ElementEntry::remote, Operation::result_mode, send_client_element(), GNUNET_SET_Element::size, GNUNET_MessageHeader::size, and Operation::state.
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, op, Set::operation, and Operation::set.
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, Operation::byzantine, Operation::channel, GNUNET_SET_Element::data, ElementEntry::element, ElementEntry::element_hash, element_size, GNUNET_SET_Element::element_type, GNUNET_SET_ElementMessage::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, OperationState::received_fresh, OperationState::received_total, ElementEntry::remote, Operation::result_mode, send_client_element(), GNUNET_SET_Element::size, GNUNET_MessageHeader::size, and Operation::state.
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, InquiryMessage::header, op, Set::operation, OperationState::phase, PHASE_INVENTORY_PASSIVE, Operation::set, GNUNET_MessageHeader::size, and Operation::state.
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 Operation::channel, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, InquiryMessage::header, LOG, op, InquiryMessage::salt, 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_Element::element_type, GNUNET_SET_ElementMessage::element_type, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, Operation::mq, 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 Operation::channel, fail_union_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SET_OPERATION_UNION, LOG, op, Set::operation, OperationState::phase, PHASE_EXPECT_IBF, send_full_set(), Operation::set, and Operation::state.
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(), Operation::channel, 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(), OperationState::key_to_element, LOG, Operation::mq, op, OperationState::phase, PHASE_DONE, PHASE_EXPECT_IBF, PHASE_FULL_SENDING, send_client_done(), send_missing_full_elements_iter(), and Operation::state.
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, op, Set::operation, Operation::set, and GNUNET_MessageHeader::size.
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, Operation::channel, Set::content, GNUNET_SET_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SET_Element::element_type, GNUNET_SET_ElementMessage::element_type, SetContent::elements, 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, Operation::mq, op, GNUNET_SET_ElementMessage::reserved, Operation::result_mode, send_client_element(), Operation::set, GNUNET_SET_Element::size, and GNUNET_MessageHeader::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, op, Set::operation, OperationState::phase, PHASE_INVENTORY_ACTIVE, PHASE_INVENTORY_PASSIVE, Operation::set, GNUNET_MessageHeader::size, and Operation::state.
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(), Operation::channel, Set::content, OperationState::demanded_hashes, SetContent::elements, 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, Operation::mq, op, Operation::set, GNUNET_MessageHeader::size, and Operation::state.
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 Operation::channel, fail_union_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_SET_OPERATION_UNION, LOG, maybe_finish(), op, Set::operation, OperationState::phase, PHASE_FINISH_CLOSING, PHASE_FINISH_WAITING, PHASE_INVENTORY_ACTIVE, PHASE_INVENTORY_PASSIVE, Operation::set, and Operation::state.
void handle_union_p2p_over | ( | void * | cls, |
const struct GNUNET_MessageHeader * | mh | ||
) |
Handle a over message from a remote peer.
Handle an over message from a remote peer.
cls | the union operation |
mh | the message |
Definition at line 2204 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 2219 of file gnunet-service-set_union.c.
References _GSS_statistics, OperationState::demanded_hashes, 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(), OperationState::initial_size, initialize_key_to_element(), OperationState::key_to_element, LOG, Operation::mq, msg, OperationRequestMessage::operation, OperationState::phase, PHASE_EXPECT_SE, OperationState::salt_receive, OperationState::salt_send, OperationState::se, SetState::se, Operation::set, state, Operation::state, Set::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 2279 of file gnunet-service-set_union.c.
References _GSS_statistics, buf, Set::content, OperationState::demanded_hashes, SetContent::elements, 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, OperationState::initial_size, initialize_key_to_element(), OperationState::key_to_element, len, LOG, Operation::mq, OperationState::phase, PHASE_EXPECT_IBF, OperationState::salt_receive, OperationState::salt_send, OperationState::se, SetState::se, Operation::set, StrataEstimatorMessage::set_size, state, Operation::state, Set::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 2345 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 2372 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 2388 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 2402 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 2420 of file gnunet-service-set_union.c.
References GNUNET_assert, GNUNET_new, SetState::se, and strata_estimator_dup().
Referenced by _GSS_union_vt().