26#define GCRYPT_NO_DEPRECATED
36#define LOG(kind, ...) GNUNET_log_from (kind, "gnunet-scalarproduct", \
91 "Session %s concluded.\n",
97 "Session %s failed: invalid response\n",
103 "Session %s failed: service failure\n",
109 "Session %s failed: service disconnect!\n",
115 "Session %s failed: return code %d\n",
142 if (0 == (rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buf, NULL,
result)))
158 "Session %s with peer %s failed: invalid response received\n",
165 "Session %s with peer %s failed: API failure\n",
172 "Session %s with peer %s was disconnected from service.\n",
179 "Session %s with peer %s failed: return code %d\n",
223 uint32_t element_count = 0;
228 _ (
"You must specify at least one message ID to check!\n"));
236 "This program needs a session identifier for comparing vectors.\n"));
249 _ (
"Tried to set initiator mode, as peer ID was given. "
250 "However, `%s' is not a valid peer identifier.\n"),
254 if ((
'\'' == *begin) &&
255 (
'\'' == begin[strlen (begin) - 1]))
257 begin[strlen (begin) - 1] =
'\0';
258 if (strlen (begin) > 0)
264 if (0 == element_count)
267 _ (
"Need elements to compute the scalarproduct, got none.\n"));
274 for (i = 0; i < element_count; i++)
277 char*separator = NULL;
285 if ((NULL == separator) ||
286 (begin == separator) ||
287 (separator ==
end - 1))
290 _ (
"Malformed input, could not parse `%s'\n"),
303 sscanf (separator + 1,
308 _ (
"Could not convert `%s' to int64_t.\n"),
314 elements[i] = element;
339 _ (
"Failed to initiate computation, were all keys unique?\n"));
358main (
int argc,
char *
const *argv)
363 "\"key1,val1;key2,val2;...,keyn,valn;\"",
365 "A comma separated list of elements to compare as vector with our remote peer."),
370 "\"key1,val1;key2,val2;...,keyn,valn;\"",
372 "A comma separated list of elements to compare as vector with our remote peer."),
379 "[Optional] peer to calculate our scalarproduct with. If this parameter is not given, the service will wait for a remote peer to compute the request."),
386 "Transaction ID shared with peer."),
396 "gnunet-scalarproduct",
398 "Calculate the Vectorproduct with a GNUnet peer."),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static int end
Set if we are to shutdown all services (including ARM).
static int status
The program status; 0 for success.
static int result
Global testing status.
static struct GNUNET_HashCode session_key
the session key identifying this computation
static char * input_elements
Option -e: vector to calculate a scalarproduct with.
static void shutdown_task(void *cls)
Task run during shutdown.
static int ret
Global return value.
static char * input_peer_id
Option -p: destination peer identity for checking message-ids with.
static char * input_session_key
Option -p: destination peer identity for checking message-ids with.
static void responder_callback(void *cls, enum GNUNET_SCALARPRODUCT_ResponseStatus status)
Callback called if we are initiating a new computation session.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
static struct GNUNET_PeerIdentity peer_id
PeerID we want to compute a scalar product with.
static void requester_callback(void *cls, enum GNUNET_SCALARPRODUCT_ResponseStatus status, gcry_mpi_t result)
Callback called if we are initiating a new computation session.
int main(int argc, char *const *argv)
The main function to the scalarproduct client.
static struct GNUNET_SCALARPRODUCT_ComputationHandle * computation
our Scalarproduct Computation handle
Constants for network protocols.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
GNUNET_SCALARPRODUCT_ResponseStatus
Result status values for the computation.
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.
void GNUNET_SCALARPRODUCT_cancel(struct GNUNET_SCALARPRODUCT_ComputationHandle *h)
Cancel an ongoing computation or revoke our collaboration offer.
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,.
@ GNUNET_SCALARPRODUCT_STATUS_SUCCESS
The computation was successful.
@ GNUNET_SCALARPRODUCT_STATUS_FAILURE
We encountered some error.
@ GNUNET_SCALARPRODUCT_STATUS_DISCONNECTED
We got disconnected from the SCALARPRODUCT service.
@ GNUNET_SCALARPRODUCT_STATUS_INVALID_RESPONSE
We got an invalid response.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Scalar Product API Message Types.
#define LOG_GCRY(level, cmd, rc)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
Definition of a command line option.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
A handle returned for each computation.
An element key-value pair for scalarproduct.
struct GNUNET_HashCode key
Key used to identify matching pairs of values to multiply.
int64_t value
Value to multiply in scalar product, in NBO.