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
34 #if 0 /* keep Emacsens' auto-indent happy */
40 * Version of the scalarproduct API.
42 #define GNUNET_SCALARPRODUCT_VERSION 0x00000042
44 enum GNUNET_SCALARPRODUCT_ResponseStatus
46 GNUNET_SCALARPRODUCT_Status_Success = 0,
47 GNUNET_SCALARPRODUCT_Status_Failure,
48 GNUNET_SCALARPRODUCT_Status_Timeout,
49 GNUNET_SCALARPRODUCT_Status_InvalidResponse,
50 GNUNET_SCALARPRODUCT_Status_ServiceDisconnected
53 struct GNUNET_SCALARPRODUCT_Handle
58 const struct GNUNET_CONFIGURATION_Handle *cfg;
61 * Current connection to the scalarproduct service.
63 struct GNUNET_CLIENT_Connection *client;
66 * Handle for statistics.
68 struct GNUNET_STATISTICS_Handle *stats;
71 * Current transmit handle.
73 struct GNUNET_CLIENT_TransmitHandle *th;
76 * Handle to the master context.
78 struct GNUNET_SCALARPRODUCT_Handle *h;
81 * The shared session key identifying this computation
83 struct GNUNET_HashCode * key;
86 * The message to be transmitted
93 * Function to call after transmission of the request.
95 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status;
98 * Function to call after transmission of the request.
100 GNUNET_SCALARPRODUCT_DatumProcessor cont_datum;
104 * Closure for 'cont'.
109 * Response Processor for response from the service. This function calls the
110 * continuation function provided by the client.
112 GNUNET_SCALARPRODUCT_ResponseMessageHandler response_proc;
115 typedef void (*GNUNET_SCALARPRODUCT_ResponseMessageHandler) (void *cls,
116 const struct GNUNET_MessageHeader *msg,
117 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
120 * Continuation called to notify client about result of the
124 * @param status Status of the request
126 typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
127 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
129 * Process a datum that was stored in the scalarproduct.
132 * @param status Status of the request
133 * @param type result of the computation
135 typedef void (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
136 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
140 * Request by Alice's client for computing a scalar product
142 * @param h handle to the master context
143 * @param key Session key - unique to the requesting client
144 * @param peer PeerID of the other peer
145 * @param elements Array of elements of the vector
146 * @param element_count Number of elements in the vector
147 * @param mask Array of the mask
148 * @param mask_bytes number of bytes in the mask
149 * @param cont Callback function
150 * @param cont_cls Closure for the callback function
152 struct GNUNET_SCALARPRODUCT_Handle *
153 GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *h,
154 const struct GNUNET_HashCode * key,
155 const struct GNUNET_PeerIdentity *peer,
156 const int32_t * elements,
157 uint32_t element_count,
158 const unsigned char * mask,
160 GNUNET_SCALARPRODUCT_DatumProcessor cont,
164 * Used by Bob's client to cooperate with Alice,
166 * @param h handle to the master context
167 * @param key Session key - unique to the requesting client
168 * @param elements Array of elements of the vector
169 * @param element_count Number of elements in the vector
170 * @param cont Callback function
171 * @param cont_cls Closure for the callback function
173 struct GNUNET_SCALARPRODUCT_Handle *
174 GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *h,
175 const struct GNUNET_HashCode * key,
176 const int32_t * elements,
177 uint32_t element_count,
178 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
181 * Cancel an ongoing computation or revoke our collaboration offer.
182 * Closes the connection to the service
184 * @param h handel to terminate
187 GNUNET_SCALARPRODUCT_cancel (const struct GNUNET_SCALARPRODUCT_Handle *h);
189 #if 0 /* keep Emacsens' auto-indent happy */