api for the set service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_seti_service.h"
#include "seti.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_SETI_Handle |
Opaque handle to a set. More... | |
struct | GNUNET_SETI_Request |
Handle for a set operation request from another peer. More... | |
struct | GNUNET_SETI_OperationHandle |
Handle to an operation. More... | |
struct | GNUNET_SETI_ListenHandle |
Opaque handle to a listen operation. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "seti-api", __VA_ARGS__) |
Functions | |
static int | check_result (void *cls, const struct GNUNET_SETI_ResultMessage *msg) |
Check that the given msg is well-formed. More... | |
static void | handle_result (void *cls, const struct GNUNET_SETI_ResultMessage *msg) |
Handle result message for a set operation. More... | |
static void | set_operation_destroy (struct GNUNET_SETI_OperationHandle *oh) |
Destroy the given set operation. More... | |
void | GNUNET_SETI_operation_cancel (struct GNUNET_SETI_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_SETI_Handle * | GNUNET_SETI_create (const struct GNUNET_CONFIGURATION_Handle *cfg) |
Create an empty set. More... | |
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. More... | |
void | GNUNET_SETI_destroy (struct GNUNET_SETI_Handle *set) |
Destroy the set handle if no operations are left, mark the set for destruction otherwise. More... | |
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. 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_SETI_RequestMessage *msg) |
Check validity of request message for a listen operation. More... | |
static void | handle_request (void *cls, const struct GNUNET_SETI_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_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. More... | |
void | GNUNET_SETI_listen_cancel (struct GNUNET_SETI_ListenHandle *lh) |
Cancel the given listen operation. More... | |
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(). More... | |
int | GNUNET_SETI_commit (struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set) |
Commit a set to be used with a set operation. More... | |
void | GNUNET_SETI_element_hash (const struct GNUNET_SETI_Element *element, struct GNUNET_HashCode *ret_hash) |
Hash a set element. More... | |
api for the set service
Definition in file seti_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "seti-api", __VA_ARGS__) |
Definition at line 33 of file seti_api.c.
|
static |
Check that the given msg is well-formed.
cls | closure |
msg | message to check |
Definition at line 213 of file seti_api.c.
References GNUNET_OK.
|
static |
Handle result message for a set operation.
cls | the set |
mh | the message |
Definition at line 228 of file seti_api.c.
References GNUNET_SETI_Element::data, GNUNET_SETI_Handle::destroy_requested, GNUNET_SETI_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_SETI_destroy(), GNUNET_SETI_STATUS_ADD_LOCAL, GNUNET_SETI_STATUS_DEL_LOCAL, GNUNET_SETI_STATUS_DONE, GNUNET_SETI_STATUS_FAILURE, GNUNET_YES, LOG, GNUNET_SETI_Handle::mq, msg, GNUNET_SETI_Handle::ops_head, GNUNET_SETI_Handle::ops_tail, GNUNET_SETI_OperationHandle::result_cb, GNUNET_SETI_OperationHandle::result_cls, GNUNET_SETI_ResultMessage::result_status, GNUNET_MessageHeader::size, and GNUNET_SETI_Element::size.
|
static |
Destroy the given set operation.
oh | set operation to destroy |
Definition at line 305 of file seti_api.c.
References GNUNET_SETI_OperationHandle::conclude_mqm, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_assoc_remove(), GNUNET_MQ_discard(), GNUNET_SETI_Handle::mq, GNUNET_SETI_Handle::ops_head, GNUNET_SETI_Handle::ops_tail, GNUNET_SETI_OperationHandle::request_id, and GNUNET_SETI_OperationHandle::set.
Referenced by GNUNET_SETI_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_SETI_Handle |
error | error code |
Definition at line 369 of file seti_api.c.
References GNUNET_SETI_Handle::destroy_requested, GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_SETI_STATUS_FAILURE, GNUNET_YES, GNUNET_SETI_Handle::invalid, LOG, GNUNET_SETI_Handle::ops_head, GNUNET_SETI_OperationHandle::result_cb, GNUNET_SETI_OperationHandle::result_cls, and set_operation_destroy().
Referenced by GNUNET_SETI_create().
|
static |
Connect to the set service in order to listen for requests.
cls | the struct GNUNET_SETI_ListenHandle * to connect |
Definition at line 661 of file seti_api.c.
References GNUNET_SETI_ListenHandle::app_id, GNUNET_SETI_ListenHandle::cfg, GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_SETI_LISTEN, GNUNET_MESSAGE_TYPE_SETI_REQUEST, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), handle_client_listener_error(), GNUNET_SETI_ListenHandle::mq, msg, GNUNET_SETI_ListenHandle::reconnect_task, and request.
Referenced by GNUNET_SETI_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 570 of file seti_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 595 of file seti_api.c.
References GNUNET_SETI_Request::accept_id, GNUNET_SETI_RejectMessage::accept_reject_id, GNUNET_SETI_Request::accepted, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETI_REJECT, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_YES, GNUNET_SETI_ListenHandle::listen_cb, GNUNET_SETI_ListenHandle::listen_cls, LOG, GNUNET_SETI_ListenHandle::mq, msg, and GNUNET_SETI_ListenHandle::reconnect_backoff.
|
static |
Our connection with the set service encountered an error, re-initialize with exponential back-off.
cls | the struct GNUNET_SETI_ListenHandle * |
error | reason for the disconnect |
Definition at line 638 of file seti_api.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, listen_connect(), LOG, GNUNET_SETI_ListenHandle::mq, GNUNET_SETI_ListenHandle::reconnect_backoff, and GNUNET_SETI_ListenHandle::reconnect_task.
Referenced by listen_connect().