2 This file is part of GNUnet.
3 (C) 2013 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
30 // including gcrypt crashes netbeans after the next restart...
35 #if 0 /* keep Emacsens' auto-indent happy */
41 * Version of the scalarproduct API.
43 #define GNUNET_SCALARPRODUCT_VERSION 0x00000042
45 enum GNUNET_SCALARPRODUCT_ResponseStatus
47 GNUNET_SCALARPRODUCT_Status_Success = 0,
48 GNUNET_SCALARPRODUCT_Status_Failure,
49 GNUNET_SCALARPRODUCT_Status_Timeout,
50 GNUNET_SCALARPRODUCT_Status_InvalidResponse,
51 GNUNET_SCALARPRODUCT_Status_ServiceDisconnected
54 struct GNUNET_SCALARPRODUCT_Handle
59 const struct GNUNET_CONFIGURATION_Handle *cfg;
62 * Current connection to the scalarproduct service.
64 struct GNUNET_CLIENT_Connection *client;
67 * Handle for statistics.
69 struct GNUNET_STATISTICS_Handle *stats;
72 * Current transmit handle.
74 struct GNUNET_CLIENT_TransmitHandle *th;
77 * Handle to the master context.
79 struct GNUNET_SCALARPRODUCT_Handle *h;
82 * The shared session key identifying this computation
84 struct GNUNET_HashCode * key;
87 * The message to be transmitted
94 * Function to call after transmission of the request.
96 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status;
99 * Function to call after transmission of the request.
101 GNUNET_SCALARPRODUCT_DatumProcessor cont_datum;
105 * Closure for 'cont'.
110 * Response Processor for response from the service. This function calls the
111 * continuation function provided by the client.
113 GNUNET_SCALARPRODUCT_ResponseMessageHandler response_proc;
116 typedef void (*GNUNET_SCALARPRODUCT_ResponseMessageHandler) (void *cls,
117 const struct GNUNET_MessageHeader *msg,
118 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
121 * Continuation called to notify client about result of the
125 * @param status Status of the request
127 typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
128 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
130 * Process a datum that was stored in the scalarproduct.
133 * @param status Status of the request
134 * @param type result of the computation
136 typedef void (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
137 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
141 * Request by Alice's client for computing a scalar product
143 * @param h handle to the master context
144 * @param key Session key - unique to the requesting client
145 * @param peer PeerID of the other peer
146 * @param elements Array of elements of the vector
147 * @param element_count Number of elements in the vector
148 * @param mask Array of the mask
149 * @param mask_bytes number of bytes in the mask
150 * @param cont Callback function
151 * @param cont_cls Closure for the callback function
153 struct GNUNET_SCALARPRODUCT_Handle *
154 GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *h,
155 const struct GNUNET_HashCode * key,
156 const struct GNUNET_PeerIdentity *peer,
157 const int32_t * elements,
158 uint32_t element_count,
159 const unsigned char * mask,
161 GNUNET_SCALARPRODUCT_DatumProcessor cont,
165 * Used by Bob's client to cooperate with Alice,
167 * @param h handle to the master context
168 * @param key Session key - unique to the requesting client
169 * @param elements Array of elements of the vector
170 * @param element_count Number of elements in the vector
171 * @param cont Callback function
172 * @param cont_cls Closure for the callback function
174 struct GNUNET_SCALARPRODUCT_Handle *
175 GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *h,
176 const struct GNUNET_HashCode * key,
177 const int32_t * elements,
178 uint32_t element_count,
179 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
182 * Cancel an ongoing computation or revoke our collaboration offer.
183 * Closes the connection to the service
185 * @param h handel to terminate
188 GNUNET_SCALARPRODUCT_cancel (const struct GNUNET_SCALARPRODUCT_Handle *h);
190 #if 0 /* keep Emacsens' auto-indent happy */