-ensure stats queues do not grow too big
[oweals/gnunet.git] / src / multicast / multicast.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 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 /**
22  * @file multicast/multicast.h
23  * @brief multicast IPC messages
24  * @author Christian Grothoff
25  * @author Gabor X Toth
26  */
27 #ifndef MULTICAST_H
28 #define MULTICAST_H
29
30 #include "platform.h"
31 #include "gnunet_multicast_service.h"
32
33 GNUNET_NETWORK_STRUCT_BEGIN
34
35
36 /**
37  * Header of a join request sent to the origin or another member.
38  */
39 struct MulticastJoinRequestMessage
40 {
41   /**
42    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST
43    */
44   struct GNUNET_MessageHeader header;
45
46   /**
47    * Always zero.
48    */
49   uint32_t reserved;
50
51   /**
52    * ECC signature of the rest of the fields of the join request.
53    *
54    * Signature must match the public key of the joining member.
55    */
56   struct GNUNET_CRYPTO_EcdsaSignature signature;
57
58   /**
59    * Purpose for the signature and size of the signed data.
60    */
61   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
62
63   /**
64    * Public key of the target group.
65    */
66   struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
67
68   /**
69    * Public key of the joining member.
70    */
71   struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
72
73   /**
74    * Peer identity of the joining member.
75    */
76   struct GNUNET_PeerIdentity peer;
77
78   /* Followed by struct GNUNET_MessageHeader join_message */
79 };
80
81
82 /**
83  * Header of a join decision message sent to a peer requesting join.
84  */
85 struct MulticastJoinDecisionMessage
86 {
87   /**
88    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
89    */
90   struct GNUNET_MessageHeader header;
91
92   /**
93    * #GNUNET_YES    if the peer was admitted
94    * #GNUNET_NO     if entry was refused,
95    * #GNUNET_SYSERR if the request could not be answered.
96    */
97   int32_t is_admitted;
98
99   /**
100    * Number of relays given.
101    */
102   uint32_t relay_count;
103
104   /* Followed by relay_count peer identities */
105
106   /* Followed by the join response message */
107 };
108
109
110 /**
111  * Header added to a struct MulticastJoinDecisionMessage
112  * when sent between the client and service.
113  */
114 struct MulticastJoinDecisionMessageHeader
115 {
116   /**
117    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION
118    */
119   struct GNUNET_MessageHeader header;
120
121   /**
122    * C->S: Peer to send the join decision to.
123    * S->C: Peer we received the join decision from.
124    */
125   struct GNUNET_PeerIdentity peer;
126
127   /**
128    * C->S: Public key of the member requesting join.
129    * S->C: Unused.
130    */
131   struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
132
133   /* Followed by struct MulticastJoinDecisionMessage */
134 };
135
136
137 /**
138  * Message sent from the client to the service to notify the service
139  * about the result of a membership test.
140  */
141 struct MulticastMembershipTestResultMessage
142 {
143   /**
144    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_MEMBERSHIP_TEST_RESULT
145    */
146   struct GNUNET_MessageHeader header;
147
148   /**
149    * Unique ID that identifies the associated membership test.
150    */
151   uint32_t uid;
152
153   /**
154    * #GNUNET_YES    if the peer is a member
155    * #GNUNET_NO     if peer is not a member,
156    * #GNUNET_SYSERR if the test could not be answered.
157    */
158   int32_t is_admitted;
159 };
160
161
162 /**
163  * Message sent from the client to the service OR the service to the
164  * client asking for a message fragment to be replayed.
165  */
166 struct MulticastReplayRequestMessage
167 {
168
169   /**
170    * The message type should be
171    * #GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_REQUEST.
172    */
173   struct GNUNET_MessageHeader header;
174
175   /**
176    * S->C: Public key of the member requesting replay.
177    * C->S: Unused.
178    */
179   struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
180
181   /**
182    * ID of the message that is being requested.
183    */
184   uint64_t fragment_id;
185
186   /**
187    * ID of the message that is being requested.
188    */
189   uint64_t message_id;
190
191   /**
192    * Offset of the fragment that is being requested.
193    */
194   uint64_t fragment_offset;
195
196   /**
197    * Additional flags for the request.
198    */
199   uint64_t flags;
200
201   /**
202    * Replay request ID.
203    */
204   uint32_t uid;
205 };
206
207
208 /**
209  * Message sent from the client to the service to give the service
210  * a replayed message.
211  */
212 struct MulticastReplayResponseMessage
213 {
214
215   /**
216    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE
217    *    or GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE_END
218    */
219   struct GNUNET_MessageHeader header;
220
221   /**
222    * ID of the message that is being requested.
223    */
224   uint64_t fragment_id;
225
226   /**
227    * ID of the message that is being requested.
228    */
229   uint64_t message_id;
230
231   /**
232    * Offset of the fragment that is being requested.
233    */
234   uint64_t fragment_offset;
235
236   /**
237    * Additional flags for the request.
238    */
239   uint64_t flags;
240
241   /**
242    * An `enum GNUNET_MULTICAST_ReplayErrorCode` identifying issues (in NBO).
243    */
244   int32_t error_code;
245
246   /* followed by replayed message */
247 };
248
249
250 /**
251  * Message sent from the client to the service to notify the service
252  * about the starting of a multicast group with this peers as its origin.
253  */
254 struct MulticastOriginStartMessage
255 {
256   /**
257    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START
258    */
259   struct GNUNET_MessageHeader header;
260
261   /**
262    * Always zero.
263    */
264   uint32_t reserved;
265
266   /**
267    * Private, non-ephemeral key for the multicast group.
268    */
269   struct GNUNET_CRYPTO_EddsaPrivateKey group_key;
270
271   /**
272    * Last fragment ID sent to the group, used to continue counting fragments if
273    * we resume operating * a group.
274    */
275   uint64_t max_fragment_id;
276
277 };
278
279
280 struct MulticastMemberJoinMessage
281 {
282   /**
283    * Type: GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN
284    */
285   struct GNUNET_MessageHeader header;
286
287   uint32_t relay_count GNUNET_PACKED;
288
289   struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
290
291   struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
292
293   struct GNUNET_PeerIdentity origin;
294
295   /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
296
297   /* Followed by struct GNUNET_MessageHeader join_msg */
298 };
299
300
301 #if NOT_USED
302 /**
303  * Message sent from the client to the service to broadcast to all group
304  * members.
305  */
306 struct MulticastBroadcastMessage
307 {
308
309   /**
310    *
311    */
312   struct GNUNET_MessageHeader header;
313
314   /**
315    * #GNUNET_OK normally, #GNUNET_SYSERR if the origin aborted the
316    * transmission.
317    */
318   int32_t status;
319
320   /**
321    * Message ID.
322    */
323   uint64_t message_id;
324
325   /**
326    * Group generation.
327    */
328   uint64_t group_generation;
329
330   /**
331    * Total message size.
332    */
333   uint64_t total_size;
334
335 };
336
337
338 /**
339  * Message sent from the client to the service to join a multicast group.
340  */
341 struct MulticastJoinMessage
342 {
343
344   /**
345    *
346    */
347   struct GNUNET_MessageHeader header;
348
349   /**
350    * Number of relays we (think) we already know about.
351    */
352   uint32_t relay_count;
353
354   /**
355    * Public non-ephemeral key of the mutlicast group.
356    */
357   struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
358
359   /**
360    * Our private key for the group.
361    */
362   struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
363
364   /* followed by 'relay_count' `struct GNUNET_PeerIdentity`s */
365
366 };
367
368
369
370 /**
371  * Message sent from the client to the service to unicast to the group origin.
372  */
373 struct MulticastUnicastToOriginMessage
374 {
375
376   /**
377    *
378    */
379   struct GNUNET_MessageHeader header;
380
381   /**
382    * Reserved (always 0).
383    */
384   uint32_t reserved;
385
386   /**
387    * Message ID.
388    */
389   uint64_t message_id;
390
391   /**
392    * Total message size.
393    */
394   uint64_t total_size;
395
396   /* followed by payload */
397
398 };
399
400
401 /**
402  * Message sent from the client to the service to
403  * cancel unicast to the group origin.
404  */
405 struct MulticastUnicastToOriginCancelMessage
406 {
407
408   /**
409    *
410    */
411   struct GNUNET_MessageHeader header;
412
413   /**
414    * Reserved (always 0).
415    */
416   uint32_t reserved;
417
418   /**
419    * Message ID.
420    */
421   uint64_t message_id;
422
423 };
424 #endif // NOT_USED
425
426 GNUNET_NETWORK_STRUCT_END
427
428 #endif
429 /* end of multicast.h */