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