2 This file is part of GNUnet.
3 Copyright (C) 2013, 2014 GNUnet e.V.
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 * @author Christian M. Fuchs
23 * @author Gaurav Kukreja
26 * API to the scalarproduct service
28 * @defgroup scalarproduct Scalar Product service
32 #ifndef GNUNET_SCALARPRODUCT_SERVICE_H
33 #define GNUNET_SCALARPRODUCT_SERVICE_H
34 #define GCRYPT_NO_DEPRECATED
39 #if 0 /* keep Emacsens' auto-indent happy */
45 * Version of the scalarproduct API.
47 #define GNUNET_SCALARPRODUCT_VERSION 0x00000044
50 * Result status values for the computation.
52 enum GNUNET_SCALARPRODUCT_ResponseStatus
56 * Operation is still active (never returned, used internally).
58 GNUNET_SCALARPRODUCT_STATUS_INIT = 0,
61 * Operation is still active (never returned, used internally).
63 GNUNET_SCALARPRODUCT_STATUS_ACTIVE = 1,
66 * The computation was successful.
68 GNUNET_SCALARPRODUCT_STATUS_SUCCESS,
71 * We encountered some error.
73 GNUNET_SCALARPRODUCT_STATUS_FAILURE,
76 * We got an invalid response.
78 GNUNET_SCALARPRODUCT_STATUS_INVALID_RESPONSE,
81 * We got disconnected from the SCALARPRODUCT service.
83 GNUNET_SCALARPRODUCT_STATUS_DISCONNECTED
88 * Opaque declaration of the SP-Handle
90 struct GNUNET_SCALARPRODUCT_Handle;
93 GNUNET_NETWORK_STRUCT_BEGIN
96 * An element key-value pair for scalarproduct
98 struct GNUNET_SCALARPRODUCT_Element
101 * Key used to identify matching pairs of values to multiply.
103 struct GNUNET_HashCode key;
106 * Value to multiply in scalar product, in NBO.
108 int64_t value GNUNET_PACKED;
111 GNUNET_NETWORK_STRUCT_END
115 * Continuation called to notify client about result of the
119 * @param status Status of the request
122 (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
123 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
127 * Process a datum that was stored in the scalarproduct.
130 * @param status Status of the request
131 * @param result result of the computation
134 (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
135 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
140 * Entry in the request queue per client
142 struct GNUNET_SCALARPRODUCT_ComputationHandle;
146 * Request by Alice's client for computing a scalar product
148 * @param cfg the gnunet configuration handle
149 * @param session_key Session key should be unique to the requesting client
150 * @param peer PeerID of the other peer
151 * @param elements Array of elements of the vector
152 * @param element_count Number of elements in the @a elements vector
153 * @param cont Callback function
154 * @param cont_cls Closure for the @a cont callback function
155 * @return a new handle for this computation
157 struct GNUNET_SCALARPRODUCT_ComputationHandle *
158 GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
159 const struct GNUNET_HashCode *session_key,
160 const struct GNUNET_PeerIdentity *peer,
161 const struct GNUNET_SCALARPRODUCT_Element *elements,
162 uint32_t element_count,
163 GNUNET_SCALARPRODUCT_DatumProcessor cont,
168 * Used by Bob's client to cooperate with Alice,
170 * @param cfg the gnunet configuration handle
171 * @param session_key Session key unique to the requesting client
172 * @param elements Array of elements of the vector
173 * @param element_count Number of elements in the @a elements vector
174 * @param cont Callback function
175 * @param cont_cls Closure for the @a cont callback function
176 * @return a new handle for this computation
178 struct GNUNET_SCALARPRODUCT_ComputationHandle *
179 GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
180 const struct GNUNET_HashCode *key,
181 const struct GNUNET_SCALARPRODUCT_Element *elements,
182 uint32_t element_count,
183 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
188 * Cancel an ongoing computation or revoke our collaboration offer.
189 * Closes the connection to the service
191 * @param h computation handle to terminate
194 GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle *h);
197 #if 0 /* keep Emacsens' auto-indent happy */
206 /** @} */ /* end of group */