remove CYGWIN codeblocks, drop vendored Windows openvpn, drop win32 specific files.
[oweals/gnunet.git] / src / set / gnunet-service-set_protocol.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2013, 2014 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 /**
21  * @author Florian Dold
22  * @author Christian Grothoff
23  * @file set/gnunet-service-set_protocol.h
24  * @brief Peer-to-Peer messages for gnunet set
25  */
26 #ifndef SET_PROTOCOL_H
27 #define SET_PROTOCOL_H
28
29 #include "platform.h"
30 #include "gnunet_common.h"
31
32
33 GNUNET_NETWORK_STRUCT_BEGIN
34
35 struct OperationRequestMessage {
36   /**
37    * Type: #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
38    */
39   struct GNUNET_MessageHeader header;
40
41   /**
42    * Operation to request, values from `enum GNUNET_SET_OperationType`
43    */
44   uint32_t operation GNUNET_PACKED;
45
46   /**
47    * For Intersection: my element count
48    */
49   uint32_t element_count GNUNET_PACKED;
50
51   /**
52    * Application-specific identifier of the request.
53    */
54   struct GNUNET_HashCode app_idX;
55
56   /* rest: optional message */
57 };
58
59
60 /**
61  * Message containing buckets of an invertible bloom filter.
62  *
63  * If an IBF has too many buckets for an IBF message,
64  * it is split into multiple messages.
65  */
66 struct IBFMessage {
67   /**
68    * Type: #GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF
69    */
70   struct GNUNET_MessageHeader header;
71
72   /**
73    * Order of the whole ibf, where
74    * num_buckets = 2^order
75    */
76   uint8_t order;
77
78   /**
79    * Padding, must be 0.
80    */
81   uint8_t reserved1;
82
83   /**
84    * Padding, must be 0.
85    */
86   uint16_t reserved2 GNUNET_PACKED;
87
88   /**
89    * Offset of the strata in the rest of the message
90    */
91   uint32_t offset GNUNET_PACKED;
92
93   /**
94    * Salt used when hashing elements for this IBF.
95    */
96   uint32_t salt GNUNET_PACKED;
97
98   /* rest: buckets */
99 };
100
101
102 struct InquiryMessage {
103   /**
104    * Type: #GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF
105    */
106   struct GNUNET_MessageHeader header;
107
108   /**
109    * Salt used when hashing elements for this inquiry.
110    */
111   uint32_t salt GNUNET_PACKED;
112
113   /**
114    * Reserved, set to 0.
115    */
116   uint32_t reserved GNUNET_PACKED;
117
118   /* rest: inquiry IBF keys */
119 };
120
121
122 /**
123  * During intersection, the first (and possibly second) message
124  * send it the number of elements in the set, to allow the peers
125  * to decide who should start with the Bloom filter.
126  */
127 struct IntersectionElementInfoMessage {
128   /**
129    * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO
130    */
131   struct GNUNET_MessageHeader header;
132
133   /**
134    * mutator used with this bloomfilter.
135    */
136   uint32_t sender_element_count GNUNET_PACKED;
137 };
138
139
140 /**
141  * Bloom filter messages exchanged for set intersection calculation.
142  */
143 struct BFMessage {
144   /**
145    * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF
146    */
147   struct GNUNET_MessageHeader header;
148
149   /**
150    * Number of elements the sender still has in the set.
151    */
152   uint32_t sender_element_count GNUNET_PACKED;
153
154   /**
155    * XOR of all hashes over all elements remaining in the set.
156    * Used to determine termination.
157    */
158   struct GNUNET_HashCode element_xor_hash;
159
160   /**
161    * Mutator used with this bloomfilter.
162    */
163   uint32_t sender_mutator GNUNET_PACKED;
164
165   /**
166    * Total length of the bloomfilter data.
167    */
168   uint32_t bloomfilter_total_length GNUNET_PACKED;
169
170   /**
171    * Number of bits (k-value) used in encoding the bloomfilter.
172    */
173   uint32_t bits_per_element GNUNET_PACKED;
174
175   /**
176    * rest: the sender's bloomfilter
177    */
178 };
179
180
181 /**
182  * Last message, send to confirm the final set.  Contains the element
183  * count as it is possible that the peer determined that we were done
184  * by getting the empty set, which in that case also needs to be
185  * communicated.
186  */
187 struct IntersectionDoneMessage {
188   /**
189    * Type: #GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE
190    */
191   struct GNUNET_MessageHeader header;
192
193   /**
194    * Final number of elements in intersection.
195    */
196   uint32_t final_element_count GNUNET_PACKED;
197
198   /**
199    * XOR of all hashes over all elements remaining in the set.
200    */
201   struct GNUNET_HashCode element_xor_hash;
202 };
203
204
205 /**
206  * Strata estimator together with the peer's overall set size.
207  */
208 struct StrataEstimatorMessage {
209   /**
210    * Type: #GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE(C)
211    */
212   struct GNUNET_MessageHeader header;
213
214   uint64_t set_size;
215 };
216
217 GNUNET_NETWORK_STRUCT_END
218
219 #endif