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;
55 typedef void (*GNUNET_SCALARPRODUCT_ResponseMessageHandler) (void *cls,
56 const struct GNUNET_MessageHeader *msg,
57 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
60 * Continuation called to notify client about result of the
64 * @param status Status of the request
66 typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
67 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
69 * Process a datum that was stored in the scalarproduct.
72 * @param status Status of the request
73 * @param type result of the computation
75 typedef void (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
76 enum GNUNET_SCALARPRODUCT_ResponseStatus status,
80 * Request by Alice's client for computing a scalar product
82 * @param h handle to the master context
83 * @param key Session key - unique to the requesting client
84 * @param peer PeerID of the other peer
85 * @param elements Array of elements of the vector
86 * @param element_count Number of elements in the vector
87 * @param mask Array of the mask
88 * @param mask_bytes number of bytes in the mask
89 * @param cont Callback function
90 * @param cont_cls Closure for the callback function
92 struct GNUNET_SCALARPRODUCT_Handle *
93 GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *h,
94 const struct GNUNET_HashCode * key,
95 const struct GNUNET_PeerIdentity *peer,
96 const int32_t * elements,
97 uint32_t element_count,
98 const unsigned char * mask,
100 GNUNET_SCALARPRODUCT_DatumProcessor cont,
104 * Used by Bob's client to cooperate with Alice,
106 * @param h handle to the master context
107 * @param key Session key - unique to the requesting client
108 * @param elements Array of elements of the vector
109 * @param element_count Number of elements in the vector
110 * @param cont Callback function
111 * @param cont_cls Closure for the callback function
113 struct GNUNET_SCALARPRODUCT_Handle *
114 GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *h,
115 const struct GNUNET_HashCode * key,
116 const int32_t * elements,
117 uint32_t element_count,
118 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
121 * Cancel an ongoing computation or revoke our collaboration offer.
122 * Closes the connection to the service
124 * @param h handel to terminate
127 GNUNET_SCALARPRODUCT_cancel (const struct GNUNET_SCALARPRODUCT_Handle *h);
129 #if 0 /* keep Emacsens' auto-indent happy */