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 it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Christian M. Fuchs
21 * @author Gaurav Kukreja
24 * API to the scalarproduct service
26 * @defgroup scalarproduct Scalar Product service
30 #ifndef GNUNET_SCALARPRODUCT_SERVICE_H
31 #define GNUNET_SCALARPRODUCT_SERVICE_H
32 #define GCRYPT_NO_DEPRECATED
37 #if 0 /* keep Emacsens' auto-indent happy */
43 * Version of the scalarproduct API.
45 #define GNUNET_SCALARPRODUCT_VERSION 0x00000044
48 * Result status values for the computation.
50 enum GNUNET_SCALARPRODUCT_ResponseStatus
54 * Operation is still active (never returned, used internally).
56 GNUNET_SCALARPRODUCT_STATUS_INIT = 0,
59 * Operation is still active (never returned, used internally).
61 GNUNET_SCALARPRODUCT_STATUS_ACTIVE = 1,
64 * The computation was successful.
66 GNUNET_SCALARPRODUCT_STATUS_SUCCESS,
69 * We encountered some error.
71 GNUNET_SCALARPRODUCT_STATUS_FAILURE,
74 * We got an invalid response.
76 GNUNET_SCALARPRODUCT_STATUS_INVALID_RESPONSE,
79 * We got disconnected from the SCALARPRODUCT service.
81 GNUNET_SCALARPRODUCT_STATUS_DISCONNECTED
86 * Opaque declaration of the SP-Handle
88 struct GNUNET_SCALARPRODUCT_Handle;
91 GNUNET_NETWORK_STRUCT_BEGIN
94 * An element key-value pair for scalarproduct
96 struct GNUNET_SCALARPRODUCT_Element
99 * Key used to identify matching pairs of values to multiply.
101 struct GNUNET_HashCode key;
104 * Value to multiply in scalar product, in NBO.
106 int64_t value GNUNET_PACKED;
109 GNUNET_NETWORK_STRUCT_END
113 * Continuation called to notify client about result of the
117 * @param status Status of the request
120 (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
121 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
125 * Process a datum that was stored in the scalarproduct.
128 * @param status Status of the request
129 * @param result result of the computation
132 (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
133 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
138 * Entry in the request queue per client
140 struct GNUNET_SCALARPRODUCT_ComputationHandle;
144 * Request by Alice's client for computing a scalar product
146 * @param cfg the gnunet configuration handle
147 * @param session_key Session key should be unique to the requesting client
148 * @param peer PeerID of the other peer
149 * @param elements Array of elements of the vector
150 * @param element_count Number of elements in the @a elements vector
151 * @param cont Callback function
152 * @param cont_cls Closure for the @a cont callback function
153 * @return a new handle for this computation
155 struct GNUNET_SCALARPRODUCT_ComputationHandle *
156 GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
157 const struct GNUNET_HashCode *session_key,
158 const struct GNUNET_PeerIdentity *peer,
159 const struct GNUNET_SCALARPRODUCT_Element *elements,
160 uint32_t element_count,
161 GNUNET_SCALARPRODUCT_DatumProcessor cont,
166 * Used by Bob's client to cooperate with Alice,
168 * @param cfg the gnunet configuration handle
169 * @param session_key Session key unique to the requesting client
170 * @param elements Array of elements of the vector
171 * @param element_count Number of elements in the @a elements vector
172 * @param cont Callback function
173 * @param cont_cls Closure for the @a cont callback function
174 * @return a new handle for this computation
176 struct GNUNET_SCALARPRODUCT_ComputationHandle *
177 GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
178 const struct GNUNET_HashCode *key,
179 const struct GNUNET_SCALARPRODUCT_Element *elements,
180 uint32_t element_count,
181 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
186 * Cancel an ongoing computation or revoke our collaboration offer.
187 * Closes the connection to the service
189 * @param h computation handle to terminate
192 GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle *h);
195 #if 0 /* keep Emacsens' auto-indent happy */
204 /** @} */ /* end of group */