![]() |
GNUnet
0.11.x
|
#include "gnunet-service-seti_protocol.h"
#include "gnunet_statistics_service.h"
#include "gnunet_cadet_service.h"
#include "gnunet_seti_service.h"
#include "gnunet_block_lib.h"
#include "seti.h"
Go to the source code of this file.
Data Structures | |
struct | ElementEntry |
Information about an element element in the set. More... | |
struct | ClientState |
State we keep per client. More... | |
struct | Operation |
Operation context used to execute a set operation. More... | |
struct | SetContent |
SetContent stores the actual set elements, which may be shared by multiple generations derived from one set. More... | |
struct | Set |
A set that supports a specific operation with other peers. More... | |
struct | Listener |
A listener is inhabited by a client, and waits for evaluation requests from remote peers. More... | |
Macros | |
#define | INCOMING_CHANNEL_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we hold on to an incoming channel if there is no local listener before giving up? More... | |
Enumerations | |
enum | IntersectionOperationPhase { PHASE_INITIAL, PHASE_COUNT_SENT, PHASE_BF_EXCHANGE, PHASE_MUST_SEND_DONE, PHASE_DONE_RECEIVED, PHASE_FINISHED, PHASE_INITIAL, PHASE_COUNT_SENT, PHASE_BF_EXCHANGE, PHASE_MUST_SEND_DONE, PHASE_DONE_RECEIVED, PHASE_FINISHED } |
Current phase we are in for a intersection operation. More... | |
Functions | |
static void | send_client_removed_element (struct Operation *op, struct GNUNET_SETI_Element *element) |
If applicable in the current operation mode, send a result message to the client indicating we removed an element. More... | |
static int | _GSS_is_element_of_operation (struct ElementEntry *ee, struct Operation *op) |
Is element ee part of the set used by op? More... | |
static int | filtered_map_initialization (void *cls, const struct GNUNET_HashCode *key, void *value) |
Fills the "my_elements" hashmap with all relevant elements. More... | |
static int | iterator_bf_reduce (void *cls, const struct GNUNET_HashCode *key, void *value) |
Removes elements from our hashmap if they are not contained within the provided remote bloomfilter. More... | |
static int | iterator_bf_create (void *cls, const struct GNUNET_HashCode *key, void *value) |
Create initial bloomfilter based on all the elements given. More... | |
static void | _GSS_operation_destroy (struct Operation *op) |
Destroy the given operation. More... | |
static void | _GSS_operation_destroy2 (struct Operation *op) |
This function probably should not exist and be replaced by inlining more specific logic in the various places where it is called. More... | |
static void | incoming_destroy (struct Operation *op) |
Destroy an incoming request from a remote peer. More... | |
static void | send_client_done_and_destroy (void *cls) |
Signal to the client that the operation has finished and destroy the operation. More... | |
static void | fail_intersection_operation (struct Operation *op) |
Inform the client that the intersection operation has failed, and proceed to destroy the evaluate operation. More... | |
static void | send_bloomfilter (struct Operation *op) |
Send a bloomfilter to our peer. More... | |
static void | finished_local_operations (void *cls) |
Remember that we are done dealing with the local client AND have sent the other peer our message that we are done, so we are not just waiting for the channel to die before telling the local client that we are done as our last act. More... | |
static void | send_p2p_done (struct Operation *op) |
Notify the other peer that we are done. More... | |
static void | send_remaining_elements (void *cls) |
Send all elements in the full result iterator. More... | |
static int | initialize_map_unfiltered (void *cls, const struct GNUNET_HashCode *key, void *value) |
Fills the "my_elements" hashmap with the initial set of (non-deleted) elements from the set of the specification. More... | |
static void | send_element_count (struct Operation *op) |
Send our element count to the peer, in case our element count is lower than theirs. More... | |
static void | begin_bf_exchange (struct Operation *op) |
We go first, initialize our map with all elements and send the first Bloom filter. More... | |
static void | handle_intersection_p2p_element_info (void *cls, const struct IntersectionElementInfoMessage *msg) |
Handle the initial struct IntersectionElementInfoMessage from a remote peer. More... | |
static void | process_bf (struct Operation *op) |
Process a Bloomfilter once we got all the chunks. More... | |
static int | check_intersection_p2p_bf (void *cls, const struct BFMessage *msg) |
Check an BF message from a remote peer. More... | |
static void | handle_intersection_p2p_bf (void *cls, const struct BFMessage *msg) |
Handle an BF message from a remote peer. More... | |
static int | filter_all (void *cls, const struct GNUNET_HashCode *key, void *value) |
Remove all elements from our hashmap. More... | |
static void | handle_intersection_p2p_done (void *cls, const struct IntersectionDoneMessage *idm) |
Handle a done message from a remote peer. More... | |
static struct Operation * | get_incoming (uint32_t id) |
Get the incoming socket associated with the given id. More... | |
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. More... | |
static int | destroy_elements_iterator (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over hash map entries to free element entries. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls) |
Clean up after a client has disconnected. More... | |
static int | check_incoming_msg (void *cls, const struct OperationRequestMessage *msg) |
Check a request for a set operation from another peer. More... | |
static void | handle_incoming_msg (void *cls, const struct OperationRequestMessage *msg) |
Handle a request for a set operation from another peer. More... | |
static void | handle_client_create_set (void *cls, const struct GNUNET_SETI_CreateMessage *msg) |
Called when a client wants to create a new set. More... | |
static void | incoming_timeout_cb (void *cls) |
Timeout happens iff: More... | |
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. More... | |
static void | channel_end_cb (void *channel_ctx, const struct GNUNET_CADET_Channel *channel) |
Function called whenever a channel is destroyed. More... | |
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. More... | |
static void | handle_client_listen (void *cls, const struct GNUNET_SETI_ListenMessage *msg) |
Called when a client wants to create a new listener. More... | |
static void | handle_client_reject (void *cls, const struct GNUNET_SETI_RejectMessage *msg) |
Called when the listening client rejects an operation request by another peer. More... | |
static int | check_client_set_add (void *cls, const struct GNUNET_SETI_ElementMessage *msg) |
Called when a client wants to add or remove an element to a set it inhabits. More... | |
static void | handle_client_set_add (void *cls, const struct GNUNET_SETI_ElementMessage *msg) |
Called when a client wants to add an element to a set it inhabits. More... | |
static void | advance_generation (struct Set *set) |
Advance the current generation of a set, adding exclusion ranges if necessary. More... | |
static int | check_client_evaluate (void *cls, const struct GNUNET_SETI_EvaluateMessage *msg) |
Called when a client wants to initiate a set operation with another peer. More... | |
static void | handle_client_evaluate (void *cls, const struct GNUNET_SETI_EvaluateMessage *msg) |
Called when a client wants to initiate a set operation with another peer. More... | |
static void | handle_client_cancel (void *cls, const struct GNUNET_SETI_CancelMessage *msg) |
Handle a request from the client to cancel a running set operation. More... | |
static void | handle_client_accept (void *cls, const struct GNUNET_SETI_AcceptMessage *msg) |
Handle a request from the client to accept a set operation that came from a remote peer. More... | |
static void | shutdown_task (void *cls) |
Called to clean up, after a shutdown has been requested. More... | |
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. More... | |
GNUNET_SERVICE_MAIN ("seti", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_accept, GNUNET_MESSAGE_TYPE_SETI_ACCEPT, struct GNUNET_SETI_AcceptMessage, NULL), GNUNET_MQ_hd_var_size(client_set_add, GNUNET_MESSAGE_TYPE_SETI_ADD, struct GNUNET_SETI_ElementMessage, NULL), GNUNET_MQ_hd_fixed_size(client_create_set, GNUNET_MESSAGE_TYPE_SETI_CREATE, struct GNUNET_SETI_CreateMessage, NULL), GNUNET_MQ_hd_var_size(client_evaluate, GNUNET_MESSAGE_TYPE_SETI_EVALUATE, struct GNUNET_SETI_EvaluateMessage, NULL), GNUNET_MQ_hd_fixed_size(client_listen, GNUNET_MESSAGE_TYPE_SETI_LISTEN, struct GNUNET_SETI_ListenMessage, NULL), GNUNET_MQ_hd_fixed_size(client_reject, GNUNET_MESSAGE_TYPE_SETI_REJECT, struct GNUNET_SETI_RejectMessage, NULL), GNUNET_MQ_hd_fixed_size(client_cancel, GNUNET_MESSAGE_TYPE_SETI_CANCEL, struct GNUNET_SETI_CancelMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static struct GNUNET_CADET_Handle * | cadet |
Handle to the cadet service, used to listen for and connect to remote peers. More... | |
static struct GNUNET_STATISTICS_Handle * | _GSS_statistics |
Statistics handle. More... | |
static struct Listener * | listener_head |
Listeners are held in a doubly linked list. More... | |
static struct Listener * | listener_tail |
Listeners are held in a doubly linked list. More... | |
static unsigned int | num_clients |
Number of active clients. More... | |
static int | in_shutdown |
Are we in shutdown? if GNUNET_YES and the number of clients drops to zero, disconnect from CADET. More... | |
static uint32_t | suggest_id |
Counter for allocating unique IDs for clients, used to identify incoming operation requests from remote peers, that the client can choose to accept or refuse. More... | |
#define INCOMING_CHANNEL_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we hold on to an incoming channel if there is no local listener before giving up?
Definition at line 37 of file gnunet-service-seti.c.
Referenced by channel_new_cb().
Current phase we are in for a intersection operation.
Definition at line 43 of file gnunet-service-seti.c.
|
static |
If applicable in the current operation mode, send a result message to the client indicating we removed an element.
op | intersection operation |
element | element to send |
Definition at line 516 of file gnunet-service-seti.c.
References Operation::client_request_id, Set::cs, GNUNET_SETI_Element::data, GNUNET_SETI_Element::element_type, GNUNET_SETI_ResultMessage::element_type, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SETI_STATUS_DEL_LOCAL, GNUNET_STATISTICS_update(), GNUNET_YES, ClientState::mq, GNUNET_SETI_ResultMessage::request_id, GNUNET_SETI_ResultMessage::result_status, Operation::return_intersection, Operation::set, and GNUNET_SETI_Element::size.
Referenced by filter_all(), filtered_map_initialization(), and iterator_bf_reduce().
|
static |
Is element ee part of the set used by op?
ee | element to test |
op | operation the defines the set and its generation |
Definition at line 562 of file gnunet-service-seti.c.
References ElementEntry::generation_added, and Operation::generation_created.
Referenced by filtered_map_initialization(), and initialize_map_unfiltered().
|
static |
Fills the "my_elements" hashmap with all relevant elements.
cls | the struct Operation * we are performing |
key | current key code |
value | the struct ElementEntry * from the hash map |
Definition at line 578 of file gnunet-service-seti.c.
References _GSS_is_element_of_operation(), ElementEntry::element, ElementEntry::element_hash, GNUNET_BLOCK_mingle_hash(), GNUNET_break, GNUNET_CONTAINER_bloomfilter_test(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash_xor(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, Operation::my_element_count, Operation::my_elements, Operation::my_xor, op, Operation::remote_bf, Operation::salt, send_client_removed_element(), GNUNET_SET_Element::size, and value.
Referenced by process_bf().
|
static |
Removes elements from our hashmap if they are not contained within the provided remote bloomfilter.
cls | closure with the struct Operation * |
key | current key code |
value | value in the hash map |
Definition at line 649 of file gnunet-service-seti.c.
References ElementEntry::element, ElementEntry::element_hash, GNUNET_assert, GNUNET_BLOCK_mingle_hash(), GNUNET_break, GNUNET_CONTAINER_bloomfilter_test(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash_xor(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, Operation::my_element_count, Operation::my_elements, Operation::my_xor, op, Operation::remote_bf, Operation::salt, send_client_removed_element(), GNUNET_SET_Element::size, and value.
Referenced by process_bf().
|
static |
Create initial bloomfilter based on all the elements given.
cls | the struct Operation * |
key | current key code |
value | the struct ElementEntry to process |
Definition at line 704 of file gnunet-service-seti.c.
References ElementEntry::element_hash, GNUNET_BLOCK_mingle_hash(), GNUNET_CONTAINER_bloomfilter_add(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_YES, Operation::local_bf, op, Operation::salt, and value.
Referenced by send_bloomfilter().
|
static |
Destroy the given operation.
Used for any operation where both peers were known and that thus actually had a vt and channel. Must not be used for operations where 'listener' is still set and we do not know the other peer.
Call the implementation-specific cancel function of the operation. Disconnects from the remote peer. Does not disconnect the client, as there may be multiple operations per set.
op | operation to destroy |
Definition at line 738 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), Operation::channel, Operation::context_msg, Operation::full_result_iter, GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterator_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, Operation::listener, Operation::local_bf, Operation::my_elements, op, Operation::remote_bf, and Operation::set.
Referenced by _GSS_operation_destroy2(), client_disconnect_cb(), fail_intersection_operation(), handle_client_cancel(), and send_client_done_and_destroy().
|
static |
This function probably should not exist and be replaced by inlining more specific logic in the various places where it is called.
Definition at line 866 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), Operation::channel, Operation::channel_death_expected, GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, incoming_destroy(), Operation::listener, send_client_done_and_destroy(), and Operation::set.
Referenced by _GSS_operation_destroy(), channel_end_cb(), handle_client_reject(), and incoming_destroy().
|
static |
Destroy an incoming request from a remote peer.
op | remote request to destroy |
Definition at line 807 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_cancel(), Operation::listener, Listener::op_head, Listener::op_tail, and Operation::timeout_task.
Referenced by _GSS_operation_destroy2(), client_disconnect_cb(), and incoming_timeout_cb().
|
static |
Signal to the client that the operation has finished and destroy the operation.
cls | operation to destroy |
Definition at line 837 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), Operation::client_request_id, Set::cs, GNUNET_SETI_ResultMessage::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SETI_STATUS_DONE, GNUNET_STATISTICS_update(), ClientState::mq, GNUNET_SETI_ResultMessage::request_id, GNUNET_SETI_ResultMessage::result_status, and Operation::set.
Referenced by _GSS_operation_destroy2(), handle_intersection_p2p_done(), and send_remaining_elements().
|
static |
Inform the client that the intersection operation has failed, and proceed to destroy the evaluate operation.
op | the intersection operation to fail |
Definition at line 910 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), Operation::client_request_id, Set::cs, GNUNET_SETI_ResultMessage::element_type, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SETI_STATUS_FAILURE, GNUNET_STATISTICS_update(), ClientState::mq, msg, Operation::my_elements, GNUNET_SETI_ResultMessage::request_id, GNUNET_SETI_ResultMessage::result_status, and Operation::set.
Referenced by handle_intersection_p2p_bf(), handle_intersection_p2p_done(), handle_intersection_p2p_element_info(), and process_bf().
|
static |
Send a bloomfilter to our peer.
After the result done message has been sent to the client, destroy the evaluate operation.
op | intersection operation |
Definition at line 944 of file gnunet-service-seti.c.
References BFMessage::bits_per_element, BFMessage::bloomfilter_total_length, BFMessage::element_xor_hash, GNUNET_assert, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_bloomfilter_get_raw_data(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETI_P2P_BF, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, iterator_bf_create(), Operation::local_bf, Operation::mq, msg, Operation::my_element_count, Operation::my_elements, Operation::my_xor, Operation::remote_element_count, Operation::salt, BFMessage::sender_element_count, and BFMessage::sender_mutator.
Referenced by begin_bf_exchange(), and process_bf().
|
static |
Remember that we are done dealing with the local client AND have sent the other peer our message that we are done, so we are not just waiting for the channel to die before telling the local client that we are done as our last act.
cls | the struct Operation . |
Definition at line 1048 of file gnunet-service-seti.c.
References Operation::channel_death_expected, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, Operation::phase, and PHASE_FINISHED.
Referenced by send_p2p_done().
|
static |
Notify the other peer that we are done.
Once this message is out, we still need to notify the local client that we are done.
op | operation to notify for. |
Definition at line 1067 of file gnunet-service-seti.c.
References Operation::channel_death_expected, IntersectionDoneMessage::element_xor_hash, IntersectionDoneMessage::final_element_count, finished_local_operations(), GNUNET_assert, GNUNET_MESSAGE_TYPE_SETI_P2P_DONE, GNUNET_MQ_msg, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, Operation::mq, Operation::my_element_count, Operation::my_xor, Operation::phase, and PHASE_MUST_SEND_DONE.
Referenced by process_bf(), and send_remaining_elements().
|
static |
Send all elements in the full result iterator.
cls | the struct Operation * |
Definition at line 1092 of file gnunet-service-seti.c.
References Operation::client_request_id, Set::cs, GNUNET_SETI_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SETI_Element::element_type, GNUNET_SETI_ResultMessage::element_type, Operation::full_result_iter, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_iterator_destroy(), GNUNET_CONTAINER_multihashmap_iterator_next(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_SETI_STATUS_ADD_LOCAL, ClientState::mq, Operation::phase, PHASE_DONE_RECEIVED, PHASE_FINISHED, PHASE_MUST_SEND_DONE, GNUNET_SETI_ResultMessage::request_id, res, GNUNET_SETI_ResultMessage::result_status, Operation::return_intersection, send_client_done_and_destroy(), send_p2p_done(), Operation::set, and GNUNET_SETI_Element::size.
Referenced by handle_intersection_p2p_done(), and process_bf().
|
static |
Fills the "my_elements" hashmap with the initial set of (non-deleted) elements from the set of the specification.
cls | closure with the struct Operation * |
key | current key code for the element |
value | value in the hash map with the struct ElementEntry * |
Definition at line 1168 of file gnunet-service-seti.c.
References _GSS_is_element_of_operation(), ElementEntry::element, ElementEntry::element_hash, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash_xor(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, Operation::my_elements, Operation::my_xor, GNUNET_SET_Element::size, and value.
Referenced by begin_bf_exchange().
|
static |
Send our element count to the peer, in case our element count is lower than theirs.
op | intersection operation |
Definition at line 1200 of file gnunet-service-seti.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_P2P_ELEMENT_INFO, GNUNET_MQ_msg, GNUNET_MQ_send(), Operation::mq, msg, Operation::my_element_count, and IntersectionElementInfoMessage::sender_element_count.
Referenced by handle_client_accept().
|
static |
We go first, initialize our map with all elements and send the first Bloom filter.
op | operation to start exchange for |
Definition at line 1222 of file gnunet-service-seti.c.
References Set::content, SetContent::elements, GNUNET_CONTAINER_multihashmap_iterate(), initialize_map_unfiltered(), Operation::phase, PHASE_BF_EXCHANGE, send_bloomfilter(), and Operation::set.
Referenced by handle_client_accept(), and handle_intersection_p2p_element_info().
|
static |
Handle the initial struct IntersectionElementInfoMessage
from a remote peer.
cls | the intersection operation |
mh | the header of the message |
Definition at line 1240 of file gnunet-service-seti.c.
References begin_bf_exchange(), Operation::channel, fail_intersection_operation(), GNUNET_break, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, Operation::my_element_count, Operation::phase, PHASE_COUNT_SENT, PHASE_INITIAL, Operation::remote_bf, Operation::remote_element_count, and IntersectionElementInfoMessage::sender_element_count.
|
static |
Process a Bloomfilter once we got all the chunks.
op | the intersection operation |
Definition at line 1273 of file gnunet-service-seti.c.
References Set::content, SetContent::elements, fail_intersection_operation(), filtered_map_initialization(), Operation::full_result_iter, GNUNET_break_op, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_iterator_create(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcmp, GNUNET_YES, iterator_bf_reduce(), Operation::local_bf, Operation::my_element_count, Operation::my_elements, Operation::my_xor, Operation::other_xor, Operation::phase, PHASE_BF_EXCHANGE, PHASE_COUNT_SENT, PHASE_DONE_RECEIVED, PHASE_FINISHED, PHASE_INITIAL, PHASE_MUST_SEND_DONE, Operation::remote_bf, Operation::remote_element_count, Operation::return_intersection, send_bloomfilter(), send_p2p_done(), send_remaining_elements(), and Operation::set.
Referenced by handle_intersection_p2p_bf().
|
static |
Check an BF message from a remote peer.
cls | the intersection operation |
msg | the header of the message |
Definition at line 1355 of file gnunet-service-seti.c.
References GNUNET_OK.
|
static |
Handle an BF message from a remote peer.
cls | the intersection operation |
msg | the header of the message |
Definition at line 1372 of file gnunet-service-seti.c.
References Operation::bf_bits_per_element, Operation::bf_data, Operation::bf_data_offset, Operation::bf_data_size, BFMessage::bits_per_element, BFMessage::bloomfilter_total_length, Operation::channel, BFMessage::element_xor_hash, fail_intersection_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, BFMessage::header, Operation::other_xor, Operation::phase, PHASE_BF_EXCHANGE, PHASE_COUNT_SENT, PHASE_INITIAL, process_bf(), Operation::remote_bf, Operation::remote_element_count, Operation::salt, BFMessage::sender_element_count, BFMessage::sender_mutator, and GNUNET_MessageHeader::size.
|
static |
Remove all elements from our hashmap.
cls | closure with the struct Operation * |
key | current key code |
value | value in the hash map |
Definition at line 1472 of file gnunet-service-seti.c.
References ElementEntry::element, ElementEntry::element_hash, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash_xor(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_YES, Operation::my_element_count, Operation::my_elements, Operation::my_xor, send_client_removed_element(), GNUNET_SET_Element::size, and value.
Referenced by handle_intersection_p2p_done().
|
static |
Handle a done message from a remote peer.
cls | the intersection operation |
mh | the message |
Definition at line 1505 of file gnunet-service-seti.c.
References Operation::channel, Operation::client_done_sent, IntersectionDoneMessage::element_xor_hash, fail_intersection_operation(), filter_all(), IntersectionDoneMessage::final_element_count, Operation::full_result_iter, GNUNET_assert, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_iterator_create(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_YES, Operation::my_element_count, Operation::my_elements, Operation::my_xor, Operation::phase, PHASE_BF_EXCHANGE, PHASE_DONE_RECEIVED, PHASE_FINISHED, Operation::return_intersection, send_client_done_and_destroy(), and send_remaining_elements().
|
static |
Get the incoming socket associated with the given id.
listener | the listener to look in |
id | id to look for |
Definition at line 1566 of file gnunet-service-seti.c.
References Operation::listener, Listener::next, Operation::next, op, Listener::op_head, and Operation::suggest_id.
Referenced by handle_client_accept(), and handle_client_reject().
|
static |
Callback called when a client connects to the service.
cls | closure for the service |
c | the new client that connected to the service |
mq | the message queue used to send messages to the client |
struct
ClientState Definition at line 1588 of file gnunet-service-seti.c.
References ClientState::client, GNUNET_new, mq, ClientState::mq, and num_clients.
Referenced by run().
|
static |
Iterator over hash map entries to free element entries.
cls | closure |
key | current key code |
value | a struct ElementEntry * to be free'd |
Definition at line 1611 of file gnunet-service-seti.c.
References GNUNET_free, GNUNET_YES, and value.
Referenced by client_disconnect_cb().
|
static |
Clean up after a client has disconnected.
cls | closure, unused |
client | the client to clean up after |
internal_cls | the struct ClientState |
Definition at line 1630 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), Operation::client_request_id, destroy_elements_iterator(), SetContent::elements, GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CADET_disconnect(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_YES, in_shutdown, incoming_destroy(), ClientState::listener, num_clients, op, Listener::op_head, Listener::open_port, Operation::peer, SetContent::refcount, and ClientState::set.
Referenced by run().
|
static |
Check a request for a set operation from another peer.
cls | the operation state |
msg | the received message |
Definition at line 1704 of file gnunet-service-seti.c.
References GNUNET_break, GNUNET_break_op, GNUNET_MQ_extract_nested_mh, GNUNET_OK, GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE, GNUNET_SYSERR, Operation::listener, GNUNET_MessageHeader::size, and Operation::suggest_id.
|
static |
Handle a request for a set operation from another peer.
Checks if we have a listener waiting for such a request (and in that case initiates asking the listener about accepting the connection). If no listener is waiting, we queue the operation request in hope that a listener shows up soon (before timeout).
This msg is expected as the first and only msg handled through the non-operation bound virtual table, acceptance of this operation replaces our virtual table and subsequent msgs would be routed differently (as we then know what type of operation this is).
cls | the operation state |
msg | the received message |
Definition at line 1752 of file gnunet-service-seti.c.
References GNUNET_SETI_RequestMessage::accept_id, Listener::app_id, Operation::context_msg, Listener::cs, OperationRequestMessage::element_count, env, GNUNET_assert, GNUNET_copy_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_REQUEST, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_msg_nested_mh, GNUNET_MQ_send(), GNUNET_SCHEDULER_cancel(), Operation::listener, ClientState::mq, Operation::peer, GNUNET_SETI_RequestMessage::peer_id, Operation::remote_element_count, Operation::suggest_id, suggest_id, and Operation::timeout_task.
|
static |
Called when a client wants to create a new set.
This is typically the first request from a client, and includes the type of set operation to be performed.
cls | client that sent the message |
m | message sent by the client |
Definition at line 1805 of file gnunet-service-seti.c.
References ClientState::client, Set::cs, GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, and ClientState::set.
|
static |
Timeout happens iff:
cls | channel context |
tc | context information (why was this task triggered now) |
Definition at line 1841 of file gnunet-service-seti.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, incoming_destroy(), and Operation::timeout_task.
Referenced by channel_new_cb().
|
static |
Method called whenever another peer has added us to a channel the other peer initiated.
Only called (once) upon reception of data from a channel we listen on.
The channel context represents the operation itself and gets added to a DLL, from where it gets looked up when our local listener client responds to a proposed/suggested operation or connects and associates with this operation.
cls | closure |
channel | new handle to the channel |
source | peer that started the channel |
Definition at line 1869 of file gnunet-service-seti.c.
References Operation::channel, GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), INCOMING_CHANNEL_TIMEOUT, incoming_timeout_cb(), Operation::listener, Operation::mq, op, Listener::op_head, Listener::op_tail, Operation::peer, Operation::salt, source, and Operation::timeout_task.
Referenced by handle_client_listen().
|
static |
Function called whenever a channel is destroyed.
Should clean up any associated state. It must NOT call GNUNET_CADET_channel_destroy() on the channel.
The peer_disconnect function is part of a a virtual table set initially either when a peer creates a new channel with us, or once we create a new channel ourselves (evaluate).
Once we know the exact type of operation (union/intersection), the vt is replaced with an operation specific instance (GSS[op]_vt).
channel_ctx | place where local state associated with the channel is stored |
channel | connection to the other end (henceforth invalid) |
Definition at line 1912 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), and Operation::channel.
Referenced by handle_client_evaluate(), and handle_client_listen().
|
static |
Function called whenever an MQ-channel's transmission window size changes.
The first callback in an outgoing channel will be with a non-zero value and will mean the channel is connected to the destination.
For an incoming channel it will be called immediately after the GNUNET_CADET_ConnectEventHandler, also with a non-zero value.
cls | Channel closure. |
channel | Connection to the other end (henceforth invalid). |
window_size | New window size. If the is more messages than buffer size this value will be negative.. |
Definition at line 1937 of file gnunet-service-seti.c.
Referenced by handle_client_evaluate(), and handle_client_listen().
|
static |
Called when a client wants to create a new listener.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1952 of file gnunet-service-seti.c.
References GNUNET_SETI_ListenMessage::app_id, Listener::app_id, channel_end_cb(), channel_new_cb(), channel_window_cb(), ClientState::client, Listener::cs, GNUNET_break, GNUNET_CADET_open_port(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_P2P_BF, GNUNET_MESSAGE_TYPE_SETI_P2P_DONE, GNUNET_MESSAGE_TYPE_SETI_P2P_ELEMENT_INFO, GNUNET_MESSAGE_TYPE_SETI_P2P_OPERATION_REQUEST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), ClientState::listener, and Listener::open_port.
|
static |
Called when the listening client rejects an operation request by another peer.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 2013 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), GNUNET_SETI_RejectMessage::accept_reject_id, Listener::app_id, ClientState::client, get_incoming(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), ClientState::listener, and op.
|
static |
Called when a client wants to add or remove an element to a set it inhabits.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 2045 of file gnunet-service-seti.c.
References GNUNET_OK.
|
static |
Called when a client wants to add an element to a set it inhabits.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 2061 of file gnunet-service-seti.c.
References ClientState::client, GNUNET_SETI_Element::data, GNUNET_SET_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SETI_Element::element_type, GNUNET_SET_Element::element_type, GNUNET_SETI_ElementMessage::element_type, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SETI_element_hash(), GNUNET_YES, GNUNET_SETI_ElementMessage::header, ElementEntry::remote, ClientState::set, GNUNET_SETI_Element::size, GNUNET_SET_Element::size, and GNUNET_MessageHeader::size.
|
static |
Advance the current generation of a set, adding exclusion ranges if necessary.
set | the set where we want to advance the generation |
Definition at line 2125 of file gnunet-service-seti.c.
References GNUNET_assert.
Referenced by handle_client_accept(), and handle_client_evaluate().
|
static |
Called when a client wants to initiate a set operation with another peer.
Initiates the CADET connection to the listener and sends the request.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 2147 of file gnunet-service-seti.c.
References GNUNET_OK.
|
static |
Called when a client wants to initiate a set operation with another peer.
Initiates the CADET connection to the listener and sends the request.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 2165 of file gnunet-service-seti.c.
References advance_generation(), GNUNET_SETI_EvaluateMessage::app_id, Operation::channel, channel_end_cb(), channel_window_cb(), ClientState::client, Operation::client_request_id, context, Set::current_set_element_count, OperationRequestMessage::element_count, Operation::generation_created, GNUNET_break, GNUNET_CADET_channel_create(), GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_P2P_BF, GNUNET_MESSAGE_TYPE_SETI_P2P_DONE, GNUNET_MESSAGE_TYPE_SETI_P2P_ELEMENT_INFO, GNUNET_MESSAGE_TYPE_SETI_P2P_OPERATION_REQUEST, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg_nested_mh, GNUNET_MQ_send(), GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, Operation::mq, msg, Operation::my_element_count, Operation::my_elements, Operation::peer, Operation::phase, PHASE_COUNT_SENT, PHASE_INITIAL, GNUNET_SETI_EvaluateMessage::request_id, GNUNET_SETI_EvaluateMessage::return_intersection, Operation::return_intersection, Operation::salt, ClientState::set, Operation::set, and GNUNET_SETI_EvaluateMessage::target_peer.
|
static |
Handle a request from the client to cancel a running set operation.
cls | the client |
msg | the message |
Definition at line 2273 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), ClientState::client, Operation::client_request_id, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, Operation::next, op, Set::ops_head, GNUNET_SETI_CancelMessage::request_id, ClientState::set, and Operation::set.
|
static |
Handle a request from the client to accept a set operation that came from a remote peer.
We forward the accept to the associated operation for handling
cls | the client |
msg | the message |
Definition at line 2328 of file gnunet-service-seti.c.
References GNUNET_SETI_AcceptMessage::accept_reject_id, advance_generation(), begin_bf_exchange(), Operation::channel, ClientState::client, Operation::client_request_id, Set::current_set_element_count, Operation::generation_created, get_incoming(), GNUNET_break, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MIN, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SETI_STATUS_FAILURE, GNUNET_YES, ClientState::listener, Operation::listener, Operation::my_element_count, Operation::my_elements, op, Listener::op_head, Listener::op_tail, Operation::phase, PHASE_COUNT_SENT, PHASE_INITIAL, Operation::remote_element_count, GNUNET_SETI_AcceptMessage::request_id, GNUNET_SETI_ResultMessage::request_id, GNUNET_SETI_ResultMessage::result_status, GNUNET_SETI_AcceptMessage::return_intersection, Operation::return_intersection, send_element_count(), ClientState::set, and Operation::set.
|
static |
Called to clean up, after a shutdown has been requested.
cls | closure, NULL |
Definition at line 2424 of file gnunet-service-seti.c.
References GNUNET_CADET_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_STATISTICS_destroy(), GNUNET_YES, in_shutdown, and num_clients.
Referenced by run().
|
static |
Function called by the service's run method to run service-specific setup code.
cls | closure |
cfg | configuration to use |
service | the initialized service |
Definition at line 2452 of file gnunet-service-seti.c.
References _, client_connect_cb(), client_disconnect_cb(), GNUNET_CADET_connect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSAGE_TYPE_SETI_ACCEPT, GNUNET_MESSAGE_TYPE_SETI_ADD, GNUNET_MESSAGE_TYPE_SETI_CANCEL, GNUNET_MESSAGE_TYPE_SETI_CREATE, GNUNET_MESSAGE_TYPE_SETI_EVALUATE, GNUNET_MESSAGE_TYPE_SETI_LISTEN, GNUNET_MESSAGE_TYPE_SETI_REJECT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), and shutdown_task().
GNUNET_SERVICE_MAIN | ( | "seti" | , |
GNUNET_SERVICE_OPTION_NONE | , | ||
& | run, | ||
& | client_connect_cb, | ||
& | client_disconnect_cb, | ||
NULL | , | ||
GNUNET_MQ_hd_fixed_size(client_accept, GNUNET_MESSAGE_TYPE_SETI_ACCEPT, struct GNUNET_SETI_AcceptMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(client_set_add, GNUNET_MESSAGE_TYPE_SETI_ADD, struct GNUNET_SETI_ElementMessage, NULL) | , | ||
GNUNET_MQ_hd_fixed_size(client_create_set, GNUNET_MESSAGE_TYPE_SETI_CREATE, struct GNUNET_SETI_CreateMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(client_evaluate, GNUNET_MESSAGE_TYPE_SETI_EVALUATE, struct GNUNET_SETI_EvaluateMessage, NULL) | , | ||
GNUNET_MQ_hd_fixed_size(client_listen, GNUNET_MESSAGE_TYPE_SETI_LISTEN, struct GNUNET_SETI_ListenMessage, NULL) | , | ||
GNUNET_MQ_hd_fixed_size(client_reject, GNUNET_MESSAGE_TYPE_SETI_REJECT, struct GNUNET_SETI_RejectMessage, NULL) | , | ||
GNUNET_MQ_hd_fixed_size(client_cancel, GNUNET_MESSAGE_TYPE_SETI_CANCEL, struct GNUNET_SETI_CancelMessage, NULL) | , | ||
GNUNET_MQ_handler_end() | |||
) |
Define "main" method using service macro.
Referenced by run().
|
static |
Handle to the cadet service, used to listen for and connect to remote peers.
Definition at line 471 of file gnunet-service-seti.c.
|
static |
Statistics handle.
Definition at line 476 of file gnunet-service-seti.c.
|
static |
Listeners are held in a doubly linked list.
Definition at line 481 of file gnunet-service-seti.c.
|
static |
Listeners are held in a doubly linked list.
Definition at line 486 of file gnunet-service-seti.c.
|
static |
Number of active clients.
Definition at line 491 of file gnunet-service-seti.c.
Referenced by client_connect_cb(), client_disconnect_cb(), and shutdown_task().
|
static |
Are we in shutdown? if GNUNET_YES and the number of clients drops to zero, disconnect from CADET.
Definition at line 497 of file gnunet-service-seti.c.
Referenced by client_disconnect_cb(), and shutdown_task().
|
static |
Counter for allocating unique IDs for clients, used to identify incoming operation requests from remote peers, that the client can choose to accept or refuse.
0 must not be used (reserved for uninitialized).
Definition at line 505 of file gnunet-service-seti.c.
Referenced by handle_incoming_msg().