- merge; service API change
[oweals/gnunet.git] / src / scalarproduct / scalarproduct.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2010, 2011, 2012, 2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20 /**
21  * @file   scalarproduct.h
22  * @brief  Scalar Product API Message Types
23  * @author Christian M. Fuchs
24  */
25 #ifndef SCALARPRODUCT_H
26 #define SCALARPRODUCT_H
27
28 GNUNET_NETWORK_STRUCT_BEGIN
29
30 /**
31  * Log an error message at log-level 'level' that indicates
32  * a failure of the command 'cmd' with the message given
33  * by gcry_strerror(rc).
34  */
35 #define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
36
37
38 /**
39  * Message type passed from client to service
40  * to initiate a request or responder role
41  */
42 struct AliceComputationMessage
43 {
44   /**
45    * GNUNET message header with type
46    * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE
47    */
48   struct GNUNET_MessageHeader header;
49
50   /**
51    * how many elements the vector in payload contains
52    */
53   uint32_t element_count_total GNUNET_PACKED;
54
55   /**
56    * contained elements the vector in payload contains
57    */
58   uint32_t element_count_contained GNUNET_PACKED;
59
60   /**
61    * Always zero.
62    */
63   uint32_t reserved GNUNET_PACKED;
64
65   /**
66    * the transaction/session key used to identify a session
67    */
68   struct GNUNET_HashCode session_key;
69
70   /**
71    * the identity of a remote peer we want to communicate with
72    */
73   struct GNUNET_PeerIdentity peer;
74
75   /**
76    * followed by struct GNUNET_SCALARPRODUCT_Element[]
77    */
78 };
79
80
81 /**
82  * Message type passed from client to service
83  * to initiate a request or responder role
84  */
85 struct BobComputationMessage
86 {
87   /**
88    * GNUNET message header with type
89    * #GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB
90    */
91   struct GNUNET_MessageHeader header;
92
93   /**
94    * how many elements the vector in payload contains
95    */
96   uint32_t element_count_total GNUNET_PACKED;
97
98   /**
99    * contained elements the vector in payload contains
100    */
101   uint32_t element_count_contained GNUNET_PACKED;
102
103   /**
104    * Always zero.
105    */
106   uint32_t reserved GNUNET_PACKED;
107
108   /**
109    * the transaction/session key used to identify a session
110    */
111   struct GNUNET_HashCode session_key;
112
113   /**
114    * followed by struct GNUNET_SCALARPRODUCT_Element[]
115    */
116 };
117
118
119 /**
120  * multipart messages following `struct ComputationMessage`
121  */
122 struct ComputationBobCryptodataMultipartMessage
123 {
124   /**
125    * GNUNET message header
126    */
127   struct GNUNET_MessageHeader header;
128
129   /**
130    * contained elements the vector in payload contains
131    */
132   uint32_t element_count_contained GNUNET_PACKED;
133
134   /**
135    * followed by struct GNUNET_SCALARPRODUCT_Element[]
136    */
137 };
138
139
140 /**
141  * Message type passed from service client
142  * to finalize a session as requester or responder
143  */
144 struct ClientResponseMessage
145 {
146   /**
147    * GNUNET message header
148    */
149   struct GNUNET_MessageHeader header;
150
151   /**
152    * 0 if no product attached
153    */
154   uint32_t product_length GNUNET_PACKED;
155
156   /**
157    * Status information about the outcome of this session,
158    * An `enum GNUNET_SCALARPRODUCT_ResponseStatus` (in NBO).
159    */
160   uint32_t status GNUNET_PACKED;
161
162   /**
163    * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1
164    */
165   int32_t range GNUNET_PACKED;
166
167   /**
168    * followed by product of length product_length (or nothing)
169    */
170 };
171
172 GNUNET_NETWORK_STRUCT_END
173
174 #endif  /* SCALARPRODUCT_H */