33#define LOG(kind, ...) GNUNET_log_from (kind, "seti-api", __VA_ARGS__)
238 result_status = ntohs (
msg->result_status);
240 "Got result message with status %d\n",
243 ntohl (
msg->request_id));
249 "Ignoring result from canceled operation\n");
253 switch (result_status)
270 ntohl (
msg->request_id));
289 "No callback for final status\n");
342 "Cancelling SET operation\n");
355 "Destroying set after operation cancel\n");
375 "Handling client set error %d\n",
424 "Creating new intersection set\n");
456 "adding element of type %u to set %p\n",
497 "Set operations are pending, delaying set destruction\n");
502 "Really destroying set\n");
531 msg->target_peer = *other_peer;
543 "Option with type %d not recognized\n",
578 if (NULL == context_msg)
605 "Processing incoming operation request with id %u\n",
606 ntohl (
msg->accept_id));
620 "Rejected request %u\n",
621 ntohl (
msg->accept_id));
644 "Listener broke down (%d), re-connecting\n",
710 "Starting listener for app %s\n",
737 "Canceling listener %s\n",
765 "Client accepts set intersection operation with id %u\n",
770 msg->accept_reject_id = htonl (
request->accept_id);
788 "Option with type %d not recognized\n",
824 "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 intersection 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_SETI_LISTEN
Listen for operation requests.
#define GNUNET_MESSAGE_TYPE_SETI_REJECT
Reject a set request.
#define GNUNET_MESSAGE_TYPE_SETI_EVALUATE
Evaluate a set operation.
#define GNUNET_MESSAGE_TYPE_SETI_ADD
Add element to set.
#define GNUNET_MESSAGE_TYPE_SETI_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETI_REQUEST
Notify the client of an incoming request from a remote peer.
#define GNUNET_MESSAGE_TYPE_SETI_CREATE
Create a new local set.
#define GNUNET_MESSAGE_TYPE_SETI_CANCEL
Cancel a set operation.
#define GNUNET_MESSAGE_TYPE_SETI_ACCEPT
Accept an incoming set request.
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.
GNUNET_SETI_Status
Status for the result callback.
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().
void GNUNET_SETI_destroy(struct GNUNET_SETI_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
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.
int GNUNET_SETI_commit(struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set)
Commit a set to be used with a set operation.
void GNUNET_SETI_element_hash(const struct GNUNET_SETI_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
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.
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.
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.
struct GNUNET_SETI_Handle * GNUNET_SETI_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set.
void GNUNET_SETI_operation_cancel(struct GNUNET_SETI_OperationHandle *oh)
Cancel the given set operation.
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.
void GNUNET_SETI_listen_cancel(struct GNUNET_SETI_ListenHandle *lh)
Cancel the given listen operation.
@ GNUNET_SETI_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETI_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
@ GNUNET_SETI_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETI_STATUS_DEL_LOCAL
Element should be delete from the result set of the local peer, i.e.
@ GNUNET_SETI_OPTION_RETURN_INTERSECTION
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL).
@ GNUNET_SETI_OPTION_END
List terminator.
#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 int check_result(void *cls, const struct GNUNET_SETI_ResultMessage *msg)
Check that the given msg is well-formed.
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 void handle_result(void *cls, const struct GNUNET_SETI_ResultMessage *msg)
Handle result message for a set operation.
static void handle_request(void *cls, const struct GNUNET_SETI_RequestMessage *msg)
Handle request message for a listen operation.
static int check_request(void *cls, const struct GNUNET_SETI_RequestMessage *msg)
Check validity of request message for a listen operation.
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_SETI_OperationHandle *oh)
Destroy the given set 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.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
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_MQ_Handle * mq
Message queue for client.
struct GNUNET_SETI_OperationHandle * ops_head
Linked list of operations on the set.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration, needed when creating (lazy) copies.
uint16_t iteration_id
Both client and service count the number of iterators created so far to match replies with iterators.
struct GNUNET_SETI_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_SETI_destroy() must...
int invalid
Has the set become invalid (e.g.
Opaque handle to a listen operation.
struct GNUNET_HashCode app_id
Application ID we listen for.
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
GNUNET_SETI_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
struct GNUNET_MQ_Handle * mq
Message queue for the client.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
void * listen_cls
Closure for listen_cb.
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.
struct GNUNET_SETI_OperationHandle * prev
Handles are kept in a linked list.
uint32_t request_id
Request ID to identify the operation within the set.
struct GNUNET_SETI_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
GNUNET_SETI_ResultIterator result_cb
Function to be called when we have a result, or an error.
struct GNUNET_SETI_OperationHandle * next
Handles are kept in a linked list.
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_MQ_Envelope * conclude_mqm
Message sent to the server on calling conclude, NULL if conclude has been called.
int return_intersection
Should we return the resulting intersection (ADD) or the elements to remove (DEL)?
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.
uint32_t accept_id
Id of the request, used to identify the request when accepting/rejecting it.
int accepted
Has the request been accepted already? GNUNET_YES/GNUNET_NO.
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_SETI_Status in NBO.
Time for relative time used by GNUnet, in microseconds.