- do not use SIGUSR1 on SuperMUC
[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_InvalidResponse,
49   GNUNET_SCALARPRODUCT_Status_ServiceDisconnected
50 };
51
52 /**
53  * Opaque declaration of the SP-Handle
54  */
55 struct GNUNET_SCALARPRODUCT_Handle;
56
57 /**
58  * Continuation called to notify client about result of the
59  * operation.
60  *
61  * @param cls closure
62  * @param status Status of the request
63  */
64 typedef void (*GNUNET_SCALARPRODUCT_ContinuationWithStatus) (void *cls,
65                                                              enum GNUNET_SCALARPRODUCT_ResponseStatus status);
66 /**
67  * Process a datum that was stored in the scalarproduct.
68  *
69  * @param cls closure
70  * @param status Status of the request
71  * @param result result of the computation
72  */
73 typedef void (*GNUNET_SCALARPRODUCT_DatumProcessor) (void *cls,
74                                                      enum GNUNET_SCALARPRODUCT_ResponseStatus status,
75                                                      gcry_mpi_t result);
76
77 /**
78  * Request by Alice's client for computing a scalar product
79  *
80  * @param cfg the gnunet configuration handle
81  * @param key Session key should be unique to the requesting client
82  * @param peer PeerID of the other peer
83  * @param elements Array of elements of the vector
84  * @param element_count Number of elements in the vector
85  * @param mask Array of the mask
86  * @param mask_bytes number of bytes in the mask
87  * @param cont Callback function
88  * @param cont_cls Closure for the callback function
89  * 
90  * @return a new handle for this computation
91  */
92 struct GNUNET_SCALARPRODUCT_ComputationHandle *
93 GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle * cfg,
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,
99                               uint32_t mask_bytes,
100                               GNUNET_SCALARPRODUCT_DatumProcessor cont,
101                               void * cont_cls);
102
103 /**
104  * Used by Bob's client to cooperate with Alice,
105  *
106  * @param cfg the gnunet configuration handle
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
112  * 
113  * @return a new handle for this computation
114  */
115 struct GNUNET_SCALARPRODUCT_ComputationHandle *
116 GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle * cfg,
117                                const struct GNUNET_HashCode * key,
118                                const int32_t * elements,
119                                uint32_t element_count,
120                                GNUNET_SCALARPRODUCT_ContinuationWithStatus cont,
121                                void * cont_cls);
122 /**
123  * Cancel an ongoing computation or revoke our collaboration offer.
124  * Closes the connection to the service
125  *
126  * @param h computation handle to terminate
127  */
128 void
129 GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle * h);
130
131 /**
132  * Cancel ALL ongoing computation or revoke our collaboration offer.
133  * Closes ALL connections to the service
134  */
135 void
136 GNUNET_SCALARPRODUCT_disconnect ();
137
138 #if 0                           /* keep Emacsens' auto-indent happy */
139 {
140 #endif
141 #ifdef __cplusplus
142 }
143 #endif
144
145 #endif