api for the set service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_set_service.h"
#include "set.h"
Go to the source code of this file.
Data Structures | |
struct | SetCopyRequest |
struct | GNUNET_SET_Handle |
Opaque handle to a set. More... | |
struct | GNUNET_SET_Request |
Handle for a set operation request from another peer. More... | |
struct | GNUNET_SET_OperationHandle |
Handle to an operation. More... | |
struct | GNUNET_SET_ListenHandle |
Opaque handle to a listen operation. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "set-api", __VA_ARGS__) |
Functions | |
static struct GNUNET_SET_Handle * | create_internal (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op, const uint32_t *cookie) |
FIXME. More... | |
static void | handle_copy_lazy (void *cls, const struct GNUNET_SET_CopyLazyResponseMessage *msg) |
Handle element for iteration over the set. More... | |
static int | check_iter_element (void *cls, const struct GNUNET_SET_IterResponseMessage *msg) |
Check that the given msg is well-formed. More... | |
static void | handle_iter_element (void *cls, const struct GNUNET_SET_IterResponseMessage *msg) |
Handle element for iteration over the set. More... | |
static void | handle_iter_done (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle message signalling conclusion of iteration over the set. More... | |
static int | check_result (void *cls, const struct GNUNET_SET_ResultMessage *msg) |
Check that the given msg is well-formed. More... | |
static void | handle_result (void *cls, const struct GNUNET_SET_ResultMessage *msg) |
Handle result message for a set operation. More... | |
static void | set_operation_destroy (struct GNUNET_SET_OperationHandle *oh) |
Destroy the given set operation. More... | |
void | GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh) |
Cancel the given set operation. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) |
Destroy the set handle if no operations are left, mark the set for destruction otherwise. More... | |
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. More... | |
static void | listen_connect (void *cls) |
Connect to the set service in order to listen for requests. More... | |
static int | check_request (void *cls, const struct GNUNET_SET_RequestMessage *msg) |
Check validity of request message for a listen operation. More... | |
static void | handle_request (void *cls, const struct GNUNET_SET_RequestMessage *msg) |
Handle request message for a listen operation. More... | |
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. More... | |
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. More... | |
void | GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) |
Cancel the given listen operation. More... | |
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(). More... | |
int | GNUNET_SET_commit (struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set) |
Commit a set to be used with a set operation. More... | |
int | GNUNET_SET_iterate (struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *iter_cls) |
Iterate over all elements in the given set. More... | |
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. More... | |
void | GNUNET_SET_element_hash (const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash) |
Hash a set element. More... | |
api for the set service
Definition in file set_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "set-api", __VA_ARGS__) |
|
static |
FIXME.
Definition at line 582 of file set_api.c.
References cfg, GNUNET_SET_Handle::cfg, GNUNET_SET_CopyLazyConnectMessage::cookie, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE, GNUNET_MESSAGE_TYPE_SET_CREATE, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, GNUNET_MESSAGE_TYPE_SET_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, handle_client_set_error(), LOG, GNUNET_SET_Handle::mq, op, GNUNET_SET_CreateMessage::operation, and result.
Referenced by GNUNET_SET_create(), and handle_copy_lazy().
|
static |
Handle element for iteration over the set.
Notifies the iterator and sends an acknowledgement to the service.
cls | the struct GNUNET_SET_Handle * |
msg | the message |
Definition at line 248 of file set_api.c.
References SetCopyRequest::cb, GNUNET_SET_Handle::cfg, SetCopyRequest::cls, GNUNET_SET_Handle::copy_req_head, GNUNET_SET_Handle::copy_req_tail, create_internal(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_SET_OPERATION_NONE, LOG, and msg.
|
static |
|
static |
Handle element for iteration over the set.
Notifies the iterator and sends an acknowledgement to the service.
cls | the struct GNUNET_SET_Handle * |
msg | the message |
Definition at line 302 of file set_api.c.
References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_ITER_ACK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SET_Handle::iteration_id, GNUNET_SET_Handle::iterator, GNUNET_SET_Handle::iterator_cls, LOG, GNUNET_SET_Handle::mq, msg, GNUNET_SET_IterAckMessage::send_more, GNUNET_MessageHeader::size, and GNUNET_SET_Element::size.
|
static |
Handle message signalling conclusion of iteration over the set.
Notifies the iterator that we are done.
cls | the set |
mh | the message |
Definition at line 343 of file set_api.c.
References GNUNET_SET_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_NO, GNUNET_SET_destroy(), GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::iteration_id, GNUNET_SET_Handle::iterator, GNUNET_SET_Handle::iterator_cls, and LOG.
|
static |
|
static |
Handle result message for a set operation.
cls | the set |
mh | the message |
Definition at line 394 of file set_api.c.
References GNUNET_SET_Element::data, GNUNET_SET_Handle::destroy_requested, GNUNET_SET_Element::element_type, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MQ_assoc_get(), GNUNET_MQ_assoc_remove(), GNUNET_ntohll(), GNUNET_SET_destroy(), GNUNET_SET_STATUS_ADD_LOCAL, GNUNET_SET_STATUS_ADD_REMOTE, GNUNET_SET_STATUS_DONE, GNUNET_SET_STATUS_FAILURE, GNUNET_SET_STATUS_HALF_DONE, GNUNET_SET_STATUS_OK, GNUNET_YES, LOG, GNUNET_SET_Handle::mq, msg, GNUNET_SET_Handle::ops_head, GNUNET_SET_Handle::ops_tail, GNUNET_SET_OperationHandle::result_cb, GNUNET_SET_OperationHandle::result_cls, GNUNET_SET_ResultMessage::result_status, GNUNET_MessageHeader::size, and GNUNET_SET_Element::size.
|
static |
Destroy the given set operation.
oh | set operation to destroy |
Definition at line 486 of file set_api.c.
References GNUNET_SET_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_assoc_remove(), GNUNET_MQ_discard(), GNUNET_SET_Handle::mq, GNUNET_SET_Handle::ops_head, GNUNET_SET_Handle::ops_tail, GNUNET_SET_OperationHandle::request_id, and GNUNET_SET_OperationHandle::set.
Referenced by GNUNET_SET_operation_cancel(), and handle_client_set_error().
|
static |
We encountered an error communicating with the set service while performing a set operation.
Report to the application.
cls | the struct GNUNET_SET_Handle |
error | error code |
Definition at line 550 of file set_api.c.
References GNUNET_SET_Handle::destroy_requested, GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_SET_STATUS_FAILURE, GNUNET_YES, GNUNET_SET_Handle::invalid, GNUNET_SET_Handle::iteration_id, GNUNET_SET_Handle::iterator, GNUNET_SET_Handle::iterator_cls, LOG, GNUNET_SET_Handle::ops_head, GNUNET_SET_OperationHandle::result_cb, GNUNET_SET_OperationHandle::result_cls, and set_operation_destroy().
Referenced by create_internal().
|
static |
Connect to the set service in order to listen for requests.
cls | the struct GNUNET_SET_ListenHandle * to connect |
Definition at line 933 of file set_api.c.
References GNUNET_SET_ListenHandle::app_id, GNUNET_SET_ListenHandle::cfg, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_SET_LISTEN, GNUNET_MESSAGE_TYPE_SET_REQUEST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handle_client_listener_error(), GNUNET_SET_ListenHandle::mq, msg, GNUNET_SET_ListenHandle::operation, GNUNET_SET_ListenHandle::reconnect_task, and request.
Referenced by GNUNET_SET_listen(), and handle_client_listener_error().
|
static |
Check validity of request message for a listen operation.
cls | the listen handle |
msg | the message |
Definition at line 843 of file set_api.c.
References GNUNET_break_op, GNUNET_MQ_extract_nested_mh, GNUNET_OK, GNUNET_SYSERR, msg, and GNUNET_MessageHeader::size.
|
static |
Handle request message for a listen operation.
cls | the listen handle |
msg | the message |
Definition at line 868 of file set_api.c.
References GNUNET_SET_Request::accept_id, GNUNET_SET_RejectMessage::accept_reject_id, GNUNET_SET_Request::accepted, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_REJECT, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, GNUNET_SET_ListenHandle::listen_cb, GNUNET_SET_ListenHandle::listen_cls, LOG, GNUNET_SET_ListenHandle::mq, msg, and GNUNET_SET_ListenHandle::reconnect_backoff.
|
static |
Our connection with the set service encountered an error, re-initialize with exponential back-off.
cls | the struct GNUNET_SET_ListenHandle * |
error | reason for the disconnect |
Definition at line 910 of file set_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, listen_connect(), LOG, GNUNET_SET_ListenHandle::mq, GNUNET_SET_ListenHandle::reconnect_backoff, and GNUNET_SET_ListenHandle::reconnect_task.
Referenced by listen_connect().