33 #define LOG(kind, ...) GNUNET_log_from (kind, "seti-api", __VA_ARGS__) 240 "Got result message with status %d\n",
249 "Ignoring result from canceled operation\n");
253 switch (result_status)
277 destroy_set = (
GNUNET_YES ==
set->destroy_requested) &&
278 (NULL == set->ops_head);
289 "No callback for final status\n");
342 "Cancelling SET operation\n");
352 (NULL == set->ops_head))
355 "Destroying set after operation cancel\n");
375 "Handling client set error %d\n",
377 while (NULL != set->ops_head)
379 if ((NULL != set->ops_head->result_cb) &&
381 set->ops_head->result_cb (set->ops_head->result_cls,
424 "Creating new intersection set\n");
456 "adding element of type %u to set %p\n",
493 if ((NULL != set->ops_head) ||
497 "Set operations are pending, delaying set destruction\n");
502 "Really destroying set\n");
556 "Option with type %d not recognized\n",
591 if (NULL == context_msg)
618 "Processing incoming operation request with id %u\n",
633 "Rejected request %u\n",
657 "Listener broke down (%d), re-connecting\n",
723 "Starting listener for app %s\n",
750 "Canceling listener %s\n",
791 "Client accepts set intersection operation with id %u\n",
814 "Option with type %d not recognized\n",
850 "Client commits to SET\n");
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
uint32_t accept_id
ID of the to identify the request when accepting or rejecting it.
uint32_t request_id
Id of our set to evaluate, chosen implicitly by the client when it calls GNUNET_SETI_commit().
Success, all elements have been sent (and received).
int invalid
Has the set become invalid (e.g.
struct GNUNET_MessageHeader * msg
int GNUNET_SETI_add_element(struct GNUNET_SETI_Handle *set, const struct GNUNET_SETI_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
The other peer refused to do the operation with us, or something went wrong.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Sent to the service by the client in order to cancel a set operation.
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
struct GNUNET_GETOPT_CommandLineOption options[]
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_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct...
uint64_t current_size
Current set size.
#define GNUNET_MESSAGE_TYPE_SETI_REQUEST
Notify the client of an incoming request from a remote peer.
#define GNUNET_MESSAGE_TYPE_SETI_EVALUATE
Evaluate a set operation.
uint16_t size
Number of bytes in the buffer pointed to by data.
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.
int GNUNET_SETI_commit(struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set)
Commit a set to be used with a set operation.
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SETI_RESULT.
#define GNUNET_MESSAGE_TYPE_SETI_ACCEPT
Accept an incoming set request.
Option for set operations.
#define GNUNET_MQ_extract_nested_mh(var)
Return a pointer to the message at the end of the given message.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_SETI_CANCEL
Cancel a set operation.
static void handle_request(void *cls, const struct GNUNET_SETI_RequestMessage *msg)
Handle request message for a listen operation.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Message sent by a listening client to the service to accept performing the operation with the other p...
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
uint32_t accept_reject_id
ID of the incoming request we want to accept.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Message sent by a listening client to the service to reject performing the operation with the other p...
static struct GNUNET_HashCode app_id
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void * listen_cls
Closure for listen_cb.
uint32_t return_intersection
Return the intersection (1), instead of the elements to remove / the delta (0), in NBO...
struct GNUNET_SETI_ListenHandle * GNUNET_SETI_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETI_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application id.
Opaque handle to a listen operation.
void * result_cls
Closure for result_cb.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for a set operation request from another peer.
#define GNUNET_MESSAGE_TYPE_SETI_REJECT
Reject a set request.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
Message sent by the client to the service to start listening for incoming requests to perform a certa...
uint16_t element_type
Type of the element to add or remove.
void(* GNUNET_SETI_ListenCallback)(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)
Called when another peer wants to do a set operation with the local peer.
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
static int check_request(void *cls, const struct GNUNET_SETI_RequestMessage *msg)
Check validity of request message for a listen operation.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
struct GNUNET_HashCode app_id
application id
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETI_destroy() must...
struct GNUNET_SETI_OperationHandle * next
Handles are kept in a linked list.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Element should be added to the result set of the local peer, i.e.
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.
uint32_t request_id
ID of the request we want to cancel.
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 request_id
id the result belongs to
struct GNUNET_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called. ...
struct GNUNET_SETI_OperationHandle * GNUNET_SETI_accept(struct GNUNET_SETI_Request *request, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETI_listen.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
void GNUNET_SETI_operation_cancel(struct GNUNET_SETI_OperationHandle *oh)
Cancel the given set operation.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_HashCode app_id
Application id.
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...
uint32_t accept_reject_id
ID of the incoming request we want to reject.
const void * data
Actual data of the element.
static int result
Global testing status.
struct GNUNET_SETI_Handle * GNUNET_SETI_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set.
struct GNUNET_SETI_OperationHandle * ops_tail
Linked list of operations on the set.
#define GNUNET_MESSAGE_TYPE_SETI_RESULT
Handle result message from operation.
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
Message handler for a specific message type.
static void set_operation_destroy(struct GNUNET_SETI_OperationHandle *oh)
Destroy the given set operation.
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
uint32_t request_id
Request ID to identify responses.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
uint32_t * request_id_addr
Address of the request if in the conclude message, used to patch the request id into the message when...
int return_intersection
Should we return the resulting intersection (ADD) or the elements to remove (DEL)?
uint32_t request_id
Request ID to identify the operation within the set.
#define GNUNET_MESSAGE_TYPE_SETI_ADD
Add element to set.
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
struct GNUNET_PeerIdentity peer_id
Identity of the requesting peer.
#define GNUNET_MESSAGE_TYPE_SETI_LISTEN
Listen for operation requests.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
void GNUNET_SETI_element_hash(const struct GNUNET_SETI_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
Element should be delete from the result set of the local peer, i.e.
void(* GNUNET_SETI_ResultIterator)(void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)
Callback for set union operation results.
struct GNUNET_PeerIdentity target_peer
Peer to evaluate the operation with.
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Handle to a message queue.
struct GNUNET_SETI_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
The identity of the host (wraps the signing key of the peer).
GNUNET_SETI_Status
Status for the result callback.
uint16_t iteration_id
Both client and service count the number of iterators created so far to match replies with iterators...
void * GNUNET_MQ_assoc_remove(struct GNUNET_MQ_Handle *mq, uint32_t request_id)
Remove the association for a request_id.
uint16_t result_status
Was the evaluation successful? Contains an enum GNUNET_SETI_Status in NBO.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Message sent by the client to the service to ask starting a new set to perform operations with...
struct GNUNET_SETI_OperationHandle * ops_head
Linked list of operations on the set.
GNUNET_SETI_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
struct GNUNET_SETI_OperationHandle * prev
Handles are kept in a linked list.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_SETI_REQUEST.
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL). ...
GNUNET_SETI_ResultIterator result_cb
Function to be called when we have a result, or an error.
struct GNUNET_MQ_Handle * mq
Message queue for client.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
uint32_t return_intersection
Return the intersection (1), instead of the elements to remove / the delta (0), in NBO...
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration, needed when creating (lazy) copies.
A request for an operation with another client.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
static int check_result(void *cls, const struct GNUNET_SETI_ResultMessage *msg)
Check that the given msg is well-formed.
Message sent by client to service to initiate a set operation as a client (not as listener)...
void GNUNET_SETI_listen_cancel(struct GNUNET_SETI_ListenHandle *lh)
Cancel the given listen operation.
struct GNUNET_MQ_Handle * mq
Message queue for the client.
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...
Message sent by client to the service to add an element to the set.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
uint16_t element_type
Application-specific element type.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
struct GNUNET_SETI_OperationHandle * GNUNET_SETI_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
uint16_t element_type
Type of the element attachted to the message, if any.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_HashCode app_id
Application ID we listen for.
#define GNUNET_MESSAGE_TYPE_SETI_CREATE
Create a new local set.
void GNUNET_SETI_destroy(struct GNUNET_SETI_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
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.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
static void handle_result(void *cls, const struct GNUNET_SETI_ResultMessage *msg)
Handle result message for a set operation.