33#define LOG(kind, ...) GNUNET_log_from (kind, "set-api", __VA_ARGS__)
237 const uint32_t *cookie);
264 "Handling response to lazy copy\n");
273 req->
cb (req->
cls, new_set);
313 "Received element in set iteration\n");
314 msize = ntohs (
msg->header.
size);
330 ack_msg->
send_more = htonl ((NULL != iter));
354 "Service completed set iteration that was already cancelled\n");
358 "Set iteration completed\n");
404 result_status = ntohs (
msg->result_status);
406 "Got result message with status %d\n",
410 ntohl (
msg->request_id));
416 "Ignoring result from canceled operation\n");
420 switch (result_status)
438 "Treating result as final status\n");
440 ntohl (
msg->request_id));
459 "No callback for final status\n");
468 "Treating result as element\n");
523 "Cancelling SET operation\n");
536 "Destroying set after operation cancel\n");
557 "Handling client set error %d\n",
584 const uint32_t *cookie)
624 "Creating new set (operation %u)\n",
633 "Creating new set (lazy copy)\n");
665 "Creating set %p for operation %d\n",
682 "adding element of type %u to set %p\n",
716 "Removing element from set %p\n",
756 "Set operations are pending, delaying set destruction\n");
761 "Really destroying set\n");
786 "Client prepares set operation (%d)\n",
794 msg->app_id = *app_id;
795 msg->result_mode = htonl (result_mode);
796 msg->target_peer = *other_peer;
803 msg->byzantine_lower_bound = opt->
v.
num;
816 "Option with type %d not recognized\n", (
int) opt->
type);
851 if (NULL == context_msg)
878 "Processing incoming operation request with id %u\n",
879 ntohl (
msg->accept_id));
893 "Rejected request %u\n",
894 ntohl (
msg->accept_id));
916 "Listener broke down (%d), re-connecting\n",
985 "Starting listener for app %s\n",
1013 "Canceling listener %s\n",
1042 "Client accepts set operation (%d) with id %u\n",
1048 msg->accept_reject_id = htonl (
request->accept_id);
1076 if (NULL != oh->
set)
1087 "Client commits to SET\n");
1129 "Iterating over set\n");
1147 "Creating lazy copy of set\n");
1175 copy->
data = ©[1];
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
static struct GNUNET_ARM_Operation * op
Current operation.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
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.
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_malloc(size)
Wrapper around malloc.
#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.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
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.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
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_SET_EVALUATE
Evaluate a set operation.
#define GNUNET_MESSAGE_TYPE_SET_CANCEL
Cancel a set operation.
#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE
Give the client an ID for connecting to the set's copy.
#define GNUNET_MESSAGE_TYPE_SET_ADD
Add element to set.
#define GNUNET_MESSAGE_TYPE_SET_REQUEST
Notify the client of a request from a remote peer.
#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE
Ask the set service to prepare a copy of a set.
#define GNUNET_MESSAGE_TYPE_SET_REJECT
Reject a set request.
#define GNUNET_MESSAGE_TYPE_SET_LISTEN
Listen for operation requests.
#define GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT
Element result for the iterating client.
#define GNUNET_MESSAGE_TYPE_SET_ACCEPT
Accept a set request.
#define GNUNET_MESSAGE_TYPE_SET_RESULT
Create an empty set.
#define GNUNET_MESSAGE_TYPE_SET_REMOVE
Remove element from set.
#define GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST
Start iteration over set elements.
#define GNUNET_MESSAGE_TYPE_SET_ITER_ACK
Acknowledge result from iteration.
#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT
Sent by the client to the server to connect to an existing, lazily copied set.
#define GNUNET_MESSAGE_TYPE_SET_ITER_DONE
Iteration end marker for the client.
#define GNUNET_MESSAGE_TYPE_SET_CREATE
Create a new local set.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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_SET_Status
Status for the result callback.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
void GNUNET_SET_copy_lazy(struct GNUNET_SET_Handle *set, GNUNET_SET_CopyReadyCallback cb, void *cls)
struct GNUNET_SET_Element * GNUNET_SET_element_dup(const struct GNUNET_SET_Element *element)
Create a copy of an element.
void GNUNET_SET_listen_cancel(struct GNUNET_SET_ListenHandle *lh)
Cancel the given listen operation.
int GNUNET_SET_remove_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Remove an element to the given set.
void(* GNUNET_SET_Continuation)(void *cls)
Continuation used for some of the set operations.
int GNUNET_SET_iterate(struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *iter_cls)
Iterate over all elements in the given set.
void(* GNUNET_SET_ResultIterator)(void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
Callback for set operation results.
void GNUNET_SET_operation_cancel(struct GNUNET_SET_OperationHandle *oh)
Cancel the given set operation.
void(* GNUNET_SET_ListenCallback)(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
Called when another peer wants to do a set operation with the local peer.
GNUNET_SET_ResultMode
The way results are given to the client.
int(* GNUNET_SET_ElementIterator)(void *cls, const struct GNUNET_SET_Element *element)
Iterator for set elements.
void(* GNUNET_SET_CopyReadyCallback)(void *cls, struct GNUNET_SET_Handle *copy)
GNUNET_SET_OperationType
The operation that a set set supports.
struct GNUNET_SET_Handle * GNUNET_SET_create(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
Create an empty set, supporting the specified operation.
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
struct GNUNET_SET_ListenHandle * GNUNET_SET_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType operation, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application id.
struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
struct GNUNET_SET_OperationHandle * GNUNET_SET_accept(struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SET_listen().
int GNUNET_SET_add_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Add an element to the given set.
void GNUNET_SET_element_hash(const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash)
Hash a set element.
@ GNUNET_SET_STATUS_OK
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set,...
@ GNUNET_SET_STATUS_FAILURE
The other peer refused to to the operation with us, or something went wrong.
@ GNUNET_SET_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SET_STATUS_HALF_DONE
Success, all elements have been returned (but the other peer might still be receiving some from us,...
@ GNUNET_SET_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SET_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
@ GNUNET_SET_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SET_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SET_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.
@ GNUNET_SET_OPERATION_NONE
A purely local set that does not support any operation.
#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...
messages used for the set api
static int check_iter_element(void *cls, const struct GNUNET_SET_IterResponseMessage *msg)
Check that the given msg is well-formed.
static void handle_iter_done(void *cls, const struct GNUNET_MessageHeader *mh)
Handle message signalling conclusion of iteration over the set.
static void handle_copy_lazy(void *cls, const struct GNUNET_SET_CopyLazyResponseMessage *msg)
Handle element for iteration over the set.
static void handle_request(void *cls, const struct GNUNET_SET_RequestMessage *msg)
Handle request message for a listen operation.
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_SET_ResultMessage *msg)
Handle result message for a set operation.
static void set_operation_destroy(struct GNUNET_SET_OperationHandle *oh)
Destroy the given set operation.
static struct GNUNET_SET_Handle * create_internal(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op, const uint32_t *cookie)
FIXME.
static int check_result(void *cls, const struct GNUNET_SET_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 int check_request(void *cls, const struct GNUNET_SET_RequestMessage *msg)
Check validity of request message for a listen operation.
static void handle_iter_element(void *cls, const struct GNUNET_SET_IterResponseMessage *msg)
Handle element for iteration over the set.
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...
uint32_t result_mode
How should results be sent to us? See enum GNUNET_SET_ResultMode.
Sent to the service by the client in order to cancel a set operation.
Client connects to a lazily copied set.
uint32_t cookie
Temporary name for the copied set.
Server responds to a lazy copy request.
Message sent by the client to the service to ask starting a new set to perform operations with.
uint32_t operation
Operation type, values of enum GNUNET_SET_OperationType
Message sent by client to the service to add or remove an element to/from the set.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
Message sent by client to service to initiate a set operation as a client (not as listener).
uint16_t iteration_id
Both client and service count the number of iterators created so far to match replies with iterators.
struct GNUNET_SET_OperationHandle * ops_head
Linked list of operations on the set.
int invalid
Has the set become invalid (e.g.
struct GNUNET_SET_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_SET_destroy() must ...
struct GNUNET_MQ_Handle * mq
Message queue for client.
GNUNET_SET_ElementIterator iterator
Callback for the current iteration over the set, NULL if no iterator is active.
struct SetCopyRequest * copy_req_head
Doubly linked list of copy requests.
void * iterator_cls
Closure for iterator.
struct SetCopyRequest * copy_req_tail
Doubly linked list of copy requests.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration, needed when creating (lazy) copies.
Client acknowledges receiving element in iteration.
uint32_t send_more
Non-zero if the service should continue sending elements.
Set element transmitted by service to client in response to a set iteration request.
Opaque handle to a listen operation.
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
void * listen_cls
Closure for listen_cb.
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
struct GNUNET_HashCode app_id
Application ID we listen for.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
enum GNUNET_SET_OperationType operation
Operation we listen for.
struct GNUNET_MQ_Handle * mq
Message queue for the client.
GNUNET_SET_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Message sent by the client to the service to start listening for incoming requests to perform a certa...
struct GNUNET_SET_Handle * set
Local set used for the operation, NULL if no set has been provided by conclude yet.
GNUNET_SET_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...
void * result_cls
Closure for result_cb.
struct GNUNET_SET_OperationHandle * prev
Handles are kept in a linked list.
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_SET_OperationHandle * next
Handles are kept in a linked list.
Option for set operations.
union GNUNET_SET_Option::@30 v
Value for the option, only used with some options.
enum GNUNET_SET_OptionType type
Type of the option.
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_SET_Status in NBO.
Time for relative time used by GNUnet, in microseconds.
struct SetCopyRequest * prev
struct SetCopyRequest * next
GNUNET_SET_CopyReadyCallback cb