40 #define LOG(kind, ...) GNUNET_log_from (kind, "setu", __VA_ARGS__) 46 #define INCOMING_CHANNEL_TIMEOUT GNUNET_TIME_UNIT_MINUTES 51 #define SE_STRATA_COUNT 32 56 #define SE_IBF_SIZE 80 61 #define SE_IBF_HASH_NUM 4 66 #define MAX_BUCKETS_PER_MESSAGE ((1 << 15) / IBF_BUCKET_SIZE) 73 #define MAX_IBF_ORDER (20) 318 int client_done_sent;
354 uint32_t remote_element_count;
359 uint32_t client_request_id;
389 int byzantine_lower_bound;
402 unsigned int generation_created;
420 unsigned int refcount;
425 unsigned int latest_generation;
481 unsigned int current_generation;
669 "Union operation failed\n");
671 "# Union operations failed",
686 "# Union operations succeeded",
690 "Signalling client that union operation is done\n");
720 struct Set *
set = op->
set;
724 "Destroying union operation %p\n",
768 if (NULL != (channel = op->
channel))
800 "Destroying incoming operation %p\n",
802 if (NULL != (listener = op->
listener))
828 if (NULL != (channel = op->
channel))
860 "union operation failed\n");
1021 x = (x >> s) | (x << (64 - s));
1037 x = (x << s) | (x >> (64 - s));
1059 "[OP %p] inserting %lx (hash %s) into ibf\n",
1157 "Failed to allocate local IBF\n");
1180 unsigned int buckets_sent = 0;
1191 "sending ibf of size %u\n",
1195 char name[64] = { 0 };
1196 snprintf (name,
sizeof(name),
"# sent IBF (order %u)", ibf_order);
1202 while (buckets_sent < (1 << ibf_order))
1204 unsigned int buckets_in_message;
1208 buckets_in_message = (1 << ibf_order) - buckets_sent;
1218 msg->
order = ibf_order;
1219 msg->
offset = htonl (buckets_sent);
1222 buckets_in_message, &msg[1]);
1223 buckets_sent += buckets_in_message;
1225 "ibf chunk size %u, %u/%u sent\n",
1249 unsigned int ibf_order;
1252 while (((1 << ibf_order) < (
IBF_ALPHA * diff) ||
1257 return ibf_order + 1;
1282 "Sending element %s\n",
1309 "Dedicing to transmit the full set\n");
1366 uint64_t other_size;
1373 "# bytes of SE received",
1381 if (NULL == remote_se)
1403 diff = diff * 3 / 2;
1409 "got se diff=%d, using ibf size %d\n",
1416 set_debug =
getenv (
"GNUNET_SETU_BENCHMARK");
1417 if ((NULL != set_debug) &&
1418 (0 == strcmp (set_debug,
"1")))
1420 FILE *
f = fopen (
"set.log",
"a");
1421 fprintf (f,
"%llu\n", (
unsigned long long) diff);
1427 (other_size < op->byzantine_lower_bound))
1439 "Deciding to go for full set transmission (diff=%d, own set=%llu)\n",
1456 "Telling other peer that we expect its full set\n");
1476 "Failed to send IBF, closing connection\n");
1514 "[OP %p] sending element offer (%s) to peer\n",
1558 unsigned int num_decoded;
1579 "decoding IBF (size=%u)\n",
1598 "decoded ibf key %lx\n",
1601 if ((num_decoded > diff_ibf->
size) ||
1602 ((num_decoded > 1) &&
1606 "detected cyclic ibf (decoded %u/%u)\n",
1617 while (1 << next_order < diff_ibf->
size)
1623 "decoding failed, sending larger ibf (size %u)\n",
1635 "Failed to send IBF, closing connection\n");
1644 "# of failed union operations (too large)",
1649 "set union failed: reached ibf limit\n");
1661 "transmitted all values, sending DONE\n");
1679 else if (-1 == side)
1694 "sending element inquiry for IBF key %lx\n",
1723 unsigned int buckets_in_message;
1725 buckets_in_message = (ntohs (msg->
header.
size) -
sizeof *
msg)
1727 if (0 == buckets_in_message)
1732 if ((ntohs (msg->
header.
size) -
sizeof *msg) != buckets_in_message
1781 unsigned int buckets_in_message;
1783 buckets_in_message = (ntohs (msg->
header.
size) -
sizeof *
msg)
1791 "Creating new ibf of size %u\n",
1796 "Receiving new IBF with salt %u\n",
1801 "Failed to parse remote IBF, closing connection\n");
1806 if (0 != ntohl (msg->
offset))
1817 "Received more of IBF\n");
1830 "received full ibf\n");
1837 "Failed to decode IBF, closing connection\n");
1863 "sending element (size %u) to client\n",
1896 unsigned int num_demanded;
1904 "In PHASE_FINISH_WAITING, pending %u demands\n",
1906 if (0 == num_demanded)
1921 "In PHASE_FINISH_CLOSING, pending %u demands\n",
1923 if (0 == num_demanded)
1971 element_size = ntohs (emsg->
header.
size) -
sizeof(
struct 1995 "Got element (size %u, hash %s) from peer\n",
1996 (
unsigned int) element_size,
2000 "# received elements",
2004 "# exchanged elements",
2017 "# repeated elements",
2026 "Registering new element from remote peer\n");
2105 "Got element (full diff, size %u, hash %s) from peer\n",
2106 (
unsigned int) element_size,
2110 "# received elements",
2114 "# exchanged elements",
2127 "# repeated elements",
2136 "Registering new element from remote peer\n");
2151 "Other peer sent only %llu/%llu fresh elements, failing operation\n",
2174 unsigned int num_keys;
2182 / sizeof(struct IBF_Key);
2184 != num_keys *
sizeof(
struct IBF_Key))
2204 const struct IBF_Key *ibf_key;
2205 unsigned int num_keys;
2208 "Received union inquiry\n");
2210 / sizeof(struct IBF_Key);
2211 ibf_key = (
const struct IBF_Key *) &msg[1];
2212 while (0 != num_keys--)
2214 struct IBF_Key unsalted_key;
2276 "Received request for full set transmission\n");
2310 "got FULL DONE, sending elements that other peer is missing\n");
2327 "got FULL DONE, finishing\n");
2339 "Handle full done phase is %u\n",
2340 (
unsigned) op->
phase);
2362 unsigned int num_hashes;
2366 / sizeof(struct GNUNET_HashCode);
2368 != num_hashes *
sizeof(
struct GNUNET_HashCode))
2392 unsigned int num_hashes;
2396 / sizeof(struct GNUNET_HashCode);
2397 for (hash = (
const struct GNUNET_HashCode *) &mh[1];
2399 hash++, num_hashes--)
2426 "[OP %p] Sending demanded element (size %u, hash %s) to peer\n",
2432 "# exchanged elements",
2456 unsigned int num_hashes;
2466 / sizeof(struct GNUNET_HashCode);
2468 num_hashes *
sizeof(
struct GNUNET_HashCode))
2490 unsigned int num_hashes;
2493 / sizeof(struct GNUNET_HashCode);
2494 for (hash = (
const struct GNUNET_HashCode *) &mh[1];
2496 hash++, num_hashes--)
2513 "Skipped sending duplicate demand\n");
2525 "[OP %p] Requesting element (hash %s)\n",
2528 sizeof(
struct GNUNET_HashCode),
2532 sizeof(
struct GNUNET_HashCode));
2557 "got DONE (as passive partner), waiting for our demands to be satisfied\n");
2571 "got DONE (as active partner), waiting to finish\n");
2690 "Client disconnected, cleaning up\n");
2691 if (NULL != (
set = cs->
set))
2696 "Destroying client's set\n");
2698 while (NULL != set->ops_head)
2702 if (NULL != set->se)
2708 set->content = NULL;
2724 if (NULL != (listener = cs->
listener))
2727 "Destroying client's listener\n");
2730 while (NULL != (op = listener->
op_head))
2733 "Destroying incoming operation `%u' from peer `%s'\n",
2780 if (NULL == listener)
2786 if ((NULL != nested_context) &&
2825 if (NULL != nested_context)
2830 "Received P2P operation request (port %s) for active listener\n",
2844 "Suggesting incoming request with accept id %u to listener %p of client %p\n",
2873 "Client created new set for union operation\n");
2874 if (NULL != cs->
set)
2891 "Failed to allocate strata estimator\n");
2899 set->content->refcount = 1;
2924 "Remote peer's incoming request timed out\n");
2954 "New incoming channel\n");
3105 "New listener created (port %s)\n",
3138 "Client rejected unknown operation %u\n",
3144 "Peer request (app %s) rejected by client\n",
3183 if (NULL == (
set = cs->
set))
3202 "Client inserts element %s of size %u\n",
3215 set->content->elements,
3223 "Client inserted element %s of size %u twice (ignored)\n",
3243 set->content->latest_generation++;
3244 set->current_generation++;
3339 if (NULL == (
set = cs->
set))
3366 "Creating new CADET channel to port %s for set union\n",
3398 "Initiating union operation evaluation\n");
3400 "# of total union operations",
3404 "# of initiated union operations",
3409 if (NULL != context)
3411 "sent op request with context message\n");
3414 "sent op request without context message\n");
3439 if (NULL == (
set = cs->
set))
3463 "Client canceled non-existent op %u\n",
3469 "Client requested cancel for op %u\n",
3496 if (NULL == (
set = cs->
set))
3510 "Client %p accepted request %u of listener %p that is no longer active\n",
3523 "Client accepting request %u\n",
3548 "accepting set union operation\n");
3550 "# of accepted union operations",
3554 "# of total union operations",
3625 "handled shutdown request\n");
3653 _ (
"Could not connect to CADET service\n"));
struct Operation * prev
Kept in a DLL of the listener, if listener is non-NULL.
Context for op_get_element_iterator.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
uint32_t offset
Offset of the strata in the rest of the message.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST
Request a set union operation from a remote peer.
struct Set * prev
Sets are held in a doubly linked list.
uint32_t received_fresh
Number of elements we received from the other peer that were not in the local set yet...
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls)
Clean up after a client has disconnected.
Message sent by the client to the service to start listening for incoming requests to perform a certa...
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
static int check_union_p2p_full_element(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Check a full element message from a remote peer.
struct Set * set
Set, if associated with the client, otherwise NULL.
#define GNUNET_MESSAGE_TYPE_SETU_REQUEST
Notify the client of an incoming request from a remote peer.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct StrataEstimator * se
Copy of the set's strata estimator at the time of creation of this operation.
After sending the full set, wait for responses with the elements that the local peer is missing...
static 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.
struct GNUNET_MessageHeader * msg
State we keep per client.
static unsigned int phase
Processing stage that we are in.
static int prepare_ibf_iterator(void *cls, uint32_t key, void *value)
Insert a key into an ibf.
static void maybe_finish(struct Operation *op)
Tests if the operation is finished, and if so notify.
struct GNUNET_MessageHeader * context_msg
Context message, may be NULL.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static void send_full_set(struct Operation *op)
Switch to full set transmission for op.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
#define SE_IBF_HASH_NUM
The hash num parameter for the difference digests and strata estimators.
enum IntersectionOperationPhase phase
Current state of the operation.
static unsigned int element_size
int received
Did we receive this element? Even if element->is_foreign is false, we might have received the element...
uint8_t reserved1
Padding, must be 0.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint32_t suggest_id
Unique request id for the request from a remote peer, sent to the client, which will accept or reject...
struct Operation * op
Operation for which the elements should be sent.
uint32_t element_count
For Intersection: my element count.
GNUNET_SERVICE_MAIN("set", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_accept, GNUNET_MESSAGE_TYPE_SETU_ACCEPT, struct GNUNET_SETU_AcceptMessage, NULL), GNUNET_MQ_hd_var_size(client_set_add, GNUNET_MESSAGE_TYPE_SETU_ADD, struct GNUNET_SETU_ElementMessage, NULL), GNUNET_MQ_hd_fixed_size(client_create_set, GNUNET_MESSAGE_TYPE_SETU_CREATE, struct GNUNET_SETU_CreateMessage, NULL), GNUNET_MQ_hd_var_size(client_evaluate, GNUNET_MESSAGE_TYPE_SETU_EVALUATE, struct GNUNET_SETU_EvaluateMessage, NULL), GNUNET_MQ_hd_fixed_size(client_listen, GNUNET_MESSAGE_TYPE_SETU_LISTEN, struct GNUNET_SETU_ListenMessage, NULL), GNUNET_MQ_hd_fixed_size(client_reject, GNUNET_MESSAGE_TYPE_SETU_REJECT, struct GNUNET_SETU_RejectMessage, NULL), GNUNET_MQ_hd_fixed_size(client_cancel, GNUNET_MESSAGE_TYPE_SETU_CANCEL, struct GNUNET_SETU_CancelMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
Opaque handle to the service.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct...
int byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
struct GNUNET_HashCode app_id
Application id.
Element should be added to the result set of the remote peer, i.e.
struct GNUNET_MQ_Handle * mq
MQ to talk to client.
const void * data
Actual data of the element.
uint8_t symmetric
Also return set elements we are sending to the remote peer.
uint16_t reserved
For alignment, always zero.
uint32_t accept_reject_id
ID of the incoming request we want to reject.
static void send_client_element(struct Operation *op, const struct GNUNET_SETU_Element *element, enum GNUNET_SETU_Status status)
Send a result message to the client indicating that there is a new element.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
struct GNUNET_HashCode element_hash
Hash of the element.
unsigned int refcount
Number of references to the content.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
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.
Message containing buckets of an invertible bloom filter.
struct Listener * next
Listeners are held in a doubly linked list.
static void handle_union_p2p_full_element(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Handle an element message from a remote peer.
#define GNUNET_MQ_extract_nested_mh(var)
Return a pointer to the message at the end of the given message.
struct InvertibleBloomFilter * remote_ibf
The IBF we currently receive.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
The other peer is decoding the IBF we just sent.
static struct Listener * listener_tail
Listeners are held in a doubly linked list.
uint32_t request_id
ID of the request we want to cancel.
Invertible bloom filter (IBF).
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE(C)
struct Operation * op_head
Head of DLL of operations this listener is responsible for.
In the ultimate phase, we wait until our demands are satisfied and then quit (sending another DONE me...
UnionOperationPhase
Current phase we are in for a union operation.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_SE
Strata estimator.
static void handle_union_p2p_request_full(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a request for full set transmission.
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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
static int ret
Return value of the commandline.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
uint32_t accept_reject_id
ID of the incoming request we want to accept.
static int check_union_p2p_ibf(void *cls, const struct IBFMessage *msg)
Check an IBF message from a remote peer.
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.
static void unsalt_key(const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out)
FIXME.
struct GNUNET_CONTAINER_MultiHashMap * elements
Maps struct GNUNET_HashCode * to struct ElementEntry *.
static void handle_client_cancel(void *cls, const struct GNUNET_SETU_CancelMessage *msg)
Handle a request from the client to cancel a running set operation.
struct KeyEntry * k
FIXME.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER
Tell the other peer which hashes match a given IBF key.
uint64_t initial_size
Initial size of our set, just before the operation started.
Opaque handle to a channel.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static struct GNUNET_CADET_Handle * cadet
Handle to the cadet service, used to listen for and connect to remote peers.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_CONTAINER_multihashmap32_get_multiple(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
unsigned int ibf_buckets_received
Number of ibf buckets already received into the remote_ibf.
A listener is inhabited by a client, and waits for evaluation requests from remote peers...
#define GNUNET_MESSAGE_TYPE_SETU_P2P_DONE
Set operation is done.
uint32_t request_id
id the result belongs to
void ibf_write_slice(const struct InvertibleBloomFilter *ibf, uint32_t start, uint32_t count, void *buf)
Write buckets from an ibf to a buffer.
uint32_t salt_receive
Salt for the IBF we've received and that we're currently decoding.
int 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)...
static void handle_union_p2p_over(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a over message from a remote peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
uint32_t request_id
Request ID to identify responses.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
uint8_t byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
static void _GSS_operation_destroy2(struct Operation *op)
This function probably should not exist and be replaced by inlining more specific logic in the variou...
static unsigned int force_full
static void * channel_new_cb(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
Method called whenever another peer has added us to a channel the other peer initiated.
static int send_ibf(struct Operation *op, uint16_t ibf_order)
Send an ibf of appropriate size.
int 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.
uint16_t element_type
Type of the element attachted to the message, if any.
Message sent by the client to the service to ask starting a new set to perform operations with...
Internal representation of the hash map.
#define SE_IBF_SIZE
Size of the IBFs in the strata estimator.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define INCOMING_CHANNEL_TIMEOUT
How long do we hold on to an incoming channel if there is no local listener before giving up...
unsigned int generation_created
Generation in which the operation handle was created.
static unsigned int num_clients
Number of active clients.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task, if the incoming peer has not been accepted after the timeout, it will be disconnected...
static int send_full_element_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Send a set element.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static pa_context * context
Pulseaudio context.
const void * data
Actual data of the element.
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
The protocol is almost finished, but we still have to flush our message queue and/or expect some elem...
A handle to a strata estimator.
struct StrataEstimator * strata_estimator_dup(struct StrataEstimator *se)
Make a copy of a strata estimator.
static void handle_union_p2p_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a done message from a remote peer.
struct Operation * next
Kept in a DLL of the listener, if listener is non-NULL.
static void _GSS_operation_destroy(struct Operation *op)
Destroy the given operation.
uint8_t force_full
Always send full sets, even if delta operations would be more efficient.
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.
The key entry is used to associate an ibf key with an element.
Handle to a client that is connected to a service.
static void send_client_done(void *cls)
Signal to the client that the operation has finished and destroy the operation.
struct GNUNET_PeerIdentity peer
The identity of the requesting peer.
static struct IBF_Key get_ibf_key(const struct GNUNET_HashCode *src)
Derive the IBF key from a hash code and a salt.
uint8_t symmetric
GNUNET_YES to also send back set elements we are sending to the remote peer.
struct InvertibleBloomFilter * ibf_dup(const struct InvertibleBloomFilter *ibf)
Create a copy of an IBF, the copy has to be destroyed properly.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_SEC
Compressed strata estimator.
uint16_t element_type
Type of the element to add or remove.
uint32_t size
How many cells does this IBF have?
static void handle_union_p2p_ibf(void *cls, const struct IBFMessage *msg)
Handle an IBF message from a remote peer.
static 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).
Message sent by client to service to initiate a set operation as a client (not as listener)...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
static void fail_union_operation(struct Operation *op)
Inform the client that the union operation has failed, and proceed to destroy the evaluate operation...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
The other peer refused to do the operation with us, or something went wrong.
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.
static int check_client_evaluate(void *cls, const struct GNUNET_SETU_EvaluateMessage *msg)
Called when a client wants to initiate a set operation with another peer.
GNUNET_SETU_Status
Status for the result callback.
struct StrataEstimator * se
The strata estimator is only generated once for each set.
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incomming MQ-based channels.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL
Demand the whole element from the other peer, given only the hash code.
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
static int destroy_elements_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries to free element entries.
static char * value
Value of the record to add/remove.
#define MAX_BUCKETS_PER_MESSAGE
Number of buckets that can be transmitted in one message.
struct GNUNET_CONTAINER_MultiHashMap * demanded_hashes
Hashes for elements that we have demanded from the other peer.
Information about an element element in the set.
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
#define GNUNET_MESSAGE_TYPE_SETU_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETU_CREATE
Create a new local set.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
static void advance_generation(struct Set *set)
Advance the current generation of a set, adding exclusion ranges if necessary.
Success, all elements have been sent (and received).
static void handle_union_p2p_full_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle a "full done" message.
void strata_estimator_destroy(struct StrataEstimator *se)
Destroy a strata estimator, free all of its resources.
int remote
GNUNET_YES if the element is a remote element, and does not belong to the operation's set...
uint16_t element_type
Application-specific element type.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int ibf_decode(struct InvertibleBloomFilter *ibf, int *ret_side, struct IBF_Key *ret_id)
Decode and remove an element from the IBF, if possible.
uint8_t order
Order of the whole ibf, where num_buckets = 2^order.
struct IBF_Key ibf_key
IBF key for the entry, derived from the current salt.
Element should be added to the result set of the local peer, i.e.
We sent the strata estimator, and expect an IBF.
A set that supports a specific operation with other peers.
uint32_t accept_id
ID of the to identify the request when accepting or rejecting it.
#define IBF_BUCKET_SIZE
Size of one ibf bucket in bytes.
static void handle_client_accept(void *cls, const struct GNUNET_SETU_AcceptMessage *msg)
Handle a request from the client to accept a set operation that came from a remote peer...
struct ElementEntry * element
The actual element associated with the key.
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_CRYPTO_kdf(void *result, size_t out_len, const void *xts, size_t xts_len, const void *skm, size_t skm_len,...)
Derive key.
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
static void salt_key(const struct IBF_Key *k_in, uint32_t salt, struct IBF_Key *k_out)
Modify an IBF key k_in based on the salt, returning a salted key in k_out.
static void channel_window_cb(void *cls, const struct GNUNET_CADET_Channel *channel, int window_size)
Function called whenever an MQ-channel's transmission window size changes.
Continuation for multi part IBFs.
int 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.
struct Set * set
Set associated with the operation, NULL until the spec has been associated with a set...
In the penultimate phase, we wait until all our demands are satisfied.
uint32_t byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
void ibf_subtract(struct InvertibleBloomFilter *ibf1, const struct InvertibleBloomFilter *ibf2)
Subtract ibf2 from ibf1, storing the result in ibf1.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF.
unsigned int strata_count
Size of the IBF array in strata.
#define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE
Maximum size of a context message for set operation requests.
void strata_estimator_insert(struct StrataEstimator *se, struct IBF_Key key)
Add a key to the strata estimator.
size_t strata_estimator_write(const struct StrataEstimator *se, void *buf)
Write the given strata estimator to the buffer.
Internal representation of the hash map.
static struct Operation * get_incoming(uint32_t id)
Get the incoming socket associated with the given id.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE
Request all missing elements from the other peer, based on their sets and the elements we previously ...
uint16_t result_status
Was the evaluation successful? Contains an enum GNUNET_SETU_Status in NBO.
Message sent by a listening client to the service to accept performing the operation with the other p...
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
uint8_t force_delta
Always use delta operation instead of sending full sets, even it it's less efficient.
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...
void GNUNET_SETU_element_hash(const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
Message handler for a specific message type.
int symmetric
GNUNET_YES to also send back set elements we are sending to the remote peer.
uint8_t byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
struct GNUNET_CONTAINER_MultiHashMap32 * key_to_element
Maps unsalted IBF-Keys to elements.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static void handle_client_create_set(void *cls, const struct GNUNET_SETU_CreateMessage *msg)
Called when a client wants to create a new set.
int force_delta
Always use delta operation instead of sending full sets, even it it's less efficient.
static int op_get_element_iterator(void *cls, uint32_t key, void *value)
Iterator over the mapping from IBF keys to element entries.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
void ibf_read_slice(const void *buf, uint32_t start, uint32_t count, struct InvertibleBloomFilter *ibf)
Read buckets from a buffer into an ibf.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
static void handle_client_evaluate(void *cls, const struct GNUNET_SETU_EvaluateMessage *msg)
Called when a client wants to initiate a set operation with another peer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
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.
static unsigned int size
Size of the "table".
#define GNUNET_MESSAGE_TYPE_SETU_ADD
Add element to set.
struct GNUNET_CADET_Port * open_port
The port we are listening on with CADET.
uint64_t current_size
Current set size.
#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...
int byzantine
GNUNET_YES to fail operations where Byzantine faults are suspected
void ibf_destroy(struct InvertibleBloomFilter *ibf)
Destroy all resources associated with the invertible bloom filter.
struct ClientState * cs
Client that owns the set.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT
Send a set element, not as response to a demand but because we're sending the full set...
struct GNUNET_MQ_Envelope * env
static int decode_and_send(struct Operation *op)
Decode which elements are missing on each side, and send the appropriate offers and inquiries...
Strata estimator together with the peer's overall set size.
struct InvertibleBloomFilter * ibf_create(uint32_t size, uint8_t hash_num)
Create an invertible bloom filter.
#define IBF_ALPHA
Number of buckets used in the ibf per estimated difference.
static struct GNUNET_SCHEDULER_Task * timeout_task
Task to be run on timeout.
Message sent by client to the service to add an element to the set.
unsigned int strata_estimator_difference(const struct StrataEstimator *se1, const struct StrataEstimator *se2)
Estimate set difference with two strata estimators, i.e.
static int check_union_p2p_strata_estimator(void *cls, const struct StrataEstimatorMessage *msg)
Handle a strata estimator from a remote peer.
int client_done_sent
Did we send the client that we are done?
struct GNUNET_PeerIdentity target_peer
Peer to evaluate the operation with.
Operation context used to execute a set operation.
int 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.
static int send_offers_iterator(void *cls, uint32_t key, void *value)
Iterator to send elements to a remote peer.
A request for an operation with another client.
SetContent stores the actual set elements, which may be shared by multiple generations derived from o...
static void handle_union_p2p_strata_estimator(void *cls, const struct StrataEstimatorMessage *msg)
Handle a strata estimator from a remote peer.
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 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).
static void incoming_timeout_cb(void *cls)
Timeout happens iff:
static void incoming_destroy(struct Operation *op)
Destroy an incoming request from a remote peer.
static uint32_t suggest_id
Counter for allocating unique IDs for clients, used to identify incoming operation requests from remo...
uint16_t reserved2
Padding, must be 0.
uint32_t request_id
Id of our set to evaluate, chosen implicitly by the client when it calls GNUNET_SETU_commit().
static int check_client_set_add(void *cls, const struct GNUNET_SETU_ElementMessage *msg)
Called when a client wants to add or remove an element to a set it inhabits.
Allow multiple values with the same key.
unsigned int generation
First generation that includes this element.
Handle to a message queue.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF.
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
void ibf_insert(struct InvertibleBloomFilter *ibf, struct IBF_Key key)
Insert a key into an IBF.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
The identity of the host (wraps the signing key of the peer).
static struct GNUNET_STATISTICS_Handle * _GSS_statistics
Statistics handle.
static void initialize_key_to_element(struct Operation *op)
Initialize the IBF key to element mapping local to this set operation.
struct GNUNET_PeerIdentity peer_id
Identity of the requesting peer.
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
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...
uint8_t force_full
Always send full sets, even if delta operations would be more efficient.
struct GNUNET_CADET_Channel * GNUNET_CADET_channel_create(struct GNUNET_CADET_Handle *h, void *channel_cls, const struct GNUNET_PeerIdentity *destination, const struct GNUNET_HashCode *port, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Create a new channel towards a remote peer.
struct GNUNET_CADET_Channel * channel
Channel to the peer.
uint32_t salt
Salt used when hashing elements for this IBF.
struct Operation * ops_head
Evaluate operations are held in a linked list.
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
uint32_t salt
Salt to use for the operation.
struct GNUNET_SERVICE_Client * client
Client this is about.
uint32_t client_request_id
ID used to identify an operation between service and client.
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.
struct InvertibleBloomFilter * local_ibf
The IBF with the local set's element.
struct SetContent * content
Content, possibly shared by multiple sets, and thus reference counted.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_IBF
Invertible bloom filter.
Sent to the service by the client in order to cancel a set operation.
static int in_shutdown
Are we in shutdown? if GNUNET_YES and the number of clients drops to zero, disconnect from CADET...
uint16_t size
Number of bytes in the buffer pointed to by data.
struct GNUNET_MQ_Handle * mq
static void handle_client_reject(void *cls, const struct GNUNET_SETU_RejectMessage *msg)
Called when the listening client rejects an operation request by another peer.
#define GNUNET_log(kind,...)
static int check_union_p2p_offer(void *cls, const struct GNUNET_MessageHeader *mh)
Check offer (of struct GNUNET_HashCodes).
Entry in list of pending tasks.
static void handle_client_listen(void *cls, const struct GNUNET_SETU_ListenMessage *msg)
Called when a client wants to create a new listener.
#define MAX_IBF_ORDER
The maximum size of an ibf we use is 2^(MAX_IBF_ORDER).
#define SE_STRATA_COUNT
Number of IBFs in a strata estimator.
static struct Listener * listener_head
Listeners are held in a doubly linked list.
struct GNUNET_SET_Element element
The actual element.
Phase that receives full set first and then sends elements that are the local peer missing...
struct Listener * prev
Listeners are held in a doubly linked list.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static int check_incoming_msg(void *cls, const struct OperationRequestMessage *msg)
Check a request for a set operation from another peer.
#define GNUNET_MESSAGE_TYPE_SETU_LISTEN
Listen for operation requests.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_HashCode app_id
Application ID for the operation, used to distinguish multiple operations of the same type with the s...
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
static void shutdown_task(void *cls)
Called to clean up, after a shutdown has been requested.
static void handle_union_p2p_elements(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Handle an element message from a remote peer.
uint8_t force_delta
Always use delta operation instead of sending full sets, even it it's less efficient.
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.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND
Demand the whole element from the other peer, given only the hash code.
#define GNUNET_MESSAGE_TYPE_SETU_REJECT
Reject a set request.
static int prepare_ibf(struct Operation *op, uint32_t size)
Create an ibf with the operation's elements of the specified size.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SETU_ADD.
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
struct ClientState * cs
Client that owns the listener.
struct Listener * listener
Listener, if associated with the client, otherwise NULL.
uint32_t remote_element_count
Remote peers element count.
struct Operation * op_tail
Tail of DLL of operations this listener is responsible for.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq)
Callback called when a client connects to the service.
static struct GNUNET_ARM_Operation * op
Current operation.
static void channel_end_cb(void *channel_ctx, const struct GNUNET_CADET_Channel *channel)
Function called whenever a channel is destroyed.
Keys that can be inserted into and removed from an IBF.
uint32_t salt
Salt used when hashing elements for this inquiry.
uint32_t byzantine_lower_bound
Lower bound for the set size, used only when byzantine mode is enabled.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
struct Set * next
Sets are held in a doubly linked list (in sets_head and sets_tail).
#define GNUNET_MESSAGE_TYPE_SETU_P2P_OVER
Request all missing elements from the other peer, based on their sets and the elements we previously ...
uint32_t salt_send
Salt that we're using for sending IBFs.
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Function called by the service's run method to run service-specific setup code.
We sent the request message, and expect a strata estimator.
struct Listener * listener
Port this operation runs on.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
uint16_t size
Number of bytes in the buffer pointed to by data.
struct GNUNET_MQ_Handle * mq
Message queue for the channel.
static int check_union_p2p_elements(void *cls, const struct GNUNET_SETU_ElementMessage *emsg)
Check an element message from a remote peer.
static 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.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Used as a closure for sending elements with a specific IBF key.
struct GNUNET_HashCode hash
FIXME.
Message sent by a listening client to the service to reject performing the operation with the other p...
struct IBF_Key ibf_key
The IBF key whose matching elements should be sent.
static 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).
#define GNUNET_malloc(size)
Wrapper around malloc.
static int _GSS_is_element_of_operation(struct ElementEntry *ee, struct Operation *op)
Is element ee part of the set used by op?
#define GNUNET_MESSAGE_TYPE_SETU_P2P_INQUIRY
Tell the other peer to send us a list of hashes that match an IBF key.
uint32_t received_total
Total number of elements received from the other peer.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
static unsigned int force_delta
#define GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS
Actual set elements.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t element_type
Application-specific element type.
static void handle_incoming_msg(void *cls, const struct OperationRequestMessage *msg)
Handle a request for a set operation from another peer.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
struct GNUNET_MQ_Handle * GNUNET_CADET_get_mq(const struct GNUNET_CADET_Channel *channel)
Obtain the message queue for a connected peer.
int force_full
Always send full sets, even if delta operations would be more efficient.
struct GNUNET_HashCode app_id
application id
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
static void handle_client_set_add(void *cls, const struct GNUNET_SETU_ElementMessage *msg)
Called when a client wants to add or remove an element to a set it inhabits.
unsigned int ibf_size
Size of each IBF stratum (in bytes)