#include "platform.h"
#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 (GNUNET_OS_project_data_gnunet(), "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 38 of file gnunet-service-seti.c.
Current phase we are in for a intersection operation.
Definition at line 44 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 517 of file gnunet-service-seti.c.
References _GSS_statistics, 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, op, GNUNET_SETI_ResultMessage::request_id, GNUNET_SETI_ResultMessage::result_status, 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 563 of file gnunet-service-seti.c.
References ElementEntry::generation_added, and op.
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 579 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, op, 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 650 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, op, 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 705 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, op, 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 739 of file gnunet-service-seti.c.
References 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, op, Set::ops_head, and Set::ops_tail.
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 867 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, incoming_destroy(), op, and send_client_done_and_destroy().
Referenced by 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 808 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_cancel(), op, Listener::op_head, and Listener::op_tail.
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 838 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), _GSS_statistics, 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(), op, GNUNET_SETI_ResultMessage::request_id, and GNUNET_SETI_ResultMessage::result_status.
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 911 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), _GSS_statistics, 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(), msg, and op.
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 945 of file gnunet-service-seti.c.
References _GSS_statistics, 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(), msg, and op.
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 1049 of file gnunet-service-seti.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, op, 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 1068 of file gnunet-service-seti.c.
References 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, op, 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 1093 of file gnunet-service-seti.c.
References GNUNET_SETI_Element::data, ElementEntry::element, ElementEntry::element_hash, GNUNET_SETI_Element::element_type, GNUNET_SETI_ResultMessage::element_type, 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, op, PHASE_DONE_RECEIVED, PHASE_FINISHED, PHASE_MUST_SEND_DONE, GNUNET_SETI_ResultMessage::request_id, res, GNUNET_SETI_ResultMessage::result_status, send_client_done_and_destroy(), send_p2p_done(), send_remaining_elements(), and GNUNET_SETI_Element::size.
Referenced by handle_intersection_p2p_done(), process_bf(), and send_remaining_elements().
|
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 1169 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, op, 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 1201 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(), msg, and op.
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 1223 of file gnunet-service-seti.c.
References GNUNET_CONTAINER_multihashmap_iterate(), initialize_map_unfiltered(), op, PHASE_BF_EXCHANGE, and send_bloomfilter().
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 1241 of file gnunet-service-seti.c.
References begin_bf_exchange(), fail_intersection_operation(), GNUNET_break, GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, msg, op, PHASE_COUNT_SENT, and PHASE_INITIAL.
|
static |
Process a Bloomfilter once we got all the chunks.
op | the intersection operation |
Definition at line 1274 of file gnunet-service-seti.c.
References fail_intersection_operation(), filtered_map_initialization(), 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(), op, PHASE_BF_EXCHANGE, PHASE_COUNT_SENT, PHASE_DONE_RECEIVED, PHASE_FINISHED, PHASE_INITIAL, PHASE_MUST_SEND_DONE, send_bloomfilter(), send_p2p_done(), and send_remaining_elements().
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 1356 of file gnunet-service-seti.c.
|
static |
Handle an BF message from a remote peer.
cls | the intersection operation |
msg | the header of the message |
Definition at line 1373 of file gnunet-service-seti.c.
References Operation::bf_bits_per_element, fail_intersection_operation(), GNUNET_break_op, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, msg, op, PHASE_BF_EXCHANGE, PHASE_COUNT_SENT, PHASE_INITIAL, process_bf(), 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 1473 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, op, 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 1506 of file gnunet-service-seti.c.
References IntersectionDoneMessage::element_xor_hash, fail_intersection_operation(), filter_all(), IntersectionDoneMessage::final_element_count, 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, op, PHASE_BF_EXCHANGE, PHASE_DONE_RECEIVED, PHASE_FINISHED, 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 1567 of file gnunet-service-seti.c.
References Operation::listener, listener_head, Listener::next, GNUNET_ARM_Operation::next, op, and Listener::op_head.
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 |
Definition at line 1589 of file gnunet-service-seti.c.
References ClientState::client, GNUNET_new, mq, ClientState::mq, and num_clients.
|
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 1612 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 1631 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), cadet, Set::content, Set::cs, 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, listener_head, listener_tail, num_clients, op, Listener::op_head, Listener::open_port, Set::ops_head, SetContent::refcount, and ClientState::set.
|
static |
Check a request for a set operation from another peer.
cls | the operation state |
msg | the received message |
Definition at line 1705 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, msg, op, and GNUNET_MessageHeader::size.
|
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 1753 of file gnunet-service-seti.c.
References GNUNET_SETI_RequestMessage::accept_id, Listener::cs, 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(), ClientState::mq, msg, op, GNUNET_SETI_RequestMessage::peer_id, and suggest_id.
|
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 1806 of file gnunet-service-seti.c.
References ClientState::client, Set::content, Set::cs, SetContent::elements, GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, SetContent::refcount, and ClientState::set.
|
static |
Timeout happens iff:
cls | channel context |
tc | context information (why was this task triggered now) |
Definition at line 1842 of file gnunet-service-seti.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, incoming_destroy(), and op.
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 1870 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, op, Listener::op_head, Listener::op_tail, and source.
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 1913 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), and op.
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 1938 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 1953 of file gnunet-service-seti.c.
References Listener::app_id, cadet, 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, listener_head, listener_tail, msg, 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 2014 of file gnunet-service-seti.c.
References _GSS_operation_destroy2(), 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, msg, 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 2046 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 2062 of file gnunet-service-seti.c.
References ClientState::client, Set::content, Set::current_set_element_count, GNUNET_SET_Element::data, el, ElementEntry::element, ElementEntry::element_hash, GNUNET_SET_Element::element_type, SetContent::elements, 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, msg, ElementEntry::remote, ClientState::set, GNUNET_MessageHeader::size, and GNUNET_SET_Element::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 2126 of file gnunet-service-seti.c.
References Set::content, Set::current_generation, GNUNET_assert, and SetContent::latest_generation.
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 2148 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 2166 of file gnunet-service-seti.c.
References advance_generation(), cadet, channel_end_cb(), channel_window_cb(), ClientState::client, context, Set::current_generation, OperationRequestMessage::element_count, 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, msg, op, Set::ops_head, Set::ops_tail, PHASE_COUNT_SENT, PHASE_INITIAL, and ClientState::set.
|
static |
Handle a request from the client to cancel a running set operation.
cls | the client |
msg | the message |
Definition at line 2274 of file gnunet-service-seti.c.
References _GSS_operation_destroy(), ClientState::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, msg, GNUNET_ARM_Operation::next, op, Set::ops_head, 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 2329 of file gnunet-service-seti.c.
References advance_generation(), begin_bf_exchange(), ClientState::client, Listener::cs, Set::cs, Set::current_generation, 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, ClientState::mq, msg, op, Listener::op_head, Listener::op_tail, Set::ops_head, Set::ops_tail, PHASE_COUNT_SENT, PHASE_INITIAL, GNUNET_SETI_ResultMessage::request_id, GNUNET_SETI_ResultMessage::result_status, send_element_count(), and ClientState::set.
|
static |
Called to clean up, after a shutdown has been requested.
cls | closure, NULL |
Definition at line 2425 of file gnunet-service-seti.c.
References _GSS_statistics, cadet, 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 2453 of file gnunet-service-seti.c.
References _, _GSS_statistics, cadet, cfg, GNUNET_CADET_connect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), and shutdown_task().
GNUNET_SERVICE_MAIN | ( | GNUNET_OS_project_data_gnunet() | , |
"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.
|
static |
Handle to the cadet service, used to listen for and connect to remote peers.
Definition at line 472 of file gnunet-service-seti.c.
Referenced by client_disconnect_cb(), handle_client_evaluate(), handle_client_listen(), run(), and shutdown_task().
|
static |
Statistics handle.
Definition at line 477 of file gnunet-service-seti.c.
Referenced by fail_intersection_operation(), run(), send_bloomfilter(), send_client_done_and_destroy(), send_client_removed_element(), and shutdown_task().
|
static |
Listeners are held in a doubly linked list.
Definition at line 482 of file gnunet-service-seti.c.
Referenced by client_disconnect_cb(), get_incoming(), and handle_client_listen().
|
static |
Listeners are held in a doubly linked list.
Definition at line 487 of file gnunet-service-seti.c.
Referenced by client_disconnect_cb(), and handle_client_listen().
|
static |
Number of active clients.
Definition at line 492 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 498 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 506 of file gnunet-service-seti.c.
Referenced by handle_incoming_msg().