2 This file is part of GNUnet.
3 (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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, 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
50 * The computation was successful.
52 GNUNET_SCALARPRODUCT_Status_Success = 0,
55 * We encountered some error.
57 GNUNET_SCALARPRODUCT_Status_Failure,
60 * We got an invalid response.
62 GNUNET_SCALARPRODUCT_Status_InvalidResponse,
65 * We got disconnected from the SCALARPRODUCT service.
67 GNUNET_SCALARPRODUCT_Status_ServiceDisconnected
72 * Opaque declaration of the SP-Handle
74 struct GNUNET_SCALARPRODUCT_Handle;
77 GNUNET_NETWORK_STRUCT_BEGIN
80 * An element key-value pair for scalarproduct
82 struct GNUNET_SCALARPRODUCT_Element
85 * Key used to identify matching pairs of values to multiply.
87 struct GNUNET_HashCode key;
90 * Value to multiply in scalar product.
92 int64_t value GNUNET_PACKED;
95 GNUNET_NETWORK_STRUCT_END
99 * Continuation called to notify client about result of the
103 * @param status Status of the request
106 (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
107 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
111 * Process a datum that was stored in the scalarproduct.
114 * @param status Status of the request
115 * @param result result of the computation
118 (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
119 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
124 * Entry in the request queue per client
126 struct GNUNET_SCALARPRODUCT_ComputationHandle;
130 * Request by Alice's client for computing a scalar product
132 * @param cfg the gnunet configuration handle
133 * @param session_key Session key should be unique to the requesting client
134 * @param peer PeerID of the other peer
135 * @param elements Array of elements of the vector
136 * @param element_count Number of elements in the @a elements vector
137 * @param cont Callback function
138 * @param cont_cls Closure for the @a cont callback function
139 * @return a new handle for this computation
141 struct GNUNET_SCALARPRODUCT_ComputationHandle *
142 GNUNET_SCALARPRODUCT_start_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
143 const struct GNUNET_HashCode *session_key,
144 const struct GNUNET_PeerIdentity *peer,
145 const struct GNUNET_SCALARPRODUCT_Element *elements,
146 uint32_t element_count,
147 GNUNET_SCALARPRODUCT_DatumProcessor cont,
152 * Used by Bob's client to cooperate with Alice,
154 * @param cfg the gnunet configuration handle
155 * @param session_key Session key unique to the requesting client
156 * @param elements Array of elements of the vector
157 * @param element_count Number of elements in the @a elements vector
158 * @param cont Callback function
159 * @param cont_cls Closure for the @a cont callback function
160 * @return a new handle for this computation
162 struct GNUNET_SCALARPRODUCT_ComputationHandle *
163 GNUNET_SCALARPRODUCT_accept_computation (const struct GNUNET_CONFIGURATION_Handle *cfg,
164 const struct GNUNET_HashCode *key,
165 const struct GNUNET_SCALARPRODUCT_Element *elements,
166 uint32_t element_count,
167 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
172 * Cancel an ongoing computation or revoke our collaboration offer.
173 * Closes the connection to the service
175 * @param h computation handle to terminate
178 GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle *h);
180 #if 0 /* keep Emacsens' auto-indent happy */