remmoved deprecated headerfile from scalarproduct
[oweals/gnunet.git] / src / include / gnunet_scalarproduct_service.h
1 /*
2       This file is part of GNUnet.
3       (C) 2013 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19  */
20
21 /**
22  * @file include/gnunet_scalarproduct_service.h
23  * @brief API to the scalarproduct service
24  * @author Christian M. Fuchs
25  * @author Gaurav Kukreja
26  */
27 #ifndef GNUNET_SCALARPRODUCT_SERVICE_H
28 #define GNUNET_SCALARPRODUCT_SERVICE_H
29 #define GCRYPT_NO_DEPRECATED
30 #include <gcrypt.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #if 0                           /* keep Emacsens' auto-indent happy */
35 }
36 #endif
37 #endif
38
39 /**
40  * Version of the scalarproduct API.
41  */
42 #define GNUNET_SCALARPRODUCT_VERSION 0x00000042
43
44 enum GNUNET_SCALARPRODUCT_ResponseStatus
45 {
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
51 };
52
53 struct GNUNET_SCALARPRODUCT_Handle
54 {
55   /**
56    * Our configuration.
57    */
58   const struct GNUNET_CONFIGURATION_Handle *cfg;
59
60   /**
61    * Current connection to the scalarproduct service.
62    */
63   struct GNUNET_CLIENT_Connection *client;
64
65   /**
66    * Handle for statistics.
67    */
68   struct GNUNET_STATISTICS_Handle *stats;
69
70   /**
71    * Current transmit handle.
72    */
73   struct GNUNET_CLIENT_TransmitHandle *th;
74   
75   /**
76    * Handle to the master context.
77    */
78   struct GNUNET_SCALARPRODUCT_Handle *h;
79   
80   /**
81    * The shared session key identifying this computation
82    */
83   struct GNUNET_HashCode * key;
84   
85   /**
86    * The message to be transmitted
87    */
88   void * msg;
89
90   union
91   {
92     /**
93      * Function to call after transmission of the request.
94      */
95     GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status;
96
97     /**
98      * Function to call after transmission of the request.
99      */
100     GNUNET_SCALARPRODUCT_DatumProcessor cont_datum;
101   };
102
103   /**
104    * Closure for 'cont'.
105    */
106   void *cont_cls;
107
108   /**
109    * Response Processor for response from the service. This function calls the
110    * continuation function provided by the client.
111    */
112   GNUNET_SCALARPRODUCT_ResponseMessageHandler response_proc;
113 };
114
115 typedef void (*GNUNET_SCALARPRODUCT_ResponseMessageHandler) (void *cls,
116                                                              const struct GNUNET_MessageHeader *msg,
117                                                              enum GNUNET_SCALARPRODUCT_ResponseStatus status);
118
119 /**
120  * Continuation called to notify client about result of the
121  * operation.
122  *
123  * @param cls closure
124  * @param status Status of the request
125  */
126 typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
127                                                              enum GNUNET_SCALARPRODUCT_ResponseStatus status);
128 /**
129  * Process a datum that was stored in the scalarproduct.
130  * 
131  * @param cls closure
132  * @param status Status of the request
133  * @param type result of the computation
134  */
135 typedef void (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
136                                                      enum GNUNET_SCALARPRODUCT_ResponseStatus status,
137                                                      gcry_mpi_t result);
138
139 /**
140  * Request by Alice's client for computing a scalar product
141  * 
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
151  */
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,
159                               uint32_t mask_bytes,
160                               GNUNET_SCALARPRODUCT_DatumProcessor cont,
161                               void *cont_cls);
162
163 /**
164  * Used by Bob's client to cooperate with Alice, 
165  * 
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
172  */
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,
179                                void *cont_cls);
180 /**
181  * Cancel an ongoing computation or revoke our collaboration offer.
182  * Closes the connection to the service
183  * 
184  * @param h handel to terminate
185  */
186 void 
187 GNUNET_SCALARPRODUCT_cancel (const struct GNUNET_SCALARPRODUCT_Handle *h);
188
189 #if 0                           /* keep Emacsens' auto-indent happy */
190 {
191 #endif
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif