API for the scalarproduct. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_scalarproduct_service.h"
#include "gnunet_protocols.h"
#include "scalarproduct.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_SCALARPRODUCT_ComputationHandle |
A handle returned for each computation. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "scalarproduct-api", __VA_ARGS__) |
Typedefs | |
typedef void(* | GNUNET_SCALARPRODUCT_ResponseMessageHandler) (struct GNUNET_SCALARPRODUCT_ComputationHandle *h, const struct ClientResponseMessage *msg, enum GNUNET_SCALARPRODUCT_ResponseStatus status) |
The abstraction function for our internal callback. More... | |
Functions | |
static int | check_response (void *cls, const struct ClientResponseMessage *message) |
Called when a response is received from the service. More... | |
static void | process_status_message (struct GNUNET_SCALARPRODUCT_ComputationHandle *h, const struct ClientResponseMessage *msg, enum GNUNET_SCALARPRODUCT_ResponseStatus status) |
Handles the STATUS received from the service for a response, does not contain a payload. More... | |
static void | handle_response (void *cls, const struct ClientResponseMessage *message) |
Called when a response is received from the service. More... | |
static int | check_unique (const struct GNUNET_SCALARPRODUCT_Element *elements, uint32_t element_count) |
Check if the keys for all given elements are unique. More... | |
static void | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
We encountered an error communicating with the set service while performing a set operation. More... | |
struct GNUNET_SCALARPRODUCT_ComputationHandle * | GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *session_key, const struct GNUNET_SCALARPRODUCT_Element *elements, uint32_t element_count, GNUNET_SCALARPRODUCT_ContinuationWithStatus cont, void *cont_cls) |
Used by Bob's client to cooperate with Alice,. More... | |
static void | process_result_message (struct GNUNET_SCALARPRODUCT_ComputationHandle *h, const struct ClientResponseMessage *msg, enum GNUNET_SCALARPRODUCT_ResponseStatus status) |
Handles the RESULT received from the service for a request, should contain a result MPI value. More... | |
struct GNUNET_SCALARPRODUCT_ComputationHandle * | GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *session_key, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_SCALARPRODUCT_Element *elements, uint32_t element_count, GNUNET_SCALARPRODUCT_DatumProcessor cont, void *cont_cls) |
Request by Alice's client for computing a scalar product. More... | |
void | GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle *h) |
Cancel an ongoing computation or revoke our collaboration offer. More... | |
API for the scalarproduct.
Definition in file scalarproduct_api.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "scalarproduct-api", __VA_ARGS__) |
Definition at line 34 of file scalarproduct_api.c.
typedef void(* GNUNET_SCALARPRODUCT_ResponseMessageHandler) (struct GNUNET_SCALARPRODUCT_ComputationHandle *h, const struct ClientResponseMessage *msg, enum GNUNET_SCALARPRODUCT_ResponseStatus status) |
The abstraction function for our internal callback.
h | computation handle |
msg | response we got, NULL on errors |
status | processing status code |
Definition at line 44 of file scalarproduct_api.c.
|
static |
Called when a response is received from the service.
Perform basic check that the message is well-formed.
cls | Pointer to the Master Context |
message | Pointer to the data received in response |
Definition at line 103 of file scalarproduct_api.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, ClientResponseMessage::header, ClientResponseMessage::product_length, and GNUNET_MessageHeader::size.
|
static |
Handles the STATUS received from the service for a response, does not contain a payload.
Called when we participate as "Bob" via GNUNET_SCALARPRODUCT_accept_computation().
h | our Handle |
msg | the response received |
status | the condition the request was terminated with (eg: disconnect) |
Definition at line 126 of file scalarproduct_api.c.
References GNUNET_SCALARPRODUCT_cancel(), h, and status.
Referenced by GNUNET_SCALARPRODUCT_accept_computation().
|
static |
Called when a response is received from the service.
After basic check, the handler in h->response_proc
is called. This functions handles the response to the client which used the API.
cls | Pointer to the Master Context |
message | Pointer to the data received in response |
Definition at line 146 of file scalarproduct_api.c.
References h, status, and ClientResponseMessage::status.
|
static |
Check if the keys for all given elements are unique.
elements | elements to check |
element_count | size of the elements array |
Definition at line 167 of file scalarproduct_api.c.
References _, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, key, and map.
Referenced by GNUNET_SCALARPRODUCT_accept_computation(), and GNUNET_SCALARPRODUCT_start_computation().
|
static |
We encountered an error communicating with the set service while performing a set operation.
Report to the application.
cls | the struct GNUNET_SCALARPRODUCT_ComputationHandle |
error | error code |
Definition at line 200 of file scalarproduct_api.c.
References GNUNET_ERROR_TYPE_INFO, GNUNET_SCALARPRODUCT_STATUS_DISCONNECTED, h, and LOG.
Referenced by GNUNET_SCALARPRODUCT_accept_computation(), and GNUNET_SCALARPRODUCT_start_computation().
|
static |
Handles the RESULT received from the service for a request, should contain a result MPI value.
Called when we participate as "Alice" via GNUNET_SCALARPRODUCT_start_computation().
h | our Handle |
msg | Pointer to the response received |
status | the condition the request was terminated with (eg: disconnect) |
Definition at line 310 of file scalarproduct_api.c.
References GNUNET_ERROR_TYPE_ERROR, GNUNET_SCALARPRODUCT_cancel(), GNUNET_SCALARPRODUCT_STATUS_INVALID_RESPONSE, GNUNET_SCALARPRODUCT_STATUS_SUCCESS, h, LOG_GCRY, msg, result, and status.
Referenced by GNUNET_SCALARPRODUCT_start_computation().