#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_setu_service.h"
#include "setu.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_SETU_Handle |
Opaque handle to a set. More... | |
struct | GNUNET_SETU_Request |
Handle for a set operation request from another peer. More... | |
struct | GNUNET_SETU_OperationHandle |
Handle to an operation. More... | |
struct | GNUNET_SETU_ListenHandle |
Opaque handle to a listen operation. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "set-api", __VA_ARGS__) |
Functions | |
static int | check_result (void *cls, const struct GNUNET_SETU_ResultMessage *msg) |
Check that the given msg is well-formed. More... | |
static void | handle_result (void *cls, const struct GNUNET_SETU_ResultMessage *msg) |
Handle result message for a set operation. More... | |
static void | set_operation_destroy (struct GNUNET_SETU_OperationHandle *oh) |
Destroy the given set operation. More... | |
void | GNUNET_SETU_operation_cancel (struct GNUNET_SETU_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_SETU_Handle * | GNUNET_SETU_create (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Create an empty set, supporting the specified operation. More... | |
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. More... | |
void | GNUNET_SETU_destroy (struct GNUNET_SETU_Handle *set) |
Destroy the set handle if no operations are left, mark the set for destruction otherwise. More... | |
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. 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_SETU_RequestMessage *msg) |
Check validity of request message for a listen operation. More... | |
static void | handle_request (void *cls, const struct GNUNET_SETU_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_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. More... | |
void | GNUNET_SETU_listen_cancel (struct GNUNET_SETU_ListenHandle *lh) |
Cancel the given listen operation. More... | |
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(). More... | |
int | GNUNET_SETU_commit (struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set) |
Commit a set to be used with a set operation. More... | |
void | GNUNET_SETU_element_hash (const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash) |
Hash a set element. More... | |
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "set-api", __VA_ARGS__) |
Definition at line 34 of file setu_api.c.
|
static |
Check that the given msg is well-formed.
cls | closure |
msg | message to check |
Definition at line 196 of file setu_api.c.
References GNUNET_OK.
|
static |
Handle result message for a set operation.
cls | the set |
mh | the message |
Definition at line 211 of file setu_api.c.
References GNUNET_SETU_Element::data, GNUNET_SETU_Handle::destroy_requested, GNUNET_SETU_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_SETU_destroy(), GNUNET_SETU_STATUS_ADD_LOCAL, GNUNET_SETU_STATUS_ADD_REMOTE, GNUNET_SETU_STATUS_DONE, GNUNET_SETU_STATUS_FAILURE, GNUNET_YES, LOG, GNUNET_SETU_Handle::mq, msg, GNUNET_SETU_Handle::ops_head, GNUNET_SETU_Handle::ops_tail, GNUNET_SETU_OperationHandle::result_cb, GNUNET_SETU_OperationHandle::result_cls, GNUNET_SETU_ResultMessage::result_status, GNUNET_MessageHeader::size, and GNUNET_SETU_Element::size.
|
static |
Destroy the given set operation.
oh | set operation to destroy |
Definition at line 290 of file setu_api.c.
References GNUNET_SETU_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_assoc_remove(), GNUNET_MQ_discard(), GNUNET_SETU_Handle::mq, GNUNET_SETU_Handle::ops_head, GNUNET_SETU_Handle::ops_tail, GNUNET_SETU_OperationHandle::request_id, and GNUNET_SETU_OperationHandle::set.
Referenced by GNUNET_SETU_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_SETU_Handle |
error | error code |
Definition at line 354 of file setu_api.c.
References GNUNET_SETU_Handle::destroy_requested, GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_SETU_STATUS_FAILURE, GNUNET_YES, GNUNET_SETU_Handle::invalid, LOG, GNUNET_SETU_Handle::ops_head, GNUNET_SETU_OperationHandle::result_cb, GNUNET_SETU_OperationHandle::result_cls, and set_operation_destroy().
Referenced by GNUNET_SETU_create().
|
static |
Connect to the set service in order to listen for requests.
cls | the struct GNUNET_SETU_ListenHandle * to connect |
Definition at line 675 of file setu_api.c.
References GNUNET_SETU_ListenHandle::app_id, GNUNET_SETU_ListenHandle::cfg, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_SETU_LISTEN, GNUNET_MESSAGE_TYPE_SETU_REQUEST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handle_client_listener_error(), GNUNET_SETU_ListenHandle::mq, msg, GNUNET_SETU_ListenHandle::reconnect_task, and request.
Referenced by GNUNET_SETU_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 584 of file setu_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 609 of file setu_api.c.
References GNUNET_SETU_Request::accept_id, GNUNET_SETU_RejectMessage::accept_reject_id, GNUNET_SETU_Request::accepted, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETU_REJECT, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, GNUNET_SETU_ListenHandle::listen_cb, GNUNET_SETU_ListenHandle::listen_cls, LOG, GNUNET_SETU_ListenHandle::mq, msg, and GNUNET_SETU_ListenHandle::reconnect_backoff.
|
static |
Our connection with the set service encountered an error, re-initialize with exponential back-off.
cls | the struct GNUNET_SETU_ListenHandle * |
error | reason for the disconnect |
Definition at line 652 of file setu_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, listen_connect(), LOG, GNUNET_SETU_ListenHandle::mq, GNUNET_SETU_ListenHandle::reconnect_backoff, and GNUNET_SETU_ListenHandle::reconnect_task.
Referenced by listen_connect().