34#define LOG(kind, ...) GNUNET_log_from (kind, "set-api", __VA_ARGS__)
221 result_status = ntohs (
msg->result_status);
223 "Got result message with status %d\n",
226 ntohl (
msg->request_id));
232 "Ignoring result from canceled operation\n");
236 switch (result_status)
253 "Treating result as final status\n");
255 ntohl (
msg->request_id));
274 "No callback for final status\n");
327 "Cancelling SET operation\n");
340 "Destroying set after operation cancel\n");
360 "Handling client set error %d\n",
438 "adding element of type %u to set %p\n",
481 "Set operations are pending, delaying set destruction\n");
486 "Really destroying set\n");
509 "Client prepares set union operation\n");
517 msg->target_peer = *other_peer;
520 msg->byzantine_upper_bond = UINT64_MAX;
521 msg->bandwidth_latency_tradeoff = 0;
522 msg->ibf_bucket_number_factor = 2;
523 msg->ibf_number_of_buckets_per_element = 3;
532 msg->byzantine_lower_bound = htonl (opt->v.num);
535 msg->byzantine_upper_bond = htonl (opt->v.num);
538 msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
541 msg->ibf_bucket_number_factor = htonl (opt->v.num);
544 msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
557 "Option with type %d not recognized\n",
592 if (NULL == context_msg)
619 "Processing incoming operation request with id %u\n",
620 ntohl (
msg->accept_id));
634 "Rejected request %u\n",
635 ntohl (
msg->accept_id));
658 "Listener broke down (%d), re-connecting\n",
725 "Starting listener for app %s\n",
752 "Canceling listener %s\n",
780 "Client accepts set union operation with id %u\n",
785 msg->accept_reject_id = htonl (
request->accept_id);
788 msg->byzantine_upper_bond = UINT64_MAX;
789 msg->bandwidth_latency_tradeoff = 0;
790 msg->ibf_bucket_number_factor = 2;
791 msg->ibf_number_of_buckets_per_element = 3;
799 msg->byzantine_lower_bound = htonl (opt->v.num);
802 msg->byzantine_upper_bond = htonl (opt->v.num);
805 msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
808 msg->ibf_bucket_number_factor = htonl (opt->v.num);
811 msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
824 "Option with type %d not recognized\n",
865 "Client commits to SET\n");
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
static struct GNUNET_FS_Handle * ctx
static int result
Global testing status.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Constants for network protocols.
Two-peer set union operations.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
void * GNUNET_MQ_assoc_get(struct GNUNET_MQ_Handle *mq, uint32_t request_id)
Get the data associated with a request_id in a queue.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
uint32_t GNUNET_MQ_assoc_add(struct GNUNET_MQ_Handle *mq, void *assoc_data)
Associate the assoc_data in mq with a unique request id.
void * GNUNET_MQ_assoc_remove(struct GNUNET_MQ_Handle *mq, uint32_t request_id)
Remove the association for a request_id.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#define GNUNET_MQ_extract_nested_mh(var)
Return a pointer to the message at the end of the given message.
#define GNUNET_MESSAGE_TYPE_SETU_REQUEST
Notify the client of an incoming request from a remote peer.
#define GNUNET_MESSAGE_TYPE_SETU_REJECT
Reject a 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_MESSAGE_TYPE_SETU_ADD
Add element to set.
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
#define GNUNET_MESSAGE_TYPE_SETU_LISTEN
Listen for operation requests.
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
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.
void GNUNET_SETU_element_hash(const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
struct GNUNET_SETU_Handle * GNUNET_SETU_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set, supporting the specified operation.
void GNUNET_SETU_operation_cancel(struct GNUNET_SETU_OperationHandle *oh)
Cancel the given set operation.
void(* GNUNET_SETU_ListenCallback)(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
Called when another peer wants to do a set operation with the local peer.
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_accept(struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETU_listen().
int GNUNET_SETU_commit(struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
Commit a set to be used with a set operation.
struct GNUNET_SETU_ListenHandle * GNUNET_SETU_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application id.
void(* GNUNET_SETU_ResultIterator)(void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
Callback for set union operation results.
GNUNET_SETU_Status
Status for the result callback.
void GNUNET_SETU_listen_cancel(struct GNUNET_SETU_ListenHandle *lh)
Cancel the given listen operation.
int GNUNET_SETU_add_element(struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
@ GNUNET_SETU_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT
This setting determines to how many IBF buckets an single elements is mapped to.
@ GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF
Bandwidth latency tradeoff determines how much bytes a single RTT is worth, which is a performance se...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR
The factor determines the number of buckets an IBF has which is multiplied by the estimated setsize d...
@ GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND
Byzantine upper bound.
@ GNUNET_SETU_OPTION_SYMMETRIC
Notify client also if we are sending a value to the other peer.
@ GNUNET_SETU_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SETU_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static void handle_client_listener_error(void *cls, enum GNUNET_MQ_Error error)
Our connection with the set service encountered an error, re-initialize with exponential back-off.
static int check_result(void *cls, const struct GNUNET_SETU_ResultMessage *msg)
Check that the given msg is well-formed.
static void handle_client_set_error(void *cls, enum GNUNET_MQ_Error error)
We encountered an error communicating with the set service while performing a set operation.
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
static void set_operation_destroy(struct GNUNET_SETU_OperationHandle *oh)
Destroy the given set operation.
static void handle_result(void *cls, const struct GNUNET_SETU_ResultMessage *msg)
Handle result message for a set operation.
static void handle_request(void *cls, const struct GNUNET_SETU_RequestMessage *msg)
Handle request message for a listen operation.
static int check_request(void *cls, const struct GNUNET_SETU_RequestMessage *msg)
Check validity of request message for a listen operation.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Message sent by a listening client to the service to accept performing the operation with the other p...
Sent to the service by the client in order to cancel a set operation.
Message sent by the client to the service to ask starting a new set to perform operations with.
Message sent by client to the service to add an element to the set.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
Message sent by client to service to initiate a set operation as a client (not as listener).
struct GNUNET_HashCode app_id
Application id.
struct GNUNET_SETU_OperationHandle * ops_tail
Linked list of operations on the set.
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETU_destroy() must...
int invalid
Has the set become invalid (e.g.
struct GNUNET_SETU_OperationHandle * ops_head
Linked list of operations on the set.
struct GNUNET_MQ_Handle * mq
Message queue for client.
Opaque handle to a listen operation.
struct GNUNET_HashCode app_id
Application ID we listen for.
struct GNUNET_MQ_Handle * mq
Message queue for the client.
GNUNET_SETU_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
void * listen_cls
Closure for listen_cb.
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Message sent by the client to the service to start listening for incoming requests to perform a certa...
void * result_cls
Closure for result_cb.
GNUNET_SETU_ResultIterator result_cb
Function to be called when we have a result, or an error.
uint32_t * request_id_addr
Address of the request if in the conclude message, used to patch the request id into the message when...
struct GNUNET_SETU_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
uint32_t request_id
Request ID to identify the operation within the set.
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called.
struct GNUNET_SETU_OperationHandle * prev
Handles are kept in a linked list.
struct GNUNET_SETU_OperationHandle * next
Handles are kept in a linked list.
Option for set operations.
Message sent by a listening client to the service to reject performing the operation with the other p...
uint32_t accept_reject_id
ID of the incoming request we want to reject.
A request for an operation with another client.
Handle for a set operation request from another peer.
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
uint16_t result_status
Was the evaluation successful? Contains an enum GNUNET_SETU_Status in NBO.
Time for relative time used by GNUnet, in microseconds.