2 This file is part of GNUnet.
3 Copyright (C) 2013, 2014 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file include/gnunet_scalarproduct_service.h
23 * @brief API to the scalarproduct service
24 * @author Christian M. Fuchs
25 * @author Gaurav Kukreja
27 #ifndef GNUNET_SCALARPRODUCT_SERVICE_H
28 #define GNUNET_SCALARPRODUCT_SERVICE_H
29 #define GCRYPT_NO_DEPRECATED
34 #if 0 /* keep Emacsens' auto-indent happy */
40 * Version of the scalarproduct API.
42 #define GNUNET_SCALARPRODUCT_VERSION 0x00000044
45 * Result status values for the computation.
47 enum GNUNET_SCALARPRODUCT_ResponseStatus
51 * Operation is still active (never returned, used internally).
53 GNUNET_SCALARPRODUCT_STATUS_ACTIVE = 0,
56 * The computation was successful.
58 GNUNET_SCALARPRODUCT_STATUS_SUCCESS,
61 * We encountered some error.
63 GNUNET_SCALARPRODUCT_STATUS_FAILURE,
66 * We got an invalid response.
68 GNUNET_SCALARPRODUCT_STATUS_INVALID_RESPONSE,
71 * We got disconnected from the SCALARPRODUCT service.
73 GNUNET_SCALARPRODUCT_STATUS_DISCONNECTED
78 * Opaque declaration of the SP-Handle
80 struct GNUNET_SCALARPRODUCT_Handle;
83 GNUNET_NETWORK_STRUCT_BEGIN
86 * An element key-value pair for scalarproduct
88 struct GNUNET_SCALARPRODUCT_Element
91 * Key used to identify matching pairs of values to multiply.
93 struct GNUNET_HashCode key;
96 * Value to multiply in scalar product, in NBO.
98 int64_t value GNUNET_PACKED;
101 GNUNET_NETWORK_STRUCT_END
105 * Continuation called to notify client about result of the
109 * @param status Status of the request
112 (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
113 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
117 * Process a datum that was stored in the scalarproduct.
120 * @param status Status of the request
121 * @param result result of the computation
124 (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
125 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
130 * Entry in the request queue per client
132 struct GNUNET_SCALARPRODUCT_ComputationHandle;
136 * Request by Alice's client for computing a scalar product
138 * @param cfg the gnunet configuration handle
139 * @param session_key Session key should be unique to the requesting client
140 * @param peer PeerID of the other peer
141 * @param elements Array of elements of the vector
142 * @param element_count Number of elements in the @a elements vector
143 * @param cont Callback function
144 * @param cont_cls Closure for the @a cont callback function
145 * @return a new handle for this computation
147 struct GNUNET_SCALARPRODUCT_ComputationHandle *
148 GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
149 const struct GNUNET_HashCode *session_key,
150 const struct GNUNET_PeerIdentity *peer,
151 const struct GNUNET_SCALARPRODUCT_Element *elements,
152 uint32_t element_count,
153 GNUNET_SCALARPRODUCT_DatumProcessor cont,
158 * Used by Bob's client to cooperate with Alice,
160 * @param cfg the gnunet configuration handle
161 * @param session_key Session key unique to the requesting client
162 * @param elements Array of elements of the vector
163 * @param element_count Number of elements in the @a elements vector
164 * @param cont Callback function
165 * @param cont_cls Closure for the @a cont callback function
166 * @return a new handle for this computation
168 struct GNUNET_SCALARPRODUCT_ComputationHandle *
169 GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
170 const struct GNUNET_HashCode *key,
171 const struct GNUNET_SCALARPRODUCT_Element *elements,
172 uint32_t element_count,
173 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
178 * Cancel an ongoing computation or revoke our collaboration offer.
179 * Closes the connection to the service
181 * @param h computation handle to terminate
184 GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle *h);
186 #if 0 /* keep Emacsens' auto-indent happy */